Draw - Maple Help

Hypergraphs

 Draw
 Draw a hypergraph stored in the hypergraph data structure

 Calling Sequence Draw(H) Draw(H, dopts, dgopts)

Parameters

 H - 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

Description

 • 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).

Examples

 > $\mathrm{with}\left(\mathrm{Hypergraphs}\right):$$\mathrm{with}\left(\mathrm{ExampleHypergraphs}\right)$
 $\left[{\mathrm{Fan}}{,}{\mathrm{Kuratowski}}{,}{\mathrm{Lovasz}}{,}{\mathrm{NonEmptyPowerSet}}{,}{\mathrm{RandomHypergraph}}\right]$ (1)

Create a hypergraph for which every hyperedge has size 2.

 > $H≔\mathrm{Fan}\left(2\right)$
 ${H}{≔}{\mathrm{< a hypergraph on 3 vertices with 3 hyperedges >}}$ (2)

Print its vertices and edges.

 > $\mathrm{Vertices}\left(H\right);$$\mathrm{Hyperedges}\left(H\right)$
 $\left[{1}{,}{2}{,}{3}\right]$
 $\left[\left\{{1}{,}{2}\right\}{,}\left\{{1}{,}{3}\right\}{,}\left\{{2}{,}{3}\right\}\right]$ (3)

Draw a graphical representation of this hypergraph.

 > $\mathrm{Draw}\left(H\right)$

Construct another hypergraph with hyperedges of size 2 or 3.

 > $K≔\mathrm{Fan}\left(3\right)$
 ${K}{≔}{\mathrm{< a hypergraph on 4 vertices with 4 hyperedges >}}$ (4)

Print the vertices and edges of K.

 > $\mathrm{Vertices}\left(K\right);$$\mathrm{Hyperedges}\left(K\right)$
 $\left[{1}{,}{2}{,}{3}{,}{4}\right]$
 $\left[\left\{{1}{,}{4}\right\}{,}\left\{{2}{,}{4}\right\}{,}\left\{{3}{,}{4}\right\}{,}\left\{{1}{,}{2}{,}{3}\right\}\right]$ (5)

Draw a graphical representation of K.

 > $\mathrm{Draw}\left(K\right)$

Draw another graphical representation of K, but make the vertices of the hypergraph be blue, 8-pointed stars.

 > $\mathrm{Draw}\left(K,\mathrm{vertexstylesheet}=\left[\mathrm{shape}="octagram",\mathrm{color}=\mathrm{blue}\right]\right)$

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.

 > $\mathrm{Draw}\left(K,\mathrm{vertexstylesheet}=\left[\mathrm{fontstyle}="bold"\right],\mathrm{hyperedgestylesheet}=\left[\mathrm{shape}="wide rectangle",\mathrm{padding}=15,\mathrm{fontsize}=8\right],\mathrm{smalledgestylesheet}=\left[\mathrm{thickness}=2\right],\mathrm{bigedgestylesheet}=\left[\mathrm{thickness}=0,\mathrm{color}=\mathrm{gray}\right],\mathrm{=}\left(\mathrm{hyperedgelabels},s↦\mathrm{convert}\left(s,\mathrm{string}\right)\right)\right)$

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}{≔}{\mathbf{proc}}\left({s}{::}{\mathrm{set}}{,}{}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{stringlist}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{stringlist}}{≔}{\mathrm{map}}{}\left({\mathrm{String}}{,}\left[{\mathrm{op}}{}\left({s}\right)\right]\right){;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{return}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{StringTools}}{:-}{\mathrm{Join}}{}\left({\mathrm{stringlist}}{,}{"-"}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (6)
 > $G≔\mathrm{Draw}\left(K,\mathrm{hyperedgelabels}=f,\mathrm{output}=\mathrm{graph}\right)$
 ${G}{≔}{\mathrm{Graph 1: an undirected graph with 5 vertices and 6 edge\left(s\right)}}$ (7)

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).

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $\mathrm{StyleEdge}\left(G,\left\{1,"1-2-3"\right\},\left[\mathrm{color}=\mathrm{green}\right]\right)$
 > $\mathrm{DrawGraph}\left(G\right)$

References

 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.

Compatibility

 • The Hypergraphs[Draw] command was introduced in Maple 2024.