Function Repository Resource:

HypergraphToGraph

Source Notebook

Convert a hypergraph to a graph with the same distance matrix

Contributed by: Stephen Wolfram

ResourceFunction["HypergraphToGraph"][hg]

converts the ordered hypergraph hg to a directed graph with the same distance matrix.

Details and Options

The hypergraph should be given as a list of lists, with one sublist for each hyperedge.
ResourceFunction["HypergraphToGraph"] takes the same options as Graph.

Examples

Basic Examples (2) 

Convert a simple hypergraph to a graph:

In[1]:=
ResourceFunction["HypergraphToGraph"][{{1, 3, 2}, {2, 1, 3}}]
Out[1]=

Find the edge list of the resulting graph:

In[2]:=
EdgeList[%]
Out[2]=

Define a more complex hypergraph:

In[3]:=
hg = {{1, 4, 2}, {1, 5, 4}, {5, 2, 4}, {1, 6, 3}, {2, 7, 6}, {7, 3, 6}, {3, 8, 1}, {2, 9, 8}, {9, 1, 8}};

Find the equivalent graph:

In[4]:=
ResourceFunction["HypergraphToGraph"][hg, VertexLabels -> Automatic]
Out[4]=

Version History

  • 2.0.0 – 16 March 2020
  • 1.0.0 – 04 December 2019

License Information