pub fn kirchhoff_index_ratio(graph: &Graph) -> IgraphResult<f64>Expand description
Compute the Kirchhoff index ratio.
The Kirchhoff index Kf(G) is the sum of effective resistances over all
vertex pairs. For a connected graph, we normalize by the number of pairs
times the diameter: Kf / (pairs * diameter). Values near 1 indicate
a tree-like resistance structure; lower values indicate more redundant
paths. Returns 0.0 for disconnected or trivial graphs.
We approximate the Kirchhoff index using BFS distances: for connected
graphs, resistance(u,v) >= dist(u,v)/max_degree and
resistance(u,v) <= dist(u,v). We use the sum of distances divided
by pairs*diameter as a proxy (the Wiener index ratio).
§Examples
use rust_igraph::{Graph, kirchhoff_index_ratio};
// Path graph 0-1-2-3: tree, sum of distances = 1+2+3+1+2+1 = 10
// pairs=6, diameter=3, ratio = 10/(6*3) = 10/18 ≈ 0.556
let g = Graph::from_edges(&[(0,1),(1,2),(2,3)], false, Some(4)).unwrap();
let r = kirchhoff_index_ratio(&g).unwrap();
assert!(r > 0.5 && r < 0.6);