pub fn join(left: &Graph, right: &Graph) -> IgraphResult<Graph>Expand description
Creates the join of two graphs.
The join first takes the disjoint union of left and right, then adds
all edges between the vertices originating from left and those from
right. This produces a graph with |V1| + |V2| vertices and
|E1| + |E2| + |V1|*|V2| edges (for undirected), or
|E1| + |E2| + 2*|V1|*|V2| edges (for directed, since both directions
are added).
Both graphs must have the same directedness.
§Arguments
left— the first graph.right— the second graph.
§Errors
Returns InvalidArgument if the graphs differ in directedness.
§Examples
use rust_igraph::{Graph, join};
let g1 = Graph::with_vertices(2); // 2 isolated vertices
let g2 = Graph::with_vertices(3); // 3 isolated vertices
let j = join(&g1, &g2).unwrap();
assert_eq!(j.vcount(), 5);
// 0 original edges + 2*3 = 6 cross-edges
assert_eq!(j.ecount(), 6);