Hypergraph rewriting repeatedly transforms a hypergraph by replacing subhypergraphs that match the left-hand side of a rule with the right-hand side of the rule. Systems of this kind, known as Wolfram models, are studied as models of fundamental physics, and the Hypergraph paclet provides the objects to build, apply, visualize and enumerate such rules.
The "Hypergraph" key holds the rewritten hypergraph; newly created vertices get fresh names:
In[5]:=
First[matches]["Hypergraph"]
Out[5]=
Edge Symmetry and Matching
The number of matches depends on the edge symmetry of the hypergraph and the rule. By default hyperedges are unordered, so a single binary pattern edge matches each binary edge in both orientations. With "Ordered" symmetry each edge matches only one way:
renders every match of a rule inside a hypergraph, highlighting the matched edges and the produced edges:
In[8]:=
HighlightRule
HypergraphRule
Hypergraph
[{{1,2}},"EdgeSymmetry""Ordered"],
Hypergraph
[{{1,2},{2,3}},"EdgeSymmetry""Ordered"],
Hypergraph
[{{a,b},{b,c}},"EdgeSymmetry""Ordered"]
Out[8]=
,
Evolution
Iterating a rule produces an evolution of hypergraph states. Here each step applies the first available match:
The edge counts grow by one at each step:
Applying all matches simultaneously, or exploring every match branch separately, leads to multiway evolution; the per-match records returned by rule application carry enough information ("MatchEdgePositions", "NewEdges", "DeletedVertices") to build either.