pub fn diameter_ratio(graph: &Graph) -> IgraphResult<f64>Expand description
Compute the diameter ratio.
diameter / (n - 1) — the diameter normalized by the maximum
possible diameter (a path graph). Values near 1 indicate the graph
is elongated; values near 0 indicate short diameters (e.g. complete
graphs). Returns 0.0 for disconnected or trivial graphs.
§Examples
use rust_igraph::{Graph, diameter_ratio};
// Path 0-1-2-3: diameter=3, n=4 → 3/3 = 1.0
let g = Graph::from_edges(&[(0,1),(1,2),(2,3)], false, Some(4)).unwrap();
assert!((diameter_ratio(&g).unwrap() - 1.0).abs() < 1e-10);