Skip to main content

is_chordal_bipartite

Function is_chordal_bipartite 

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

Check whether a graph is chordal bipartite.

A bipartite graph is chordal bipartite if it has no induced cycle of length ≥ 6. Returns false for non-bipartite or directed graphs.

Uses a perfect elimination ordering (PEO) approach on the bipartite adjacency: repeatedly finds a vertex whose neighborhood forms a “bisimplicial” structure and removes it.

§Examples

use rust_igraph::{Graph, is_chordal_bipartite};

// Complete bipartite `K_{2,3}` is chordal bipartite
let mut g = Graph::with_vertices(5);
g.add_edge(0, 2).unwrap();
g.add_edge(0, 3).unwrap();
g.add_edge(0, 4).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(1, 3).unwrap();
g.add_edge(1, 4).unwrap();
assert!(is_chordal_bipartite(&g).unwrap());

// `C_6` is bipartite but NOT chordal bipartite
let mut g = Graph::with_vertices(6);
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, 5).unwrap();
g.add_edge(5, 0).unwrap();
assert!(!is_chordal_bipartite(&g).unwrap());