Skip to main content

Vf2Options

Struct Vf2Options 

Source
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) i of the first graph with vertex (edge) j of the second, and can veto the match by returning false. 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>

Source

pub fn new() -> Self

No colors and no compatibility predicates: plain (sub)isomorphism.

Source

pub fn with_vertex_colors(self, color1: &'a [i64], color2: &'a [i64]) -> Self

Sets the vertex colors of the first and second graph.

Source

pub fn with_edge_colors(self, color1: &'a [i64], color2: &'a [i64]) -> Self

Sets the edge colors of the first and second graph.

Source

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.

Source

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.

Source

pub fn vertex_colors(self, color1: &'a [i64], color2: &'a [i64]) -> Self

👎Deprecated:

use with_vertex_colors

Sets the vertex colors; use with_vertex_colors instead.

Source

pub fn edge_colors(self, color1: &'a [i64], color2: &'a [i64]) -> Self

👎Deprecated:

use with_edge_colors

Sets the edge colors; use with_edge_colors instead.

Source

pub fn node_compat(self, f: impl FnMut(VertexId, VertexId) -> bool + 'a) -> Self

👎Deprecated:

use with_node_compat

Sets the vertex compatibility predicate; use with_node_compat instead.

Source

pub fn edge_compat(self, f: impl FnMut(i64, i64) -> bool + 'a) -> Self

👎Deprecated:

use with_edge_compat

Sets the edge compatibility predicate; use with_edge_compat instead.

Trait Implementations§

Source§

impl Debug for Vf2Options<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for Vf2Options<'a>

Source§

fn default() -> Vf2Options<'a>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Vf2Options<'a>

§

impl<'a> !Send for Vf2Options<'a>

§

impl<'a> !Sync for Vf2Options<'a>

§

impl<'a> !UnwindSafe for Vf2Options<'a>

§

impl<'a> Freeze for Vf2Options<'a>

§

impl<'a> Unpin for Vf2Options<'a>

§

impl<'a> UnsafeUnpin for Vf2Options<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.