Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Generate a visual display of a hypergraph
ResourceFunction["WolframModelPlot"][g] generates a plot of the hypergraph g. | |
ResourceFunction["WolframModelPlot"][{g1,g2,…}] generates a list of plots of the hypergraphs gi. | |
ResourceFunction["WolframModelPlot"][data,"type"] generates plots assuming hypergraphs of the specified type. |
"Ordered" | every hyperedge is interpreted as a sequence of directed edges of adjacent vertices |
"Cyclic" | the same as "Ordered", with an addition of a directed edge from the last vertex to the first |
"ArrowheadLength" | Automatic | the length of arrowheads |
"EdgePolygonStyle" | Automatic | style for hyperedge polygons |
"HyperedgeRendering" | "Polygons" | how to render hyperedges in the hypergraph |
"MaxImageSize" | Automatic | upper limit for the image size |
EdgeStyle | Automatic | style for edges |
GraphHighlight | {} | vertices and hyperedges to highlight |
GraphHighlightStyle | Red | highlight color |
PlotStyle | Automatic | overall style |
VertexCoordinateRules | {} | coordinates specified for particular vertices |
VertexLabels | None | labels for vertices |
VertexSize | 0.06 | the size of vertices |
VertexStyle | Automatic | style for vertices |
"Subgraphs" | render hyperedges as ordinary graphs | |
"Polygons" | render hyperedges as polygons |
Plot a hypergraph:
In[1]:= |
|
Out[1]= |
|
Plot multiple hypergraphs:
In[2]:= |
|
Out[2]= |
|
Plot a cyclic hypergraph:
In[3]:= |
|
Out[3]= |
|
Unary edges are shown as circles around the vertices:
In[4]:= |
|
Out[4]= |
|
Self-loops are shown as convex polygons around the appropriate number of circular arrows:
In[5]:= |
|
Out[5]= |
|
Note the difference between a hyper-self-loop and two binary edges pointing in opposite directions:
In[6]:= |
|
Out[6]= |
|
Multiedges are shown as multiple arrows and polygons:
In[7]:= |
|
Out[7]= |
|
Highlight some vertices and edges:
In[8]:= |
|
Out[8]= |
|
Change the color of the highlight:
In[9]:= |
|
Out[9]= |
|
Unroll each hypergraph to a sequence of binary edges:
In[10]:= |
|
Out[10]= |
|
Specify custom coordinates for the vertices:
In[11]:= |
|
Out[11]= |
|
Display the labels for vertices:
In[12]:= |
|
Out[12]= |
|
Make vertices appear larger:
In[13]:= |
|
Out[13]= |
|
Make arrowheads appear larger:
In[14]:= |
|
Out[14]= |
|
Reduce the maximum image size, but keep small hypergraphs small:
In[15]:= |
|
Out[15]= |
|
Specify an overall style:
In[16]:= |
|
Out[16]= |
|
Specify a style for vertices:
In[17]:= |
|
Out[17]= |
|
Styles for each vertex can be given as a List:
In[18]:= |
|
Out[18]= |
|
Styles for different vertex patterns can be given as an Association:
In[19]:= |
|
Out[19]= |
|
Specify a style for edges:
In[20]:= |
|
Out[20]= |
|
Styles for each edge can be given as a List:
In[21]:= |
|
Out[21]= |
|
Styles for different edge patterns can be given as an Association:
In[22]:= |
|
Out[22]= |
|
Specify a style for edge polygons:
In[23]:= |
|
Out[23]= |
|
This can be specified independently from the style for edge lines:
In[24]:= |
|
Out[24]= |
|
WolframModelPlot is used in various properties of WolframModel:
In[25]:= |
|
Out[25]= |
|
It is also used in RulePlot:
In[26]:= |
|
Out[26]= |
|
It may be hard to see the boundaries between hyperedges:
In[27]:= |
|
Out[27]= |
|
Using different colors for each edge might help:
In[28]:= |
|
Out[28]= |
|
Manually specifying coordinates might break the scaling, so vertices and arrowheads may appear too large relative to the distance between vertices:
In[29]:= |
|
Out[29]= |
|
Manually reduce the vertex/arrowhead sizes to get a better-looking image:
In[30]:= |
|
Out[30]= |
|
Make polygon art by getting rid of the vertices and arrowheads:
In[31]:= |
|
Out[31]= |
|
Make an unordered hypergraph plot by specifying a custom edge style:
In[32]:= |
|
Out[32]= |
|
Display binary and ternary edges in different colors:
In[33]:= |
|
Out[33]= |
|
This work is licensed under a Creative Commons Attribution 4.0 International License