pub fn bipartiteness_ratio(graph: &Graph) -> IgraphResult<f64>Expand description
Compute the bipartiteness ratio (2 - μ_n) / 2.
For bipartite graphs μ_n = 2, so the ratio is 0. For
non-bipartite graphs μ_n < 2, giving a positive value that
measures how far the graph is from being bipartite.
Returns 1.0 for graphs with μ_n = 0 (isolated vertices only).
§Examples
use rust_igraph::{Graph, bipartiteness_ratio};
// K_{2,2} (bipartite): ratio = 0
let g = Graph::from_edges(&[(0,2),(0,3),(1,2),(1,3)], false, Some(4)).unwrap();
let br = bipartiteness_ratio(&g).unwrap();
assert!(br.abs() < 0.01);
// K_3 (non-bipartite): μ_n = 3/2, ratio = (2 - 3/2)/2 = 1/4
let k3 = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
let br3 = bipartiteness_ratio(&k3).unwrap();
assert!((br3 - 0.25).abs() < 0.05);