pub fn energy_ratio(graph: &Graph) -> IgraphResult<f64>Expand description
Compute the energy ratio.
energy / (n × sqrt(2m/n)) where energy = Σ|λᵢ| is the graph energy
and the denominator is the expected energy of an Erdős–Rényi random
graph with the same density. Values > 1 indicate the graph is more
“energetic” than a random graph of the same density. Returns 0.0 for
edgeless or trivial graphs.
§Examples
use rust_igraph::{Graph, energy_ratio};
// K_3: eigenvalues {2,-1,-1}, energy=4, m=3, n=3
// baseline = 3*sqrt(2*3/3) = 3*sqrt(2) ≈ 4.243
// ratio ≈ 4/4.243 ≈ 0.943
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
let r = energy_ratio(&g).unwrap();
assert!(r > 0.5 && r < 1.5);