pub fn frustration_ratio(graph: &Graph) -> IgraphResult<f64>Expand description
Compute the frustration ratio.
Fraction of edges that are “frustrated” (connect same-color vertices) under a BFS greedy 2-coloring. For bipartite graphs this is 0.0; for complete graphs on n≥3 vertices it is positive. Returns 0.0 for graphs with no edges.
§Examples
use rust_igraph::{Graph, frustration_ratio};
// K_3: BFS colors 0→A, 1→B, 2→B; edge (1,2) frustrated → 1/3
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!((frustration_ratio(&g).unwrap() - 1.0/3.0).abs() < 1e-10);