pub fn linegraph(graph: &Graph) -> IgraphResult<Graph>Expand description
Build the line graph L(G) of graph.
L(G) has one vertex for every edge of graph (edge id e maps to
L-vertex id e). For an undirected input two L-vertices are
connected by one L-edge per shared endpoint between their G-edges
(so multigraphs and self-loops behave per the upstream docstring).
For a directed input an L-arc e → e1 exists exactly when the target
of e equals the source of e1. The result inherits graph’s
directedness.
§Errors
Propagates errors from Graph::new / Graph::add_edges; the
algorithm itself does not introduce new failure modes.
§Examples
use rust_igraph::{Graph, linegraph};
// L of the path P_4 (edges e0=(0,1), e1=(1,2), e2=(2,3)) is the path
// P_3 on the three L-vertices 0, 1, 2.
let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
let l = linegraph(&g).unwrap();
assert_eq!(l.vcount(), 3);
assert_eq!(l.ecount(), 2);
assert!(!l.is_directed());