Wolfram Research

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

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]=

Resource History

License Information