Skip to content

Commit

Permalink
Markdown Linter (#581)
Browse files Browse the repository at this point in the history
## Changes
* Adds [markdown linter](https://github.com/DavidAnson/markdownlint)
* Enforces 120 characters line width
* Related to #247
* Closes #582

## Examples
Some common errors:
![image](https://user-images.githubusercontent.com/26678747/102560353-08b5a880-40a0-11eb-87be-be2787ccdc6c.png)

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/maxitg/setreplace/581)
<!-- Reviewable:end -->
  • Loading branch information
aokellermann authored Dec 18, 2020
1 parent 2a95d9e commit ec58541
Show file tree
Hide file tree
Showing 55 changed files with 1,262 additions and 658 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ jobs:
- run:
name: Install Required Tools
command: |
apk add --no-cache bash git g++ make cmake clang py-pip shellcheck shfmt grep
apk add --no-cache bash git g++ make cmake clang py-pip shellcheck shfmt grep npm
pip install cpplint
npm install -g markdownlint-cli
- run:
name: Lint
Expand Down
521 changes: 380 additions & 141 deletions .github/CONTRIBUTING.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ assignees: ''
---

### The problem

Is your feature request related to a problem? Please describe. Ex. I'm always frustrated when [...]

### Possible solution

A clear and concise description of what you want to happen.

### Alternative solutions

A clear and concise description of any alternative solutions or features you've considered.

### Additional context

Add any other context or screenshots about the feature request here.
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/weed_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,33 @@ assignees: ''
---

### The problem

A clear and concise description of what is not working.

```wl
In[] := minimal input that is not working
```

image of the actual output.

### Expected behavior

A clear and concise description of what you expected to happen.

### Version

```wl
In[] := SystemInformation["Small"]
```

image of the output

```wl
In[] := $SetReplaceGitSHA
```

paste the output here without quotes.

### Additional context

Add any other context or screenshots about the weed report here.
3 changes: 3 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
## Changes

* Reference resolved issues.
* Add a few comments about what this pull request changes.

## Comments

* Add comments for the reviewer.

## Examples

* Add explicit inputs and outputs (as screenshots in case of graphics) showcasing new functionality.
10 changes: 10 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"line-length": {
"line_length": 120,
"headers": false
},
"no-inline-html": false,
"first-line-h1": false,
"no-blanks-blockquote": false,
"no-duplicate-heading": false
}
62 changes: 47 additions & 15 deletions Documentation/SymbolsAndFunctions/HypergraphPlot.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@

# HypergraphPlot

[Edge Type](#edge-type) | [GraphHighlight and GraphHighlightStyle](#graphhighlight-and-graphhighlightstyle) | ["HyperedgeRendering"](#hyperedgerendering) | [VertexCoordinateRules](#vertexcoordinaterules) | [VertexLabels](#vertexlabels) | [VertexSize and "ArrowheadLength"](#vertexsize-and-arrowheadlength) | ["MaxImageSize"](#maximagesize) | [Style Options](#style-options) | [Graphics Options](#graphics-options)
[Edge Type](#edge-type) | [GraphHighlight and GraphHighlightStyle](#graphhighlight-and-graphhighlightstyle)
| ["HyperedgeRendering"](#hyperedgerendering) | [VertexCoordinateRules](#vertexcoordinaterules)
| [VertexLabels](#vertexlabels) | [VertexSize and "ArrowheadLength"](#vertexsize-and-arrowheadlength)
| ["MaxImageSize"](#maximagesize) | [Style Options](#style-options) | [Graphics Options](#graphics-options)

**`HypergraphPlot`** (aka `WolframModelPlot`) is a function used to visualize [`WolframModel`](WolframModelAndWolframModelEvolutionObject/WolframModelAndWolframModelEvolutionObject.md) states. It treats lists of vertices as ordered hypergraphs, and displays each hyperedge as a polygon with arrows showing the ordering:
**`HypergraphPlot`** (aka `WolframModelPlot`) is a function used to
visualize [`WolframModel`](WolframModelAndWolframModelEvolutionObject/WolframModelAndWolframModelEvolutionObject.md)
states. It treats lists of vertices as ordered hypergraphs, and displays each hyperedge as a polygon with arrows showing
the ordering:

```wl
In[] := HypergraphPlot[{{1, 2, 3}, {3, 4, 5}, {5, 6, 7, 1}}]
```

<img src="/Documentation/Images/HypergraphPlot.png" width="478">

Edges of any arity can be mixed. The binary edges are displayed as non-filled arrows, and the unary edges are shown as circles around the vertices:
Edges of any arity can be mixed. The binary edges are displayed as non-filled arrows, and the unary edges are shown as
circles around the vertices:

```wl
In[] := HypergraphPlot[{{1, 2, 3}, {3, 4}, {4, 3}, {4, 5,
Expand All @@ -37,7 +44,8 @@ In[] := HypergraphPlot[{{1, 2, 1}, {2, 3}, {3, 2}}]

<img src="/Documentation/Images/HyperSelfLoopDoubleBinaryEdgesComparison.png" width="478">

Multiedges are shown in a darker color (because of overlaid partially transparent polygons), or as separate polygons depending on the layout (and are admittedly sometimes hard to understand):
Multiedges are shown in a darker color (because of overlaid partially transparent polygons), or as separate polygons
depending on the layout (and are admittedly sometimes hard to understand):

```wl
In[] := HypergraphPlot[{{1, 2, 3}, {3, 4, 5}, {3, 4, 5}, {1, 6, 6}, {1, 6,
Expand All @@ -56,11 +64,17 @@ In[] := HypergraphPlot[{{{1, 2, 3}},

<img src="/Documentation/Images/MultiplePlots.png" width="698">

Many [`WolframModel`](WolframModelAndWolframModelEvolutionObject/WolframModelAndWolframModelEvolutionObject.md) properties, such as [`"FinalStatePlot"`](WolframModelAndWolframModelEvolutionObject/Properties/PlotsOfStates.md) and [`"EventStatesPlotsList"`](WolframModelAndWolframModelEvolutionObject/Properties/PlotsOfEvents.md), use `HypergraphPlot` to produce output. They accept the same set of options, as enumerated below.
Many [`WolframModel`](WolframModelAndWolframModelEvolutionObject/WolframModelAndWolframModelEvolutionObject.md)
properties, such as [`"FinalStatePlot"`](WolframModelAndWolframModelEvolutionObject/Properties/PlotsOfStates.md)
and [`"EventStatesPlotsList"`](WolframModelAndWolframModelEvolutionObject/Properties/PlotsOfEvents.md),
use `HypergraphPlot` to produce output. They accept the same set of options, as enumerated below.

## Edge Type

By default, `HypergraphPlot` assumes the hypergraph edges are ordered. It is also possible to treat edges as cyclic instead (i.e., assume [`RotateLeft`](https://reference.wolfram.com/language/ref/RotateLeft.html) and [`RotateRight`](https://reference.wolfram.com/language/ref/RotateRight.html) don't change the edge), in which case `"Cyclic"` should be used as the second argument to `HypergraphPlot`:
By default, `HypergraphPlot` assumes the hypergraph edges are ordered. It is also possible to treat edges as cyclic
instead (i.e., assume [`RotateLeft`](https://reference.wolfram.com/language/ref/RotateLeft.html)
and [`RotateRight`](https://reference.wolfram.com/language/ref/RotateRight.html) don't change the edge), in which
case `"Cyclic"` should be used as the second argument to `HypergraphPlot`:

```wl
In[] := HypergraphPlot[{{1, 2, 3}, {3, 4, 5}, {5, 6, 7, 1}}, "Cyclic"]
Expand Down Expand Up @@ -100,7 +114,10 @@ In[] := HypergraphPlot[{{1, 2, 3}, {3, 4, 5}, {5, 6, 7, 1}, {7, 8, 2}, {4,

## "HyperedgeRendering"

By default, `HypergraphPlot` represents each hyperedge as a polygon. It is possible instead to drop the polygons (and the vertex layout adjustments that come with them), and simply split each hyperedge into a collection of binary edges by setting **`"HyperedgeRendering"`** to `"Subgraphs"`. This loses information (`{{1, 2}, {2, 3}}` and `{{1, 2, 3}}` would look the same), but might be useful if one does not care to see the separation between hyperedges:
By default, `HypergraphPlot` represents each hyperedge as a polygon. It is possible instead to drop the polygons (and
the vertex layout adjustments that come with them), and simply split each hyperedge into a collection of binary edges by
setting **`"HyperedgeRendering"`** to `"Subgraphs"`. This loses information (`{{1, 2}, {2, 3}}` and `{{1, 2, 3}}` would
look the same), but might be useful if one does not care to see the separation between hyperedges:

```wl
In[] := HypergraphPlot[{{1, 2, 3}, {3, 4, 5}, {5, 6, 7, 1}, {7, 8, 2}, {4,
Expand All @@ -122,7 +139,10 @@ In[] := HypergraphPlot[{{1, 2, 3}, {2, 4, 5}, {2, 6, 7, 8}, {8, 9, 1}},

<img src="/Documentation/Images/PlotWithCustomCoordinates.png" width="478">

Unfortunately, due to limitations of [`GraphEmbedding`](https://reference.wolfram.com/language/ref/GraphEmbedding.html), specifying coordinates of two or more vertices breaks the scaling of distances. As a result, vertices and arrowheads might appear too small or too large and need to be manually adjusted. This might also affect [`RulePlot`](RulePlotOfWolframModel.md) in some cases.
Unfortunately, due to limitations of [`GraphEmbedding`](https://reference.wolfram.com/language/ref/GraphEmbedding.html),
specifying coordinates of two or more vertices breaks the scaling of distances. As a result, vertices and arrowheads
might appear too small or too large and need to be manually adjusted. This might also
affect [`RulePlot`](RulePlotOfWolframModel.md) in some cases.

```wl
In[] := HypergraphPlot[{{1, 2, 3}, {2, 4, 5}, {2, 6, 7, 8}, {8, 9, 1}},
Expand All @@ -141,7 +161,8 @@ In[] := HypergraphPlot[{{1, 2, 3}, {2, 4, 5}, {2, 6, 7, 8}, {8, 9, 1}},

## VertexLabels

`"VertexLabels" -> Automatic` displays labels for vertices, similar to [`GraphPlot`](https://reference.wolfram.com/language/ref/GraphPlot.html):
`"VertexLabels" -> Automatic` displays labels for vertices, similar
to [`GraphPlot`](https://reference.wolfram.com/language/ref/GraphPlot.html):

```wl
In[] := HypergraphPlot[{{1, 2, 3}, {2, 4, 5}, {2, 6, 7, 8}, {8, 9, 1}},
Expand All @@ -152,7 +173,8 @@ In[] := HypergraphPlot[{{1, 2, 3}, {2, 4, 5}, {2, 6, 7, 8}, {8, 9, 1}},

## VertexSize and "ArrowheadLength"

The size of vertices and the length of arrowheads (in the internal graphics units), can be adjusted with **`VertexSize`** and **`"ArrowheadLength"`** options respectively:
The size of vertices and the length of arrowheads (in the internal graphics units), can be adjusted
with **`VertexSize`** and **`"ArrowheadLength"`** options respectively:

```wl
In[] := HypergraphPlot[{{1, 2, 3, 4}, {1, 5, 6}, {2, 7, 8}, {4, 6, 9}},
Expand All @@ -161,7 +183,10 @@ In[] := HypergraphPlot[{{1, 2, 3, 4}, {1, 5, 6}, {2, 7, 8}, {4, 6, 9}},

<img src="/Documentation/Images/PlotWithCustomElementSizes.png" width="478">

Note that unlike [`GraphPlot`](https://reference.wolfram.com/language/ref/GraphPlot.html), both vertices and arrowheads have a fixed size relative to the layout (in fact, the arrowheads are drawn manually as polygons). This fixed size implies that they scale proportionally when the image is resized, and do not overlay/disappear for tiny/huge graphs or image sizes.
Note that unlike [`GraphPlot`](https://reference.wolfram.com/language/ref/GraphPlot.html), both vertices and arrowheads
have a fixed size relative to the layout (in fact, the arrowheads are drawn manually as polygons). This fixed size
implies that they scale proportionally when the image is resized, and do not overlay/disappear for tiny/huge graphs or
image sizes.

These options can also be used to get rid of vertices and arrowheads altogether:

Expand All @@ -187,7 +212,8 @@ In[] := HypergraphPlot[{{1, 2, 2}, {2, 3, 3}, {3, 1, 1}},

## "MaxImageSize"

**`"MaxImageSize"`** allows one to specify the image size while allowing for automatic reduction for very small hypergraphs. To demonstrate that, consider the difference:
**`"MaxImageSize"`** allows one to specify the image size while allowing for automatic reduction for very small
hypergraphs. To demonstrate that, consider the difference:

```wl
In[] := HypergraphPlot[{{{1}}, {{1, 1}}, {{1, 2, 3}}},
Expand Down Expand Up @@ -246,7 +272,8 @@ In[] := HypergraphPlot[{{1, 2, 3}, {3, 4, 5}, {5, 6, 7, 1}, {7, 8, 2}, {4,

<img src="/Documentation/Images/PlotWithCustomEdgePolygonStyle.png" width="478">

It is possible to specify styles separately for each edge and vertex. Vertex styles are specified in the same order as `Union @* Catenate` evaluated on the list of edges:
It is possible to specify styles separately for each edge and vertex. Vertex styles are specified in the same order
as `Union @* Catenate` evaluated on the list of edges:

```wl
In[] := HypergraphPlot[{{1, 2, 3}, {3, 4, 5}, {5, 6, 7, 1}, {7, 8, 2}, {4,
Expand All @@ -256,7 +283,9 @@ In[] := HypergraphPlot[{{1, 2, 3}, {3, 4, 5}, {5, 6, 7, 1}, {7, 8, 2}, {4,

<img src="/Documentation/Images/PlotWithElementwiseStyles.png" width="478">

Alternatively, one can specify different styles for different patterns of elements. In this case, styles are specified as [`Association`](https://reference.wolfram.com/language/ref/Association.html)s with patterns for keys. This can be used to, for example, differently color edges of different arities:
Alternatively, one can specify different styles for different patterns of elements. In this case, styles are specified
as [`Association`](https://reference.wolfram.com/language/ref/Association.html)s with patterns for keys. This can be
used to, for example, differently color edges of different arities:

```wl
In[] := HypergraphPlot[WolframModel[{{1, 2, 3}, {4, 5, 6}, {2, 5}, {5, 2}} ->
Expand All @@ -271,7 +300,10 @@ In[] := HypergraphPlot[WolframModel[{{1, 2, 3}, {4, 5, 6}, {2, 5}, {5, 2}} ->

## Graphics Options

All [`Graphics`](https://reference.wolfram.com/language/ref/Graphics.html) options are supported as well, such as [`Background`](https://reference.wolfram.com/language/ref/Background.html), [`PlotRange`](https://reference.wolfram.com/language/ref/PlotRange.html), [`Axes`](https://reference.wolfram.com/language/ref/Axes.html), etc.:
All [`Graphics`](https://reference.wolfram.com/language/ref/Graphics.html) options are supported as well, such
as [`Background`](https://reference.wolfram.com/language/ref/Background.html)
, [`PlotRange`](https://reference.wolfram.com/language/ref/PlotRange.html)
, [`Axes`](https://reference.wolfram.com/language/ref/Axes.html), etc.:

```wl
In[] := HypergraphPlot[WolframModel[{{1, 2}} -> {{1, 3}, {1, 3}, {3, 2}},
Expand Down
28 changes: 21 additions & 7 deletions Documentation/SymbolsAndFunctions/RulePlotOfWolframModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

# RulePlot of WolframModel

[**`RulePlot`**](https://reference.wolfram.com/language/ref/RulePlot.html) can be used to get a [`HypergraphPlot`](HypergraphPlot.md)-based visual representation of hypergraph substitution rules:
[**`RulePlot`**](https://reference.wolfram.com/language/ref/RulePlot.html) can be used to get
a [`HypergraphPlot`](HypergraphPlot.md)-based visual representation of hypergraph substitution rules:

```wl
In[] := RulePlot[WolframModel[{{1, 2}, {1, 2}} ->
Expand All @@ -11,7 +12,8 @@ In[] := RulePlot[WolframModel[{{1, 2}, {1, 2}} ->

<img src="/Documentation/Images/RulePlot.png" width="429">

The shared elements between rule sides (vertices `1` and `2` in the example above) are put at the same positions in the `RulePlot` and highlighted in a darker shade of blue. Shared edges are highlighted as well:
The shared elements between rule sides (vertices `1` and `2` in the example above) are put at the same positions in
the `RulePlot` and highlighted in a darker shade of blue. Shared edges are highlighted as well:

```wl
In[] := RulePlot[WolframModel[{{1, 2, 3}} -> {{1, 2, 3}, {3, 4, 5}}]]
Expand All @@ -29,13 +31,17 @@ In[] := RulePlot[WolframModel[{{{1, 1, 2}} ->

<img src="/Documentation/Images/MultipleRulesPlot.png" width="808">

Passing a [`WolframModelEvolutionObject`](/Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/WolframModelAndWolframModelEvolutionObject.md) plots its [`"Rules"`](/Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/Rules.md) property:
Passing
a [`WolframModelEvolutionObject`](/Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/WolframModelAndWolframModelEvolutionObject.md)
plots its [`"Rules"`](/Documentation/SymbolsAndFunctions/WolframModelAndWolframModelEvolutionObject/Properties/Rules.md)
property:

<img src="/Documentation/Images/RulePlotWolframModelEvolutionObjectInput.png" width="575">

<img src="/Documentation/Images/RulePlot.png" width="429">

Sometimes an incorrectly scaled layout might be produced due to the issue discussed above in [`VertexCoordinateRules`](HypergraphPlot.md#vertexcoordinaterules):
Sometimes an incorrectly scaled layout might be produced due to the issue discussed above
in [`VertexCoordinateRules`](HypergraphPlot.md#vertexcoordinaterules):

```wl
In[] := RulePlot[WolframModel[{{1, 2}, {1, 3}, {1, 4}} ->
Expand All @@ -55,9 +61,16 @@ In[] := RulePlot[WolframModel[{{1, 2}, {1, 3}, {1, 4}} ->

<img src="/Documentation/Images/RulePlotWithCustomCoordinates.png" width="429">

Some of the [`HypergraphPlot`](HypergraphPlot.md) options are supported, specifically [`GraphHighlightStyle`](HypergraphPlot.md#graphhighlight-and-graphhighlightstyle), [`"HyperedgeRendering"`](HypergraphPlot.md#hyperedgerendering), [`VertexCoordinateRules`](HypergraphPlot.md#vertexcoordinaterules), [`VertexLabels`](HypergraphPlot.md#vertexlabels), [`VertexSize`, `"ArrowheadLength"`](HypergraphPlot.md#vertexsize-and-arrowheadlength), and [style options](HypergraphPlot.md#style-options). `"EdgeType"` is supported as an option instead of [the second argument](HypergraphPlot.md#edge-type) like in [`HypergraphPlot`](HypergraphPlot.md).
Some of the [`HypergraphPlot`](HypergraphPlot.md) options are supported,
specifically [`GraphHighlightStyle`](HypergraphPlot.md#graphhighlight-and-graphhighlightstyle)
, [`"HyperedgeRendering"`](HypergraphPlot.md#hyperedgerendering)
, [`VertexCoordinateRules`](HypergraphPlot.md#vertexcoordinaterules), [`VertexLabels`](HypergraphPlot.md#vertexlabels)
, [`VertexSize`, `"ArrowheadLength"`](HypergraphPlot.md#vertexsize-and-arrowheadlength),
and [style options](HypergraphPlot.md#style-options). `"EdgeType"` is supported as an option instead
of [the second argument](HypergraphPlot.md#edge-type) like in [`HypergraphPlot`](HypergraphPlot.md).

There are also two additional `RulePlot`-specific style options. **`Spacings`** controls the amount of empty space between the rule parts and the frame (or the space where the frame would be if it's not shown):
There are also two additional `RulePlot`-specific style options. **`Spacings`** controls the amount of empty space
between the rule parts and the frame (or the space where the frame would be if it's not shown):

```wl
In[] := RulePlot[WolframModel[{{{1, 2}} -> {{1, 3}, {1, 3}, {3, 2}},
Expand All @@ -66,7 +79,8 @@ In[] := RulePlot[WolframModel[{{{1, 2}} -> {{1, 3}, {1, 3}, {3, 2}},

<img src="/Documentation/Images/RulePlotWithSmallSpacings.png" width="747">

**`"RulePartsAspectRatio"`** is used to control the aspect ratio of rule sides. As an example, it can be used to force rule parts to be square:
**`"RulePartsAspectRatio"`** is used to control the aspect ratio of rule sides. As an example, it can be used to force
rule parts to be square:

```wl
In[] := RulePlot[WolframModel[{{1, 2}} -> {{1, 3}, {1, 3}, {3, 2}}],
Expand Down
Loading

0 comments on commit ec58541

Please sign in to comment.