build_line_graph

build_line_graph(graph)[source]

Return the line graph of the given graph.

The line graph contains a node for each edge in the original graph. The node’s label is the original graph’s edge. Nodes in the line graph are connected by an (unlabeled) edge if the original edges share a node in the original graph.

Example: if the original graph has four nodes and edges [0, 1], [1, 2], [2, 3] then the line graph has three nodes labeled [0, 1], [1, 2], [2, 3] and two edges: between the nodes labeled [0, 1] and the node labeled [1, 2]; and between the node labeled [1, 2] and the node labeled [2, 3].

Parameters:

graph (PyGraph) – A rustworkx.PyGraph instance

Returns:

The line graph

Return type:

PyGraph