Skip to main content

diameter_vulnerability

Function diameter_vulnerability 

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

Compute the diameter vulnerability.

For each vertex v, compute the diameter of G - v (graph with v removed). The vulnerability is the maximum increase in diameter over all removals, normalized by the original diameter. Returns 0.0 for disconnected, trivial graphs, or graphs with zero diameter.

§Examples

use rust_igraph::{Graph, diameter_vulnerability};

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