Skip to main content

edge_surplus_ratio

Function edge_surplus_ratio 

Source
pub fn edge_surplus_ratio(graph: &Graph) -> IgraphResult<f64>
Expand description

Compute the edge surplus ratio.

ESR = (m - n + c) / (n·(n-1)/2 - n + c)

The fraction of the available “surplus” edge slots that are actually used, where the denominator is the maximum possible circuit rank (for a complete graph). Zero for forests, 1.0 for complete graphs. Returns 0.0 for graphs with fewer than 3 vertices or when the denominator is zero.

§Examples

use rust_igraph::{Graph, edge_surplus_ratio};

// K_3: circuit_rank=1, max_circuit_rank = 3-3+1 = 1 → ESR=1.0
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!((edge_surplus_ratio(&g).unwrap() - 1.0).abs() < 1e-10);