Skip to main content

merrifield_simmons_index

Function merrifield_simmons_index 

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

Compute the Merrifield–Simmons index of a graph.

Returns the total number of independent sets (including the empty set). For a graph with no edges, σ(G) = 2^n.

Only feasible for small graphs — the count can be exponential.

§Examples

use rust_igraph::{Graph, merrifield_simmons_index};

// Path 0-1-2: independent sets: {}, {0}, {1}, {2}, {0,2} → σ = 5
let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
assert_eq!(merrifield_simmons_index(&g).unwrap(), 5);