biconnected-components

Crates.iobiconnected-components
lib.rsbiconnected-components
version0.5.0
created_at2023-07-20 09:25:35.04192+00
updated_at2025-12-22 06:26:32.834652+00
descriptionFind biconnected components in a graph
homepage
repositoryhttps://github.com/a-maier/biconnected-components
max_upload_size
id921170
size14,894
(a-maier)

documentation

README

biconnected-components

Compute the biconnected components of a graph.

Example

use petgraph::graph::UnGraph;
use biconnected_components::{Bcc, SplitIntoBcc};

// construct a simple graph
let g = UnGraph::<(), ()>::from_edges([
   (0, 1),
   (1, 2)
 ]);

// Get a vector of the biconnected components defined by their node indices
let bcc = g.bcc();
assert_eq!(bcc.len(), 2);
for bcc_nodes in bcc {
   println!("Found biconnected component with nodes {bcc_nodes:?}");
}

// Split up the graph into its biconnected components, that is
// two identical graphs with two nodes connected by a single edge
let bcc = g.split_into_bcc();
assert_eq!(bcc.len(), 2);
assert!(bcc.iter().all(|g| g.node_count() == 2));
assert!(bcc.iter().all(|g| g.edge_count() == 1));

License: MIT OR Apache-2.0

Commit count: 24

cargo fmt