Skip to main content

avg_path_fraction

Function avg_path_fraction 

Source
pub fn avg_path_fraction(graph: &Graph) -> IgraphResult<f64>
Expand description

Compute the average path fraction.

avg_dist / diameter — how close the average shortest-path length is to the diameter. Values close to 1 indicate most paths are near the diameter; values close to 0 indicate most paths are short. Returns 0.0 for disconnected or trivial graphs.

§Examples

use rust_igraph::{Graph, avg_path_fraction};

// K_3: avg_dist=1, diameter=1 → 1.0
let g = Graph::from_edges(&[(0,1),(1,2),(0,2)], false, Some(3)).unwrap();
assert!((avg_path_fraction(&g).unwrap() - 1.0).abs() < 1e-10);