Skip to main content

is_multiple

Function is_multiple 

Source
pub fn is_multiple(graph: &Graph) -> IgraphResult<Vec<bool>>
Expand description

Returns a per-edge boolean vector marking multiple (parallel) edges.

result[e] == true iff there is another edge with the same canonical endpoint pair and a smaller edge id. Per upstream igraph_is_multiple()’s contract (loops.c:230): the result is true “only for the second or more appearances” — the canonical/first occurrence stays false, parallel copies after it are true.

O(|E| log |E|) via sort by canonical pair (within each pair group we keep edges in their natural id order, so the first id stays false).

§Examples

use rust_igraph::{Graph, is_multiple};

let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
// Edge 0 is the canonical (0,1); edge 1 is the duplicate.
assert_eq!(is_multiple(&g).unwrap(), vec![false, true, false]);