Skip to main content

qiskit-graph-walks

Quantum walk algorithms for graph problems, built on Qiskit.

Coined and continuous-time quantum walks are usually presented as physics demos of ballistic spreading on a line or a lattice. This package treats them as algorithmic primitives for graph problems instead: spatial search on arbitrary graphs, and graph-invariant fingerprinting for isomorphism testing, both built directly on top of Qiskit circuits so they compose with the rest of the Qiskit ecosystem (transpilation, backends, noise models, etc.).

What's here

Module What it does
qiskit_graph_walks.ctqw Continuous-time quantum walks (H = -gamma*A or the graph Laplacian), circuit construction and exact simulation.
qiskit_graph_walks.dtqw Discrete-time (Szegedy) quantum walks -- works on any graph, not just regular ones.
qiskit_graph_walks.search CTQW spatial search (Childs & Goldstone, 2004) with automatic parameter optimization for arbitrary graphs.
qiskit_graph_walks.isomorphism CTQW-based graph invariants for isomorphism testing -- a genuine proof of non-isomorphism when fingerprints differ, a documented heuristic otherwise.

Installation

git clone https://github.com/RexRowan/qiskit-graph-walks.git
cd qiskit-graph-walks
pip install -e ".[dev]"

Requires Python >= 3.9, Qiskit >= 2.0, NetworkX >= 3.0.

(Qiskit >= 2.0 is required for eventual submission to the Qiskit Ecosystem -- see CONTRIBUTING.md if this repo is ever proposed as a member.)

Quickstart

Continuous-time quantum walk

import networkx as nx
from qiskit_graph_walks import ContinuousTimeQuantumWalk

G = nx.petersen_graph()
walk = ContinuousTimeQuantumWalk(G)

circuit = walk.circuit(time=2.5, initial_vertex=0)   # a Qiskit QuantumCircuit
probs = walk.probabilities(time=2.5, initial_vertex=0)  # exact per-vertex occupation

Spatial search

from qiskit_graph_walks import SpatialSearch

search = SpatialSearch(nx.complete_graph(16), marked_vertices=7)
result = search.optimize()
print(result.gamma, result.time, result.success_probability)
# -> matches the Childs-Goldstone closed form for the complete graph

circuit = search.circuit(result.gamma, result.time)
circuit.measure_all()

Graph isomorphism testing

from qiskit_graph_walks import are_possibly_isomorphic

result = are_possibly_isomorphic(graph_a, graph_b)
print(result.summary)

Read this before trusting the isomorphism result: a fingerprint mismatch is a genuine proof of non-isomorphism. A fingerprint match is not a proof of isomorphism -- it means the test didn't find a difference, which is not the same thing. See docs/isomorphism.md for what this technique can and can't do, including a worked example of a classic cospectral (but non-isomorphic) graph pair that it does successfully separate.

Documentation

Scope and known limitations

  • The Szegedy walk (dtqw.py) builds its step operator as an explicit dense unitary matrix. This is exact and easy to verify, but doesn't scale past small graphs (roughly up to a few hundred vertices before the dense linear algebra becomes the bottleneck). Synthesizing the walk operator into an elementary-gate decomposition for larger graphs is a natural next contribution -- see open issues.
  • SpatialSearch.optimize() uses local numerical optimization (Nelder-Mead) seeded from the complete-graph closed form. For graphs very different in structure from the complete graph, consider trying several seeds, since a single local optimizer run is not guaranteed to find the global optimum.
  • The isomorphism fingerprint is a heuristic invariant, not a decision procedure. See docs/isomorphism.md.

Development

pip install -e ".[dev]"
pytest tests/ -v

License

Apache 2.0. See LICENSE.

References

  • Farhi, E. & Gutmann, S. (1998). "Quantum computation and decision trees." Physical Review A, 58(2), 915.
  • Childs, A. M. & Goldstone, J. (2004). "Spatial search by quantum walk." Physical Review A, 70(2), 022314.
  • Szegedy, M. (2004). "Quantum speed-up of Markov chain based algorithms." FOCS 2004, 32-41.
  • Douglas, B. L. & Wang, J. B. (2008). "A classical approach to the graph isomorphism problem using quantum walks." Journal of Physics A, 41(7), 075303.
  • Rudinger, K. et al. (2012). "Comparing algorithms for graph isomorphism using discrete- and continuous-time quantum random walks." J. Comput. Theor. Nanosci.

Metadata

Release files for qiskit-graph-walks 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qiskit-graph-walks 0.1.0
File Size Uploaded
qiskit_graph_walks-0.1.0.tar.gz 21.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for qiskit-graph-walks 0.1.0
File Interpreter ABI Platform
qiskit_graph_walks-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 42.4 kB

Release files / qiskit_graph_walks-0.1.0.tar.gz

Download URL qiskit_graph_walks-0.1.0.tar.gz
Size 21.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a4032c6aeef54caff8c2230db24143c23927a9c1d2ebf5d514f05f3f93e4067c
BLAKE2b-256 checksum
How to use checksums
04640c4e2f5a1728f23670ff6e42e0bcbc6a4a45fa90727f1bd10141ce8b90fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.1

Release files / qiskit_graph_walks-0.1.0-py3-none-any.whl

Download URL qiskit_graph_walks-0.1.0-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4473b9c1851e09e433c0c152500ba3b406c7fd217faf331f2647b20f8ee71633
BLAKE2b-256 checksum
How to use checksums
58260938d99d20a4ac5c86f9b4bb5802e23e0146009bb4e33d0c6578534921a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.1

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page