Skip to main content

is_well_covered

Function is_well_covered 

Source
pub fn is_well_covered(graph: &Graph) -> IgraphResult<bool>
Expand description

Check whether a graph is well-covered.

A graph is well-covered if all maximal independent sets have the same cardinality. Uses backtracking enumeration of maximal independent sets.

Directed graphs are treated as undirected.

§Examples

use rust_igraph::{Graph, is_well_covered};

// Complete graph `K_3`: only maximal IS is any single vertex → well-covered
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 0).unwrap();
assert!(is_well_covered(&g).unwrap());

// Star `S_3` is NOT well-covered ({0} size 1, {1,2,3} size 3)
let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(0, 2).unwrap();
g.add_edge(0, 3).unwrap();
assert!(!is_well_covered(&g).unwrap());