pub struct Vf2Options<'a> {
pub vertex_color1: Option<&'a [i64]>,
pub vertex_color2: Option<&'a [i64]>,
pub edge_color1: Option<&'a [i64]>,
pub edge_color2: Option<&'a [i64]>,
/* private fields */
}Expand description
Options of the VF2 functions: vertex and edge colors, and custom compatibility predicates.
- With vertex colors, a vertex may only be matched to a vertex of the same color; with edge colors, an edge only to an edge of the same color. Colors are given for both graphs at once (igraph ignores the colors, with a warning, when only one graph is colored).
- A node (edge) compatibility closure is called every time VF2 tries
to match vertex (edge)
iof the first graph with vertex (edge)jof the second, and can veto the match by returningfalse. If a closure panics, the search is aborted and the panic is resumed when the wrapper returns.
Build it with the builder methods and pass it as &mut, so that it
(and its closures) can be reused:
use igraph::prelude::*;
use igraph::isomorphism::Vf2Options;
let path = Graph::from_edges(&[(0, 1), (1, 2)], 3, false).unwrap();
// Colors pin the middle vertex: only the reflection 0 <-> 2 survives.
let colors = [0, 1, 0];
let mut opts = Vf2Options::new().with_vertex_colors(&colors, &colors);
assert_eq!(path.count_isomorphisms_vf2(&path, &mut opts).unwrap(), 2);
// A predicate forbidding fixed points leaves only the reflection.
let mut opts = Vf2Options::new().with_node_compat(|i, j| i != j || i == 1);
assert_eq!(path.get_isomorphisms_vf2(&path, &mut opts).unwrap(), vec![vec![2, 1, 0]]);Fields§
§vertex_color1: Option<&'a [i64]>Vertex colors of the first graph.
vertex_color2: Option<&'a [i64]>Vertex colors of the second graph.
edge_color1: Option<&'a [i64]>Edge colors of the first graph.
edge_color2: Option<&'a [i64]>Edge colors of the second graph.
Implementations§
Source§impl<'a> Vf2Options<'a>
impl<'a> Vf2Options<'a>
Sourcepub fn with_vertex_colors(self, color1: &'a [i64], color2: &'a [i64]) -> Self
pub fn with_vertex_colors(self, color1: &'a [i64], color2: &'a [i64]) -> Self
Sets the vertex colors of the first and second graph.
Sourcepub fn with_edge_colors(self, color1: &'a [i64], color2: &'a [i64]) -> Self
pub fn with_edge_colors(self, color1: &'a [i64], color2: &'a [i64]) -> Self
Sets the edge colors of the first and second graph.
Sourcepub fn with_node_compat(
self,
f: impl FnMut(VertexId, VertexId) -> bool + 'a,
) -> Self
pub fn with_node_compat( self, f: impl FnMut(VertexId, VertexId) -> bool + 'a, ) -> Self
Sets the vertex compatibility predicate f(v1, v2), where v1 is a
vertex of the first graph and v2 one of the second graph.
Sourcepub fn with_edge_compat(self, f: impl FnMut(i64, i64) -> bool + 'a) -> Self
pub fn with_edge_compat(self, f: impl FnMut(i64, i64) -> bool + 'a) -> Self
Sets the edge compatibility predicate f(e1, e2), where e1 is an
edge of the first graph and e2 one of the second graph.
Sourcepub fn vertex_colors(self, color1: &'a [i64], color2: &'a [i64]) -> Self
👎Deprecated: use with_vertex_colors
pub fn vertex_colors(self, color1: &'a [i64], color2: &'a [i64]) -> Self
use with_vertex_colors
Sets the vertex colors; use
with_vertex_colors instead.
Sourcepub fn edge_colors(self, color1: &'a [i64], color2: &'a [i64]) -> Self
👎Deprecated: use with_edge_colors
pub fn edge_colors(self, color1: &'a [i64], color2: &'a [i64]) -> Self
use with_edge_colors
Sets the edge colors; use
with_edge_colors instead.
Sourcepub fn node_compat(self, f: impl FnMut(VertexId, VertexId) -> bool + 'a) -> Self
👎Deprecated: use with_node_compat
pub fn node_compat(self, f: impl FnMut(VertexId, VertexId) -> bool + 'a) -> Self
use with_node_compat
Sets the vertex compatibility predicate; use
with_node_compat instead.
Sourcepub fn edge_compat(self, f: impl FnMut(i64, i64) -> bool + 'a) -> Self
👎Deprecated: use with_edge_compat
pub fn edge_compat(self, f: impl FnMut(i64, i64) -> bool + 'a) -> Self
use with_edge_compat
Sets the edge compatibility predicate; use
with_edge_compat instead.