pub fn layer_ratio(graph: &Graph) -> IgraphResult<f64>Expand description
Compute the layer ratio.
BFS from the highest-degree vertex; measures how concentrated the graph is around a hub. Returns the ratio of the actual average layer depth to the maximum possible depth (n-1, for a path). Values near 0 indicate a flat structure (star-like, all vertices near the hub); values near 1 indicate a deep, chain-like structure. Returns 0.0 for trivial or disconnected graphs.
ยงExamples
use rust_igraph::{Graph, layer_ratio};
// Star graph: all leaves at layer 1, avg_depth = 1, max = n-1 = 4
// ratio = 1/4 = 0.25
let g = Graph::from_edges(
&[(0,1),(0,2),(0,3),(0,4)], false, Some(5)
).unwrap();
let r = layer_ratio(&g).unwrap();
assert!(r > 0.2 && r < 0.3);