Wolfram Research

Function Repository Resource:

HypergraphPlot

Source Notebook

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

Contributed by: Daniel McDonald

ResourceFunction["HypergraphPlot"][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

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[
 "HypergraphPlot"][{{a, b, c, d}, {b, c}, {c, d, e}, f, g}]
Out[1]=

Applications

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["HypergraphPlot"][rh]
Out[4]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Resource History

See Also

License Information