networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturns
inverse_line_graph(G)

If H is a graph, and G is the line graph of H, such that G = L(H). Then H is the inverse line graph of G.

Not all graphs are line graphs and these do not have an inverse line graph. In these cases this function raises a NetworkXError.

Notes

This is an implementation of the Roussopoulos algorithm.

If G consists of multiple components, then the algorithm doesn't work. You should invert every component seperately:

>>> K5 = nx.complete_graph(5)
>>> P4 = nx.Graph([("a", "b"), ("b", "c"), ("c", "d")])
>>> G = nx.union(K5, P4)
>>> root_graphs = []
>>> for comp in nx.connected_components(G):
...     root_graphs.append(nx.inverse_line_graph(G.subgraph(comp)))
>>> len(root_graphs)
2

Parameters

G : graph

A NetworkX Graph

Raises

NetworkXNotImplemented

If G is directed or a multigraph

NetworkXError

If G is not a line graph

Returns

H : graph

The inverse line graph of G.

Returns the inverse line graph of graph G.

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/generators/line.py#203
type: <class 'function'>
Commit: