Skip to main content

hosoya_index

Function hosoya_index 

Source
pub fn hosoya_index(graph: &Graph) -> IgraphResult<u64>
Expand description

Compute the Hosoya index (Z-index) of a graph.

The Hosoya index equals the total number of matchings (including the empty matching). For a graph with no edges, Z(G) = 1.

Only feasible for small/sparse graphs — the value grows exponentially.

§Examples

use rust_igraph::{Graph, hosoya_index};

// Path 0-1-2: matchings are {}, {01}, {12} → Z = 3
let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
assert_eq!(hosoya_index(&g).unwrap(), 3);