Skip to main content

union_many

Function union_many 

Source
pub fn union_many(graphs: &[&Graph]) -> IgraphResult<Graph>
Expand description

Returns the union of multiple graphs.

Generalises union to an arbitrary number of inputs. The result has max(g.vcount() for g in graphs) vertices. For each endpoint pair (u, v), the multiplicity in the result equals the maximum over all input graphs.

If graphs is empty, returns an empty directed graph (matching igraph C convention). All inputs must agree on directedness.

§Errors

§Examples

use rust_igraph::{Graph, union_many};

let mut a = Graph::with_vertices(3);
a.add_edge(0, 1).unwrap();
let mut b = Graph::with_vertices(4);
b.add_edge(1, 2).unwrap();
let mut c = Graph::with_vertices(2);
c.add_edge(0, 1).unwrap();

let u = union_many(&[&a, &b, &c]).unwrap();
assert_eq!(u.vcount(), 4);
assert_eq!(u.ecount(), 2); // (0,1) and (1,2)