Skip to main content

is_co_bipartite

Function is_co_bipartite 

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

Check whether a graph is co-bipartite.

A co-bipartite graph’s vertex set can be partitioned into two cliques. This is equivalent to the complement being bipartite.

Returns false for directed graphs.

§Examples

use rust_igraph::{Graph, is_co_bipartite};

// `K_3`: single clique → co-bipartite (other part empty)
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_co_bipartite(&g).unwrap());

// `C_5` is NOT co-bipartite (complement `C_5` is not bipartite)
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_bipartite(&g).unwrap());