Function bridges

Source
pub fn bridges<G>(
    graph: G,
) -> HashSet<(<G as GraphBase>::NodeId, <G as GraphBase>::NodeId)>
Expand description

Return the bridges of an undirected graph.

Bridges are edges that, if removed, would increase the number of connected components of a graph.

§Note

The function implicitly assumes that there are no parallel edges or self loops. It may produce incorrect/unexpected results if the input graph has self loops or parallel edges.

§Example:

use std::iter::FromIterator;
use hashbrown::{HashMap, HashSet};

use rustworkx_core::connectivity::bridges;
use rustworkx_core::petgraph::graph::UnGraph;
use rustworkx_core::petgraph::graph::node_index as nx;

let graph = UnGraph::<(), ()>::from_edges(&[
   (0, 1), (0, 2), (1, 2), (1, 3),
]);

let bridges = bridges(&graph);

assert_eq!(bridges, HashSet::from_iter([(nx(1), nx(3))]));