Skip to main content

is_weakly_chordal

Function is_weakly_chordal 

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

Check whether a graph is weakly chordal.

A graph is weakly chordal if neither G nor its complement has an induced cycle of length ≥ 5. Uses chordality checks on both G and its complement; if both are chordal, G is weakly chordal. Otherwise, checks for induced C_k (k ≥ 5) in the non-chordal graph(s).

Directed graphs are treated as undirected.

§Examples

use rust_igraph::{Graph, is_weakly_chordal};

// `K_4`: chordal → weakly chordal
let mut g = Graph::with_vertices(4);
for i in 0..4u32 {
    for j in (i+1)..4 {
        g.add_edge(i, j).unwrap();
    }
}
assert!(is_weakly_chordal(&g).unwrap());

// `C_5` is NOT weakly chordal (is its own induced C_5)
let mut g = Graph::with_vertices(5);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
g.add_edge(3, 4).unwrap();
g.add_edge(4, 0).unwrap();
assert!(!is_weakly_chordal(&g).unwrap());