graph-canon
Super fast and barebones graph canonicalization using nauty C-lib
and built on petgraph.
Usage
Hashable Labels
If you are just looking to create a hashable object to determine isomorphism
then it is simples to use the CanonLabeling struct.
This can be created from a Graph object directly.
Directed Graphs
use ;
use CanonLabeling;
let e1 = vec!; // Isomorphic
let e2 = vec!; // Isomorphic
let e3 = vec!; // Non-Isomorphic
let g1 = from_edges;
let g2 = from_edges;
let g3 = from_edges;
let l1 = new;
let l2 = new;
let l3 = new;
assert_eq!;
assert_ne!;
Undirected Graphs
use ;
use CanonLabeling;
let e1 = vec!; // Isomorphic
let e2 = vec!; // Isomorphic
let e3 = vec!; // Non-Isomorphic
let g1 = from_edges;
let g2 = from_edges;
let g3 = from_edges;
let l1 = new;
let l2 = new;
let l3 = new;
assert_eq!;
assert_ne!;
Recovering the Canonical Graph
If instead you are interested in working with the graph itself,
you can use the canonize function to return a new Graph object
use ;
use canonize;
let edges = vec!;
let graph = from_edges;
let canon = canonize;
assert_eq!;
Timing Comparison
This crate is inspired by nauty-pet
but is much faster as it is much simpler.
(tests measured with criterion)
This test is using a randomly generated graph of 10 nodes and 0.5 probability
of edge connection using random_gpn_graph
graph-canon time: [1.3272 µs 1.3276 µs 1.3285 µs]
Found 14 outliers among 100 measurements (14.00%)
3 (3.00%) high mild
11 (11.00%) high severe
nauty-pet time: [6.2591 µs 6.2738 µs 6.2956 µs]
Found 10 outliers among 100 measurements (10.00%)
2 (2.00%) low mild
4 (4.00%) high mild
4 (4.00%) high severe