pub fn complementer(graph: &Graph, loops: bool) -> IgraphResult<Graph>Expand description
Returns the complementer of graph.
If loops == true, self-loops (v, v) are added for every vertex
that does not already have one. If loops == false, no self-loops
appear in the output regardless of the input.
The output’s vertex count equals the input’s; the output’s edge
count is n*(n-1) − ecount (directed) or n*(n-1)/2 − ecount
(undirected) when loops == false, plus n extra slots if
loops == true for self-loops not in the input.
§Examples
use rust_igraph::{Graph, complementer};
// Path 0-1-2 → complementer is the single edge (0, 2).
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
let c = complementer(&g, false).unwrap();
assert_eq!(c.ecount(), 1);
assert_eq!(c.edge(0).unwrap(), (0, 2));