pub fn spanning_tree_ratio(graph: &Graph) -> IgraphResult<f64>Expand description
Compute the spanning tree ratio.
Uses Kirchhoff’s matrix-tree theorem: the number of spanning trees τ(G)
equals (1/n) * product of non-zero Laplacian eigenvalues. We compute
log(τ) / ((n-1) * log(n)) as a normalized measure. Values near 1
indicate a graph rich in spanning trees (complete-graph-like); values
near 0 indicate few spanning trees (tree-like). Returns 0.0 for
disconnected or trivial graphs.
§Examples
use rust_igraph::{Graph, spanning_tree_ratio};
// K_3: τ = 3, log(3)/((3-1)*log(3)) = 1/(2) = 0.5
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
let r = spanning_tree_ratio(&g).unwrap();
assert!(r > 0.45 && r < 0.55);