Skip to main content

intersection_many

Function intersection_many 

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

Returns the intersection of multiple graphs.

Generalises intersection 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 is the minimum over all input graphs (a pair only survives if it appears in every input).

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, intersection_many};

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

let i = intersection_many(&[&a, &b, &c]).unwrap();
assert_eq!(i.ecount(), 1); // only (0,1) is in all three