NetworkX

Previous topic

networkx.generators.bipartite.bipartite_random_graph

Next topic

networkx.generators.ego.ego_graph

networkx.generators.line.line_graph

networkx.generators.line.line_graph(G)

Return the line graph of the graph or digraph G.

The line graph of a graph G has a node for each edge in G and an edge between those nodes if the two edges in G share a common node.

For DiGraphs an edge an edge represents a directed path of length 2.

The original node labels are kept as two-tuple node labels in the line graph.

Parameters :

G : graph

A NetworkX Graph or DiGraph

Notes

Not implemented for MultiGraph or MultiDiGraph classes.

Graph, node, and edge data are not propagated to the new graph.

Examples

>>> G=nx.star_graph(3)
>>> L=nx.line_graph(G)
>>> print(sorted(L.edges())) # makes a clique, K3
[((0, 1), (0, 2)), ((0, 1), (0, 3)), ((0, 3), (0, 2))]