NetworkX

Previous topic

networkx.symmetric_difference

Next topic

networkx.ego_graph

networkx.line_graph

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.

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