pub fn subisomorphic_vf2(
graph1: &Graph,
graph2: &Graph,
vertex_color1: Option<&[u32]>,
vertex_color2: Option<&[u32]>,
edge_color1: Option<&[u32]>,
edge_color2: Option<&[u32]>,
) -> IgraphResult<Vf2Subisomorphism>Expand description
Test whether the pattern graph2 is a (non-induced) subgraph of the target
graph1, using the VF2 algorithm.
Optional vertex_color* / edge_color* slices restrict the matching: a
pattern vertex (edge) may map onto a target vertex (edge) only if their
colours are equal. Pass None for uncoloured graphs; supplying a colour for
only one side makes that colour be ignored (matching upstream).
On success Vf2Subisomorphism::iso tells whether an embedding exists; when
it does, map21 holds the embedding (pattern → target) and map12 its
reverse view, otherwise both are empty.
§Errors
Returns IgraphError::InvalidArgument if the two graphs differ in
directedness, if either contains a self-loop (VF2 does not support loops),
or if a supplied colour vector has the wrong length.
§Examples
use rust_igraph::{Graph, subisomorphic_vf2};
// A triangle (pattern) sits inside K4 (target).
let mut k4 = Graph::new(4, false).unwrap();
for i in 0..4u32 {
for j in (i + 1)..4 {
k4.add_edge(i, j).unwrap();
}
}
let mut tri = Graph::new(3, false).unwrap();
tri.add_edge(0, 1).unwrap();
tri.add_edge(1, 2).unwrap();
tri.add_edge(2, 0).unwrap();
let r = subisomorphic_vf2(&k4, &tri, None, None, None, None).unwrap();
assert!(r.iso);
assert_eq!(r.map21.len(), 3);