pub fn line_graph(graph: &Graph) -> IgraphResult<Graph>Expand description
Construct the line graph L(G) of the input graph.
The line graph has one vertex for each edge of the original graph. Two vertices of L(G) are adjacent if and only if the corresponding edges in G share an endpoint.
For directed graphs, edge (u→v) is adjacent to edge (w→x) in the line graph iff v == w (the head of the first matches the tail of the second), matching igraph’s upstream convention.
Counterpart of igraph_linegraph().
§Examples
use rust_igraph::{Graph, line_graph};
// Triangle 0-1-2-0 has 3 edges; L(G) is also a triangle.
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 0).unwrap();
let lg = line_graph(&g).unwrap();
assert_eq!(lg.vcount(), 3);
assert_eq!(lg.ecount(), 3);use rust_igraph::{Graph, line_graph};
// Path 0-1-2 has 2 edges; L(G) is a single edge.
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
let lg = line_graph(&g).unwrap();
assert_eq!(lg.vcount(), 2);
assert_eq!(lg.ecount(), 1);