pub fn graph_compactness(graph: &Graph) -> IgraphResult<f64>Expand description
Compute the compactness of the graph.
1 - avg_dist / diameter — how compact the graph is relative to
its diameter. A value of 0 means the average distance equals the
diameter; close to 1 means most pairs are much closer than the
diameter. Returns 0.0 for disconnected or trivial graphs.
§Examples
use rust_igraph::{Graph, graph_compactness};
// K_3: avg=1, diam=1 → 1-1/1 = 0.0
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!(graph_compactness(&g).unwrap().abs() < 1e-10);