Skip to main content

average_path_resilience

Function average_path_resilience 

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

Compute the average path resilience.

Measures how much the diameter increases when the highest-degree vertex is removed. Specifically: 1 - (new_diameter - old_diameter) / n where new_diameter is the diameter of the graph after removing the vertex with highest degree (ties broken by lowest index). Values near 1 indicate removing the hub has little effect; values near 0 indicate the hub is critical. Returns 0.0 for trivial graphs or if removal disconnects the graph.

§Examples

use rust_igraph::{Graph, average_path_resilience};

// K_4: removing any vertex leaves K_3 (diameter 1 → 1), resilience = 1 - 0/4 = 1.0
let g = Graph::from_edges(
    &[(0,1),(0,2),(0,3),(1,2),(1,3),(2,3)], false, Some(4)
).unwrap();
assert!((average_path_resilience(&g).unwrap() - 1.0).abs() < 1e-10);