pub fn disjoint_union(left: &Graph, right: &Graph) -> IgraphResult<Graph>Expand description
Returns the disjoint union of left and right.
The result has left.vcount() + right.vcount() vertices and
left.ecount() + right.ecount() edges. Vertices from right are
shifted by left.vcount().
§Errors
IgraphError::InvalidArgumentif the two graphs differ in directedness — disjoint union is only defined for graphs of the same directedness.
§Examples
use rust_igraph::{Graph, disjoint_union};
// Two triangles → 6-vertex graph with two disjoint triangles.
let mut a = Graph::with_vertices(3);
a.add_edge(0, 1).unwrap();
a.add_edge(1, 2).unwrap();
a.add_edge(2, 0).unwrap();
let b = a.clone();
let u = disjoint_union(&a, &b).unwrap();
assert_eq!(u.vcount(), 6);
assert_eq!(u.ecount(), 6);
// The right triangle's edges are shifted by 3.
assert_eq!(u.edge(3).unwrap(), (3, 4));