canonaut (Python)
Graph canonicalization and automorphism groups: Python bindings for canonaut, a safe Rust port of nauty. The PyPI package and the Rust crate share the name.
Install
pip install canonaut
Usage
Nodes can be any hashable value — ints, strings, tuples, whatever you already
have. No need to relabel your graph to 0..n-1 first.
import canonaut
# Canonize a 4-cycle with arbitrary node labels
r = canonaut.canonize([("a","b"), ("b","c"), ("c","d"), ("d","a")])
print(r.num_orbits) # 1 (vertex-transitive)
print(r.group_size1, r.group_size2) # |Aut| ~= group_size1 * 10**group_size2
print(r.canonical_edges) # edges of the canonical form (0..n-1 index space)
# Vertex colors (partition): vertices with different colors are never mapped
# onto each other by any automorphism, and the canonical form respects it.
r = canonaut.canonize(
[(0,1), (1,2), (2,3)],
colors={0: "red", 1: "red", 2: "blue", 3: "blue"},
)
print(r.num_orbits) # 4 (colors broke the path's end-to-end symmetry)
# Automorphism generators, as {node: image_node} maps
r = canonaut.canonize([("a","b"),("b","c"),("c","d"),("d","a")], generators=True)
print(r.generators)
# Orbits, grouped by original node label
print(r.orbits) # [['a','b','c','d']] for the 4-cycle
# Isomorphism test — works with different label sets on each side
canonaut.are_isomorphic(
[("p","q"),("q","r"),("r","s"),("s","p")],
[(1,2),(2,3),(3,4),(4,1)],
) # True
# Hashable canonical key for deduplication — equal iff the graphs are isomorphic
key = r.canonical_bytes()
# networkx graphs work directly (duck-typed, no hard dependency)
import networkx as nx
r = canonaut.canonize(nx.petersen_graph())
Isolated vertices
nodes= includes vertices with no edges at all:
canonaut.canonize([("a","b")], nodes=["a", "b", "isolated"])
Directed graphs
canonaut.canonize(edges, directed=True)
Detected automatically for graph-like objects exposing .is_directed() (e.g.
networkx.DiGraph).
Low-level API
canonaut.raw exposes the compiled extension directly: 0..n-1 integer
vertex indices only, no node-label translation. Use it if you already have
integer-labeled graphs and want to skip that overhead:
r = canonaut.raw.canonize(4, [(0,1),(1,2),(2,3)], colors=[0,0,1,1])
CanonResult
| Attribute | Type | Meaning |
|---|---|---|
labeling |
list |
Original nodes in canonical order — labeling[i] is the node placed at canonical position i |
orbits |
list[list] |
Automorphism-group orbits, as groups of original nodes |
canonical_edges |
list[tuple[int,int]] |
Edges of the canonical form, in canonical-position (0..n-1) space |
group_size1, group_size2 |
float, int |
|Aut(G)| ~= group_size1 * 10**group_size2 |
num_orbits, num_generators |
int |
|
generators |
list[dict] |
Automorphism generators as {node: image_node} maps (only when generators=True) |
.canonical_bytes() |
bytes |
Hashable canonical key |
Metadata
Release files for canonaut 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| canonaut-1.0.0.tar.gz | 275.2 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| canonaut-1.0.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details |
| canonaut-1.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| canonaut-1.0.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| canonaut-1.0.0-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details |
| canonaut-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 1.6 MB
Release files / canonaut-1.0.0.tar.gz
| Download URL | canonaut-1.0.0.tar.gz |
|---|---|
| Size | 275.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7fb5a0469d4aac4d46bbd3fc62b992ea8c52d2b19f710580b2d8c8a70f273a94
|
|
BLAKE2b-256 checksum How to use checksums |
df86bd6101666d087ae97099a260e9cdfab9f665b6aec9c8ef61dc6c2fa74872
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.
Transparency logRelease files / canonaut-1.0.0-cp39-abi3-win_amd64.whl
| Download URL | canonaut-1.0.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 200.7 kB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
9de63b336510e99727f8ca6ba5a305442c7f96f01fc0640c5e6042bb6ca8e30e
|
|
BLAKE2b-256 checksum How to use checksums |
7efd7be6991770fc35cd1f88edebdaa86e1f5299ceb88ac14e6a3d3fc5f9b238
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.
Transparency logRelease files / canonaut-1.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | canonaut-1.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 288.7 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
bae514596a9d454ff00ea2b191d85a9f42b2c1e7127635d98a75f5a4062b5923
|
|
BLAKE2b-256 checksum How to use checksums |
f3f597be168d7f5e72b690ed496931479bba93313626bcd6bdaf7a42a51e1857
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.
Transparency logRelease files / canonaut-1.0.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | canonaut-1.0.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 274.0 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
a5ecfde6f2a9d65f11aa1e0049715468fed9079f7467c5a93746eae2c9a48c06
|
|
BLAKE2b-256 checksum How to use checksums |
723008b1a59d7a213ac92da799c57017d3f6e04ee91df6bf9e4e900356d931aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.
Transparency logRelease files / canonaut-1.0.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | canonaut-1.0.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 263.9 kB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7bd85c664b4ebb81974e8586262cd147bd6cb7062930084aa4c305e0473dceea
|
|
BLAKE2b-256 checksum How to use checksums |
286b84d082e3111c7653f2aa5c58be49368ce51294d2dc7235029701b25db560
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.
Transparency logRelease files / canonaut-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | canonaut-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 275.8 kB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
c9c93873a904979df28012deb468d14f2a0c37a3580b7b412da78be5fef28db9
|
|
BLAKE2b-256 checksum How to use checksums |
b762024654cba314bbdd49337d354e8138ccfc65509e03005d8758455d7fca50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.
Transparency log