Hypergraphs
Draw
Draw a hypergraph stored in the hypergraph data structure
Calling Sequence
Parameters
Description
Examples
References
Compatibility
Draw(H)
Draw(H, dopts, dgopts)
H
-
Hypergraph
dopts
(optional) zero or more options specific to the Draw command, of the form vertexstylesheet=l, hyperedgestylesheet=l, smalledgestylesheet=l, bigedgestylesheet=l, output=o, or hyperedgelabels=f, where each l is a list, o is the name graph or plot or a list of these names, and f is a procedure generating hyperedge labels
dgopts
(optional) zero or more options to be passed to the GraphTheory:-DrawGraph command
The command Draw(H) displays the vertices and edges of the hypergraph H as the Maple plot of a graph G using the command DrawGraph of the package GraphTheory.
The graph G is constructed as follows.
Each vertex of H is a vertex of G.
Each hyperedge of H with at most 2 elements is an edge of G. We call these small hyperedges.
For each hyperedge e of H with more than 2 elements, a new vertex v(e) is added to the vertex set of G, and for each x in e, there is an edge in G between x and v(e). We call these big hyperedges.
The GraphTheory package can only deal with graphs whose vertices are integers, symbols (that is, variable names), or strings. Any vertices of H that are not of this type will be converted to strings. An error is raised if there are duplicates in the resulting vertex set.
Options
The Draw command accepts several options. Any arguments not of a form listed below are passed to the GraphTheory:-DrawGraph command; its help page describes these options. By default, if G is connected, the option layout = spring is passed to GraphTheory:-DrawGraph, and no options at all if G is not connected. Note that any plot options can generally be passed to GraphTheory:-DrawGraph (and therefore to the Draw command), though not all such options are useful.
vertexstylesheet = l
This option gives a list of stylesheet options to be applied to the vertices of G that correspond to the vertices of H. The default value is [color = red].
hyperedgestylesheet = l
This option gives a list of stylesheet options to be applied to the vertices v(e) of G that correspond to big hyperedges of H. The default value is [shape = hexagon, fontsize = 6, fontcolor = "_match"]. This means that the labels of these vertices will not be visible; to make the labels visible, use this option and do not include the entry fontcolor = "_match".
smalledgestylesheet = l
This option gives a list of stylesheet options to be applied to the edges of G that correspond to small hyperedges of H. The default value is [] (no special styling).
bigedgestylesheet = l
This option gives a list of stylesheet options to be applied to the edges of G that correspond to big hyperedges of H. The default value is [linestyle = dash].
output = o
By default, the Draw command returns the plot data structure corresponding to the drawing of G by the GraphTheory:-DrawGraph command. For some applications, it may be useful to use G itself, rather than the plot data structure.
If you use the option output = graph, the Draw command will return G.
If you use the option output = plot (the default), the Draw command will return the plot data structure.
If you use the option output = l, where l is a list of the names graph and plot, then the Draw command will return the corresponding values as an expression sequence. For example, if you use the option output = [plot, graph], then the Draw command will return an expression sequence P, G, where P is the plot data structure and G is the graph.
hyperedgeslabels = f
If you want to work with G, you may want to refer to its individual vertices, for example if you want to use the command GraphTheory:-StyleVertex. The vertices of G that correspond to vertices of H are the same as the vertices of H, so they can be referred to in the same way that you refer to the vertices of H. But the other vertices v(e) of G, corresponding to big hyperedges e of H, by default get a name that cannot be typed (each is a different local variable named the empty symbol).
If you specify the hyperedgeslabel option, then f is a procedure or appliable module that is applied to each big hyperedge to obtain the label of the corresponding vertex of G. Each label should be an integer, a symbol (that is, a variable name), or a string. All such labels should be distinct, and they should be distinct from the vertices of H; otherwise, an error is raised.
Note that these labels are generally not visible in the plot, because the default hyperedgestylesheet gives them a font color that matches the background color. Use the hyperedgestylesheet option if you want to see these labels in the plot.
Terminology
Hypergraph : mathematically, a hypergraph is a pair (X, Y) where X is a finite set and Y is a set of non-empty subsets of X.
Vertices : the members of X are called the vertices of the hypergraph (X, Y).
Hyperedges : the members of Y are called the hyperedges (or simply edges) of the hypergraph (X, Y).
with⁡Hypergraphs:with⁡ExampleHypergraphs
Fan,Kuratowski,Lovasz,NonEmptyPowerSet,RandomHypergraph
Create a hypergraph for which every hyperedge has size 2.
H≔Fan⁡2
H≔< a hypergraph on 3 vertices with 3 hyperedges >
Print its vertices and edges.
Vertices⁡H;Hyperedges⁡H
1,2,3
1,2,1,3,2,3
Draw a graphical representation of this hypergraph.
Draw⁡H
Construct another hypergraph with hyperedges of size 2 or 3.
K≔Fan⁡3
K≔< a hypergraph on 4 vertices with 4 hyperedges >
Print the vertices and edges of K.
Vertices⁡K;Hyperedges⁡K
1,2,3,4
1,4,2,4,3,4,1,2,3
Draw a graphical representation of K.
Draw⁡K
Draw another graphical representation of K, but make the vertices of the hypergraph be blue, 8-pointed stars.
Draw⁡K,vertexstylesheet=shape=octagram,color=blue
Draw another graphical representation of K with various changes to the stylesheets. Also specify that the labels for the vertices corresponding to big hyperedges should be the set represented as a string.
Draw⁡K,vertexstylesheet=fontstyle=bold,hyperedgestylesheet=shape=wide rectangle,padding=15,fontsize=8,smalledgestylesheet=thickness=2,bigedgestylesheet=thickness=0,color=gray,`=`⁡hyperedgelabels,s↦convert⁡s,string
If we want more control over the visualization, for example, highlighting a particular edge or vertex in the resulting graph, we can obtain the graph data structure as follows.
f := proc(s :: set, $) local stringlist := map(String, [op(s)]); return StringTools:-Join(stringlist, "-"); end proc;
f ≔ procs::set, $localstringlist;stringlist ≔ map⁡String,op⁡s;returnStringTools:-Join⁡stringlist,-end proc
G≔Draw⁡K,hyperedgelabels=f,output=graph
G≔Graph 1: an undirected graph with 5 vertices and 6 edge(s)
We now color the edge between the vertex 1 of G (corresponding to the vertex 1 of H) and the vertex "1-2-3" of G (corresponding to the hyperedge {1, 2, 3} of H).
with⁡GraphTheory:
StyleEdge⁡G,1,1-2-3,color=green
DrawGraph⁡G
Claude Berge. Hypergraphes. Combinatoires des ensembles finis. 1987, Paris, Gauthier-Villars, translated to English.
Claude Berge. Hypergraphs. Combinatorics of Finite Sets. 1989, Amsterdam, North-Holland Mathematical Library, Elsevier, translated from French.
Charles Leiserson, Liyun Li, Marc Moreno Maza and Yuzhen Xie " Parallel computation of the minimal elements of a poset." Proceedings of the 4th International Workshop on Parallel Symbolic Computation (PASCO) 2010: 53-62, ACM.
The Hypergraphs[Draw] command was introduced in Maple 2024.
For more information on Maple 2024 changes, see Updates in Maple 2024.
See Also
Hypergraphs[Hyperedges]
Hypergraphs[Hypergraph]
Hypergraphs[Vertices]
GraphTheory[DrawGraph]
Download Help Document