Skip to main content

ctypes bindings to graph isomorphism solver dejavu

Project description

Bindings to graph isomorphism solver dejavu

This package provides a basic ctypes wrapper to the graph isomorphism solver dejavu (https://www.mathematik.tu-darmstadt.de/dejavu). The goal of the package is to provide easy-to-use, quick access to the main functionality of dejavu. For performance critical software, consider using the C++ version of dejavu directly.

Features

The package exposes methods of the probabilistic graph isomorphism solver dejavu. The main features include easy access to a probabilistic graph isomorphism test, probabilistic computation of graph automorphisms (AKA symmetries), color refinement (AKA 1-WL) and random walks of IR trees.

Quickstart

Once installed using pip, the package can simply be imported using import dejavu_gi.

Lets assume we want to compute the symmetries of the 5-cycle. Graphs in the package are represented using the number of vertices n (in this case 5) and an (undirected) edgelist, in this case [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]. We can then simply compute the symmetries as follows.

import dejavu_gi

group = dejavu_gi.get_automorphisms(5, [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]])
print(group)

The above code outputs the following representation of the automorphism group:

{'generators': [[4, 3, 2, 1, 0], [2, 3, 4, 0, 1]], 'base': [2, 4], 'size': 10.0}

generators is a generating set of the automorphism group, whereas base is a base and size is the order of the automorphism group. Note that this computation is probabilistic. More precisely, the solver is only guaranteed to return all the symmetries with some bounded error probability (which can be set using err). For more precise information on this, see the code documentation.

If we want to test two graphs for isomorphism, we can do so using:

import dejavu_gi

is_iso1 = dejavu_gi.are_isomorphic(5, [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]], 5, [[1, 0], [1, 2], [3, 2], [3, 4], [4, 0]])
is_iso2 = dejavu_gi.are_isomorphic(5, [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]], 5, [[1, 0], [1, 2], [3, 2], [3, 4], [4, 1]])
print(is_iso1)
print(is_iso2)

The output for the above would be:

0
0

We can also use the color refinement of dejavu, using the following code:

colors = dejavu_gi.color_refinement(3, [[0, 1],[0, 2]])
print(colors)

This returns a mapping from vertices to colors, in the above example this is:

[2, 0, 0]

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

dejavu_gi-0.1.3.tar.gz (210.3 kB view details)

Uploaded Source

File details

Details for the file dejavu_gi-0.1.3.tar.gz.

File metadata

  • Download URL: dejavu_gi-0.1.3.tar.gz
  • Upload date:
  • Size: 210.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for dejavu_gi-0.1.3.tar.gz
Algorithm Hash digest
SHA256 9b79c32d6aa2d9ae9f87fc96db2186ebf358554c58ea19cb56c84588fcca05a2
MD5 ae18abdd5f02eb3c6d45a259d9236a18
BLAKE2b-256 0278329be4ac9f3c79814fb994e89178063223909b7921418727a5c1f063f672

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