Function Repository Resource:

SimpleHypergraphPlot

Source Notebook

Plot a hypergraph defined by a list of hyperedges and isolated vertices

Contributed by: Daniel McDonald

ResourceFunction["SimpleHypergraphPlot"][list]

plots the hypergraph defined by list.

Details and Options

The hypergraph represented by {{v11,v12,},{v21,v22,},,u1,u2,} has vertices v11,v12,,v21,v22,,,u1,u2, and hyperedges {v11,v12,},{v21,v22,},.

Examples

Basic Examples (1) 

Plot the hypergraph having vertices a, b, c, d, e, f, g and hyperedges {a,b,c,d}, {b,c}, {c,d,e}:

In[1]:=
ResourceFunction[
 "SimpleHypergraphPlot"][{{a, b, c, d}, {b, c}, {c, d, e}, f, g}]
Out[1]=

Applications (2) 

Define a random hypergraph having n vertices and m hyperedges:

In[2]:=
RandomHypergraph[n_, m_] := With[{edges = Apply[Join, Map[Function[pos, Subsets[Range[n], {1, n}, {pos}]], RandomInteger[{1, 2^n - 1}, m]]]}, Join[edges, Complement[Range[n], Flatten[edges]]]]
rh = RandomHypergraph[15, 3]
Out[3]=

Plot it:

In[4]:=
ResourceFunction["SimpleHypergraphPlot"][rh]
Out[4]=

Version History

  • 1.0.0 – 15 November 2019

Related Resources

Author Notes

This function was originally published under the name HypergraphPlot.

License Information