1个不稳定版本

0.1.0 2023年1月13日

#1456数学

Download history · Rust 包仓库 651/week @ 2024-03-14 · Rust 包仓库 1041/week @ 2024-03-21 · Rust 包仓库 859/week @ 2024-03-28 · Rust 包仓库 645/week @ 2024-04-04 · Rust 包仓库 786/week @ 2024-04-11 · Rust 包仓库 852/week @ 2024-04-18 · Rust 包仓库 818/week @ 2024-04-25 · Rust 包仓库 849/week @ 2024-05-02 · Rust 包仓库 1015/week @ 2024-05-09 · Rust 包仓库 912/week @ 2024-05-16 · Rust 包仓库 908/week @ 2024-05-23 · Rust 包仓库 965/week @ 2024-05-30 · Rust 包仓库 1166/week @ 2024-06-06 · Rust 包仓库 1207/week @ 2024-06-13 · Rust 包仓库 1049/week @ 2024-06-20 · Rust 包仓库 1181/week @ 2024-06-27 · Rust 包仓库

4,814 每月下载量
25 个crate中使用了(2个直接使用)

MIT/Apache

10KB
144

graph-cycles

找到图中的所有循环

Johnson算法寻找图中所有循环的原始实现。基于petgraph

示例

三角形图恰好有一个循环,即完全图本身。

use graph_cycles::Cycles;
use petgraph::graph::Graph;

let g = Graph::<(), ()>::from_edges([(0, 1), (1, 2), (2, 0)]);

// find all cycles
let cycles = g.cycles();
assert_eq!(cycles.len(), 1);
assert_eq!(cycles[0].len(), 3);

// print each cycle in turn
g.visit_all_cycles(|_g, c| {
   println!("Found new cycle with vertices {c:?}");
});

注意事项

此crate基本上未经测试。

参考文献

Donald B. Johnson, Finding all the elementary circuits of a directed graph, SIAM Journal on Computing, 1975.

许可证:MIT或Apache-2.0


lib.rs:

找到图中的所有循环

Johnson算法寻找图中所有循环的原始实现。基于petgraph

示例

三角形图恰好有一个循环,即完全图本身。

use graph_cycles::Cycles;
use petgraph::graph::Graph;

let g = Graph::<(), ()>::from_edges([(0, 1), (1, 2), (2, 0)]);

// find all cycles
let cycles = g.cycles();
assert_eq!(cycles.len(), 1);
assert_eq!(cycles[0].len(), 3);

// print each cycle in turn
g.visit_all_cycles(|_g, c| {
   println!("Found new cycle with vertices {c:?}");
});

注意事项

此crate基本上未经测试。

参考文献

Donald B. Johnson, Finding all the elementary circuits of a directed graph, SIAM Journal on Computing, 1975.

底层图的节点标识符

依赖

~3.5MB
~59K SLoC