inverse_line_graph

inverse_line_graph#

graph_tool.generation.inverse_line_graph(g)[git][source]#

Return the root graph of a line graph.

Parameters:
gGraph

Undirected line graph, without self-loops or parallel edges.

Returns:
hGraph

The undirected root graph \(H\), with \(L(H) \cong G\), where edge \(i\) (in the order of edges()) corresponds to the \(i\)-th vertex of g.

See also

line_graph

Line graph

Notes

The root graph is found with the algorithm of Roussopoulos [roussopoulos-algorithm-1973], applied to every connected component: the edges are partitioned into cliques such that every vertex belongs to at most two of them, starting from a clique around an edge that is chosen by inspecting the (odd) triangles containing it, which resolves the ambiguity between triangles and stars. The cliques, together with the vertices that belong to a single one, are the vertices of \(H\), and every vertex of \(G\) becomes the edge between the two cells that contain it; isolated vertices become isolated edges. By Whitney’s theorem, \(H\) is unique up to isomorphism for connected graphs, except for the triangle, which is the line graph of both the triangle and the star \(K_{1,3}\) (the latter is returned). A ValueError is raised if g is not a line graph. The algorithm runs in time \(O(N + E\Delta)\), for maximum degree \(\Delta\).

References

[roussopoulos-algorithm-1973]

Nicholas D. Roussopoulos, “A max {m, n} algorithm for determining the graph H from its line graph G”, Information Processing Letters 2, 108-112 (1973), DOI: 10.1016/0020-0190(73)90029-X [sci-hub, @tor]

Examples

>>> g = gt.collection.data["karate"]
>>> h = gt.inverse_line_graph(gt.line_graph(g)[0])
>>> print(h.num_vertices(), h.num_edges(), gt.isomorphism(g, h))
34 78 True