Skip to main content

The Graph/Subgraph Isomorphism Library for Quantum Annealers

Project description

G/SG Morph

The Graph/Subgraph Isomorphism Library for Quantum Annealers

G/SG Morph is an implementation of Calude, Dinneen, and Hua's "QUBO formulations for the graph isomorphism problem and related problems" (Quantum Unconstrained Binary Optimization) QUBO's for finding graph, subgraph, and induced subgraph isomorphisms on quantum annealers.

G/SG Morph also contains, with the permission of Richard Hua, a copy of his implementation of the Graph Isomorphism QUBO from his thesis "Adiabatic Quantum Computing with QUBO Formulations", Appendix E which is used for benchmarking (see "Benchmarking" in this README).

Installation

You can either

pip install gsgmorph

or clone this repository and run the following in the folder (and your choice of python environment!):

pip install .

High Level Overview

G/SG Morph consists of two modules, matrix_form and pyqubo_form, both of which contain three core functions, graph_isomorphism(), subgraph_isomorphism(), and translate_sample() that accomplish identical tasks but are implemented differently.

matrix_form relies on the usage of dictionaries to provide a matrix representing the QUBO, while pyqubo_form uses the PyQUBO library to express QUBOs. Note that pyqubo_form has been intentionally programmed to follow the math presented in Calude, Dineen, and Hua's paper as closely as possible (with minor adjustments made to satisfy Python syntax).

Both graph_isomorphism() and subgraph_isomorphism() take two NetworkX graphs (a "graph to embed" onto a "target graph") and will generate a QUBO suitable for running on a simulated annealer such as D-Wave Neal or actual hardware.

The above functions also return a dictionary that, in conjunction with a sample from an annelear, can be translated into a dictionary that maps nodes from the graph to embed to the target graph with the help of translate_sample().

subgraph_isomorphism() also has an additional induced argument that can be set to True indicating that you would like to generate a QUBO for the Induced Subgraph Isomorphism problem.

Examples

Please refer to the Jupyter Notebooks in the examples folder.

  • gsgmorph_matrix_form_demo.ipynb shows the usage of the matrix_form module
  • gsgmorph_pyqubo_form_demo.ipynb shows the usage of the pyqubo_form module

Benchmarking

Some benchmarking was conducted against Richard Hua's graph isomorphism QUBO generator and G/SG Morph's matrix_form implementation using Erdos-Renyi graphs in Google Colab. The results and techniques can be found in the Benchmarking folder.

Contributing

If you find a bug or have an idea to improve the library, please feel free to either make an Issue or a Pull Request with your suggested changes! If you are contributing code, please do note that this library attempts to follow the PEP-8 Style Guide for Python Code as well as using Google Style Python Docstrings

Credits

Although all the QUBO formulations used come from Calude, Dinneen, and Hua's "QUBO formulations for the graph isomorphism problem and related problems", this library would not have been possible without the following helpful sources:

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

gsgmorph-1.0.2.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

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

gsgmorph-1.0.2-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file gsgmorph-1.0.2.tar.gz.

File metadata

  • Download URL: gsgmorph-1.0.2.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.7.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for gsgmorph-1.0.2.tar.gz
Algorithm Hash digest
SHA256 50035a595d73faf2ca590e1ef78504468155a6d427ff5fdcaadf5acd646bed0a
MD5 2772b413f64342b835e2a0d67f5e5bda
BLAKE2b-256 7d4fc7855519f6b86b0e4e68c2cf09ff4f8233465b6bd91f619c6344fb0eab08

See more details on using hashes here.

File details

Details for the file gsgmorph-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: gsgmorph-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 23.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.7.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for gsgmorph-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2e618bebcd90046631b7ac5e608285c021b8e02e5375400c2f364a9f2304b6bf
MD5 5899b8d83bd5548b584d4ce0ea709f93
BLAKE2b-256 5f321a66ffcc8aade3421ef630b5d76ec04e6e61d2a2a691ef002e986b27519a

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