Skip to main content

Isomorphism testing and automorphisms of graphs.

Project description

Build and test

Pynauty

Pynauty can be used to compare graphs for isomorphism and to determine their automorphism group in a Python programming environment. Pynauty is a Python/C extension module using library components from the Nauty package by Brendan McKay.

Current version is distributed and has been tested with nauty27r4.

Usage

Here is an example of pynauty's usage in an interactive session.

>>> from pynauty import *
>>> g = Graph(5)
>>> g.connect_vertex(0, [1, 2, 3])
>>> g.connect_vertex(2, [1, 3, 4])
>>> g.connect_vertex(4, [3])
>>> print(g)
Graph(number_of_vertices=5, directed=False,
 adjacency_dict = {
  0: [1, 2, 3],
  2: [1, 3, 4],
  4: [3],
 },
 vertex_coloring = [
 ],
)
>>> autgrp(g)
([[3, 4, 2, 0, 1]], 2.0, 0, [0, 1, 2, 0, 1], 3)
>>> 
>>> g.connect_vertex(1, [3])
>>> autgrp(g)
([[0, 1, 3, 2, 4], [1, 0, 2, 3, 4]], 4.0, 0, [0, 0, 2, 2, 4], 3)
>>>
>>> g.set_vertex_coloring([set([3])])
>>> print(g)
Graph(number_of_vertices=5, directed=False,
 adjacency_dict = {
  0: [1, 2, 3],
  1: [3],
  2: [1, 3, 4],
  4: [3],
 },
 vertex_coloring = [
  set([3]),
  set([0, 1, 2, 4]),
 ],
)
>>> autgrp(g)
([[1, 0, 2, 3, 4]], 2.0, 0, [0, 0, 2, 3, 4], 4)
>>>

Please note that multigraphs are not supported, but this limitation can be worked around by encoding multigraphs as simple graphs. For details, see the documentation and Nauty's manual.

Installation

Installing from PyPi

You can install pynauty using pip, just type

pip install --upgrade pynauty

Many binary wheels are provided for recent Linux and macOS systems. When your system is not compatible with any of the provided binary wheels pip attempts to build the wheel of the extension module in your local system. This happens automatically and the process is transparent to the user. For local builds pip expects that the required tools are available.

You can force the local (re)compilation during install by issuing

pip install --no-binary pynauty pynauty

Regardless of which way the installation was accomplished, afterwards you can test the result by running the provided tests.

python <path-to-installed-package>/pynauty/tests/test_minimal.py

If you have pytest installed then you can run the full test suit by issuing

pip install pytest
python -m pytest <path-to-installed-package>/pynauty

That takes a few seconds but then you can be sure in having a binary compatible module.

Documentation

The pynauty package comes with an HTML documentation with examples. You can read it with your favorite browser:

<your-browser>  <path-to-installed-package>/pynauty/docs/html/index.html

Building manually from sources

Requirements

Apart from Python the requirements are the same as for building Nauty.

  • Python 3.8 - 3.10
  • An ANSI C compiler
  • GNU make

Download sources

You can download the source distribution form PyPi by issuing:

pip download --no-binary pynauty pynauty

Please note, the source distribution also contains Nauty27r4's source.

Build, test, install

If you really are interested in the low level details then unpack the downloaded source distribution, change into pynauty's directory and type make. The Makefile is self-documenting in the sense that invoking make without arguments will list all available targets with short explanations.

Contributing

Questions, bug reports, pull requests, especially the ones extending the Python module's functionality, are welcome. Please, open an issue first to discuss what you would like to change.

Pull requests must be made on a dedicated topic-branch of your choice and not against upstream/main. Before submitting a pull request, make sure that your fork is up to date with upstream. Also update tests, documentation, examples as appropriate with the changes in your PR.

Contributors

  • @goens helped creating pytest components.

  • Sam Morley-Short (@sammorley-short) added canon_label() function.

  • Frank Bryce fixed the issue of misleadingly accepting multigraphs.

License

Pynauty is distributed under the terms of GPL v3 WITHOUT ANY WARRANTY. For the exact details on licensing see the file COPYING.

Please note, Nauty is covered by its own licensing terms. For the exact details see the file src/nauty27r3/COPYRIGHT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pynauty-1.1.2.tar.gz (1.9 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pynauty-1.1.2-cp310-cp310-manylinux_2_35_x86_64.whl (317.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.35+ x86-64

pynauty-1.1.2-cp310-cp310-manylinux_2_31_x86_64.whl (320.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.31+ x86-64

pynauty-1.1.2-cp310-cp310-macosx_10_15_universal2.whl (306.6 kB view details)

Uploaded CPython 3.10macOS 10.15+ universal2 (ARM64, x86-64)

pynauty-1.1.2-cp39-cp39-manylinux_2_31_x86_64.whl (320.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.31+ x86-64

pynauty-1.1.2-cp39-cp39-macosx_10_15_x86_64.whl (300.8 kB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

File details

Details for the file pynauty-1.1.2.tar.gz.

File metadata

  • Download URL: pynauty-1.1.2.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for pynauty-1.1.2.tar.gz
Algorithm Hash digest
SHA256 fca00e50874b0cb34800f41b91b31f4b61a6ec22f2d3bd0b2290209b8d552307
MD5 a5d35bbffa14bde092e45df268c71039
BLAKE2b-256 48ac305b0917ad230d3872d18d03945895c1ac199c5d7da742ee29a6185fdf6a

See more details on using hashes here.

File details

Details for the file pynauty-1.1.2-cp310-cp310-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for pynauty-1.1.2-cp310-cp310-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 3e5dd7adaf5f99fa41d72fdb536d44226c9c4a1ca979b7a2613c9d6c61616c90
MD5 719a26e22b1e3d4f2928bf343508d3bd
BLAKE2b-256 75adcd694a249043607e63a351e3113f0905ab59903b4720b1de9e62eae58868

See more details on using hashes here.

File details

Details for the file pynauty-1.1.2-cp310-cp310-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for pynauty-1.1.2-cp310-cp310-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 9ca4a04a62ca53355474dd3057c9af9ddfb3f96308190cd9dd480803d1d64086
MD5 a8342e97afe022f20a9bc7398d1a985e
BLAKE2b-256 b00ffb19976a04a329e871db6849ee49223835742a2d7c4670d08bb08279c809

See more details on using hashes here.

File details

Details for the file pynauty-1.1.2-cp310-cp310-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for pynauty-1.1.2-cp310-cp310-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 2ef8b0cca7b586bec6d5088f7f57578167724372645b17ed2b088ac72c02eb7b
MD5 b5b909a73bd67a3acfcd29d97511bb38
BLAKE2b-256 0086b06adc5d7252eae28fa0dce58c15e6a5c594a8e43f119e0759ec8a338769

See more details on using hashes here.

File details

Details for the file pynauty-1.1.2-cp39-cp39-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for pynauty-1.1.2-cp39-cp39-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 d112d5e621a2608e327cee80fd2da42bd7bcb770b90c5bd001b2d58d129a7697
MD5 60215c85eb193e770f00d3a5153649c0
BLAKE2b-256 b9119b131902543ce498e8c6eedd723d0cd7e4b7ec8ea832dfcd60db35c88b08

See more details on using hashes here.

File details

Details for the file pynauty-1.1.2-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for pynauty-1.1.2-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 802358f8a3e1293f35527c890b20e6b8a676b579df1a6a89b35ea9e7c397006e
MD5 1cbeb4c2455aa95932d1aa39eb8135c4
BLAKE2b-256 18e7e03fd16fe7c50e52894f41cbbbed51488b721bd8d264569c568ee034cd8f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page