Skip to main content

is_biregular

Function is_biregular 

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

Check whether a graph is biregular.

A bipartite graph is biregular if every vertex in the same partition has the same degree. Returns false for non-bipartite graphs.

Directed graphs are treated as undirected.

ยงExamples

use rust_igraph::{Graph, is_biregular};

// K_{2,3} is biregular: left vertices have degree 3, right have degree 2
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_biregular(&g).unwrap());

// Path P_4: bipartite but not biregular (degrees differ within a side)
let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();
assert!(!is_biregular(&g).unwrap());