Skip to main content

bridge_ratio

Function bridge_ratio 

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

Compute the bridge ratio of the graph.

Fraction of edges that are bridges (whose removal disconnects the graph). Uses Tarjan’s bridge-finding algorithm with DFS. Returns 0.0 for graphs with no edges.

§Examples

use rust_igraph::{Graph, bridge_ratio};

// Path 0-1-2: both edges are bridges → 1.0
let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
assert!((bridge_ratio(&g).unwrap() - 1.0).abs() < 1e-10);