#graph #graph-algorithms #petgraph #canonical #trace #nauty #vertex

nauty-pet

使用 nauty/Traces 和 petgraph 进行图规范标签

18 个版本 (11 个重大更新)

0.12.1 2024年4月11日
0.12.0 2023年7月21日
0.11.1 2023年6月26日
0.8.0 2022年9月26日
0.1.1 2022年2月11日

#284 in 数学

Download history 4/week @ 2024-05-18 1/week @ 2024-05-25 1/week @ 2024-06-08 135/week @ 2024-07-27

每月 135 次下载
2 crates 中使用

Apache-2.0

68KB
2K SLoC

nauty-pet

图规范标签。

利用 nauty 和 Traces 找到 规范标签图自同构,用于 petgraph 图。

示例

use petgraph::graph::UnGraph;
use nauty_pet::prelude::*;

// Two different vertex labellings for the tree graph with two edges
let g1 = UnGraph::<(), ()>::from_edges([(0, 1), (1, 2)]);
let g2 = UnGraph::<(), ()>::from_edges([(0, 1), (0, 2)]);

// The canonical forms are identical
let c1 = g1.clone().into_canon();
let c2 = g2.clone().into_canon();
assert!(c1.is_identical(&c2));

// Alternatively, we can use a dedicated `struct` for canonically
// labelled graphs
let c1 = CanonGraph::from(g1.clone());
let c2 = CanonGraph::from(g2);
assert_eq!(c1, c2);

// `g1` is invariant under the permutation 0 -> 2, 1 -> 1, 2 -> 0.
// we encode it as the vector `[2, 1, 0]`
let automorphisms = g1.try_into_autom_group().unwrap();
assert!(automorphisms.contains(&vec![2, 1, 0]));

特性

  • serde-1: 使用 serde 使 CanonGraph 对象可序列化。

  • stable: 当节点或边权重可区分但相等时,确保确定性行为。

要启用特性 feature1feature2,请将以下内容添加到您的 Cargo.toml 中

[dependencies]
nauty-pet = { version = "0.8", features = ["feature1", "feature2"] }

许可证:Apache-2.0

依赖项

~4.5–7MB
~130K SLoC