Skip to main content

is_co_chordal

Function is_co_chordal 

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

Check whether a graph is co-chordal (complement is chordal).

Builds the complement graph and runs the chordality test on it.

Directed graphs are treated as undirected.

ยงExamples

use rust_igraph::{Graph, is_co_chordal};

// `K_5`: complement is edgeless (chordal) โ†’ co-chordal
let mut g = Graph::with_vertices(5);
for i in 0..5u32 {
    for j in (i+1)..5 {
        g.add_edge(i, j).unwrap();
    }
}
assert!(is_co_chordal(&g).unwrap());

// `C_5`: complement is also `C_5` โ†’ not chordal โ†’ not co-chordal
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_co_chordal(&g).unwrap());