inverse_line_graph#
- graph_tool.generation.inverse_line_graph(g)[git][source]#
Return the root graph of a line graph.
- Parameters:
- g
Graph Undirected line graph, without self-loops or parallel edges.
- g
- Returns:
See also
line_graphLine 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
ValueErroris raised ifgis 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