Skip to main content

is_matching

Function is_matching 

Source
pub fn is_matching(
    graph: &Graph,
    types: Option<&[bool]>,
    matching: &[Option<u32>],
) -> IgraphResult<bool>
Expand description

Check whether matching is a valid matching for graph.

A matching vector has length vcount; entry i is Some(j) when vertex i is matched to j, or None if unmatched. The function verifies:

  1. Length equals vcount.
  2. Matched pairs are mutual (matching[i] == Some(j)matching[j] == Some(i)).
  3. Every matched pair is connected by an edge (ignoring direction).
  4. If types is provided, matched vertices have different types.
use rust_igraph::{create, is_matching};

let g = create(&[(0, 1), (1, 2)], 3, false).unwrap();
let m = vec![Some(1), Some(0), None];
assert!(is_matching(&g, None, &m).unwrap());