3 个版本 (破坏性)

0.3.0 2024 年 4 月 3 日
0.2.0 2024 年 3 月 22 日
0.1.0 2023 年 7 月 20 日

数学 类别中排名 1060

Download history

每月下载 132
用于 dynast

MIT/Apache 许可

14KB
302 行代码(不含注释)

biconnected-components

计算图的二连通分量。

示例

use petgraph::graph::UnGraph;
use biconnected_components::Bcc;

// 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:?}");
}

许可证:MIT OR Apache-2.0


lib.rs:

计算图的二连通分量。

示例

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 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));

依赖项

~2MB
~29K SLoC