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).
networkx.MultiGraph and MultiDiGraph are rejected because parallel edges
cannot be represented. Convert explicitly to nx.Graph or nx.DiGraph if
discarding edge multiplicities is intended. Duplicate pairs in a simple-graph
edge list still denote a single edge.
Fixed vertex colors and canonical keys
Color values are fixed labels: an isomorphism must map each color to the same
value in the other graph. Supported labels are integers, floats (except NaN),
strings, bytes, None, and tuples/frozensets containing these. Python-equal
numeric values such as 1 and 1.0 denote the same color. None and missing
dictionary entries share the implicit uncolored label. Map custom color objects
to stable labels before calling canonize.
canonical_bytes() includes graph order, directedness, and fixed colors as well
as canonical adjacency. Its versioned format has changed; regenerate previously
stored keys. The high-level and raw APIs have separate color encodings, so compare
keys produced through the same API. canonical_edges alone does not encode colors.
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.1.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 | Provenance | Actions |
|---|---|---|---|---|
| canonaut-1.1.0.tar.gz | 315.7 kB | With provenance | Details for canonaut-1.1.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| canonaut-1.1.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details for canonaut-1.1.0-cp39-abi3-win_amd64.whl |
| canonaut-1.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details for canonaut-1.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
| canonaut-1.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details for canonaut-1.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
| canonaut-1.1.0-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details for canonaut-1.1.0-cp39-abi3-macosx_11_0_arm64.whl |
| canonaut-1.1.0-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details for canonaut-1.1.0-cp39-abi3-macosx_10_12_x86_64.whl |
Total release size: 1.6 MB
Release files / canonaut-1.1.0.tar.gz
| Download URL | canonaut-1.1.0.tar.gz |
|---|---|
| Size | 315.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
14202443002d2d548fe09a76cbafb8620b4af4a37d6b986a3bc4b48e1f0c07ce
|
|
BLAKE2b-256 checksum How to use checksums |
00ff8caf4aa2bbce7579cb780f462f053df12b14319f3c79b667895af86078f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 3, 2026.
Transparency logRelease files / canonaut-1.1.0-cp39-abi3-win_amd64.whl
| Download URL | canonaut-1.1.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 209.2 kB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
80dcb14f3a8aed36fc216f691d68c514498029d203f63b88031bbfa3cfdf2446
|
|
BLAKE2b-256 checksum How to use checksums |
a3853d0898a7907235c45d81b91acf1f71bb4634a6fd0dd135cac7a0296a44f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 3, 2026.
Transparency logRelease files / canonaut-1.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | canonaut-1.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 292.7 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
49f80b68e73aa8383f14971e72bee15cf0aea883edb050e7836c97478eb0b8f5
|
|
BLAKE2b-256 checksum How to use checksums |
f7fdf1f9343afd43a17886c48707daa37d76c99c6ae7d910d92f1c6764073f7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 3, 2026.
Transparency logRelease files / canonaut-1.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | canonaut-1.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 279.0 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
876d766df67a094bec05f398d029feb491598237361ff0a8c9bfd1b1588bb6e9
|
|
BLAKE2b-256 checksum How to use checksums |
151be2770c04a38f202ed1000804b35cfddd8d2ca37e41ac693cc4234644bc54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 3, 2026.
Transparency logRelease files / canonaut-1.1.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | canonaut-1.1.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 269.5 kB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f3d279b59b8e739a12ca3b31eedf529fe0e2e85ff7a772b727101893322fd0b3
|
|
BLAKE2b-256 checksum How to use checksums |
4daaf1fb37be27cdee727cad826c469436aadab6f309040760a160a527eb3411
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 3, 2026.
Transparency logRelease files / canonaut-1.1.0-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | canonaut-1.1.0-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 282.1 kB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
777a56650d1684d62210fdf98d2606b4f7ccad96e865715d5120594ac56eb15d
|
|
BLAKE2b-256 checksum How to use checksums |
97526f8d53bf4425e5a5f67e5c4e1d305e7efd712b806874656a4e8d29d1d1a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 3, 2026.
Transparency logSecurity for canonaut 1.1.0
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.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for canonaut-1.1.0.tar.gz
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 Nov 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.