Graph Problems
Graph problems are fundamental in computer science:
- Graph isomorphism: determine if two graphs are the same
- Community detection: find clusters in networks
- Shortest path: find minimum distance paths
- Maximum clique: find the largest complete subgraph
- Minimum spanning tree: connect all vertices with minimum weight
Quantum algorithms can provide speedups for certain graph problems.
Quantum Walk on Graphs
Quantum walks on graphs provide algorithmic speedups:
- Spatial search: find a marked vertex in on complete graphs
- Element distinctness: queries using Johnson graph walks
- Triangle finding: queries
The speedup comes from the quadratic spreading of quantum walks compared to classical random walks.
A continuous-time quantum walk replaces the coin flip of a classical walk with phase evolution under a graph Hamiltonian. Taking , the adjacency matrix, the state at time is , starting from the uniform superposition. Because amplitudes interfere instead of adding as probabilities, the distance covered after time grows like rather than . That single fact is the origin of every query saving in the table below.
For spatial search the Hamiltonian becomes , where marks the target vertex with a penalty . On a complete graph of vertices the marked amplitude oscillates sinusoidally and peaks at , so a run stopped there succeeds with probability near 1 using evolution time. The stopping time is the operational catch: the amplitude keeps rotating past the peak, and a run left twice as long ends with almost no weight on the target. On irregular graphs the peak is also less clean, because the success probability depends on the spectral gap of and on how much of the initial uniform state overlaps the eigenstates that couple to the marked vertex.
Graph Isomorphism
Graph isomorphism asks if two graphs and are isomorphic (same structure).
Classically: no known polynomial algorithm (but not NP-complete) Quantum: no proven exponential speedup, but quantum walks may help for specific graph classes.
Graph invariant approach: compute quantum walk properties that are preserved under isomorphism.
Where Invariants Stop Being Enough
Every walk-based fingerprint eventually collides. The sharpest example is the pair formed by the Shrikhande graph and the 4×4 rook's graph: both are strongly regular with parameters , so both have adjacency eigenvalues , and with multiplicities , and . Any test that only compares spectra — adjacency, Laplacian, signless Laplacian, or the walk matrix — reports them as identical. They are not isomorphic: the six neighbours of any vertex induce a single 6-cycle in the Shrikhande graph, while in the rook's graph they induce two disjoint triangles.
Colour refinement (1-dimensional Weisfeiler–Leman) fails on the same input, because it cannot separate vertices of a graph that is regular and vertex-transitive. The practical rule is to escalate invariants only as far as needed: run the spectrum check first because it costs for diagonalization, compare the multiset of triangle counts per vertex next, and reserve brute-force canonical-form comparison for the rare pair that survives both.
For reference points, Babai's classical algorithm decides isomorphism in time, isomorphism for bounded-degree graphs is polynomial-time by the Babai–Luks algorithm, and no quantum algorithm is known to improve those exponents. Quantum walks help for specific graph families and for underlying subroutines such as automorphism testing, not for general isomorphism.
Community Detection
Community detection finds densely connected groups in networks:
Classical: modularity optimization, label propagation, spectral methods Quantum: quantum annealing on modularity optimization
The modularity function:
where is the adjacency matrix, is the degree, and is the community of vertex .
Quantum Speedups for Graph Problems
| Problem | Classical | Quantum | Speedup |
|---|---|---|---|
| Element distinctness | O(N) | O(N^2/3) | Quadratic |
| Triangle finding | O(N^5/3) | O(N^5/4) | Polynomial |
| Max-cut | NP-hard | QAOA | Approximation |
| Community detection | NP-hard | QA/QAOA | Heuristic |
The quantum speedups are often polynomial rather than exponential, but significant for large graphs.
Applications
Quantum graph algorithms for:
- Social networks: community detection, influence maximization
- Bioinformatics: protein interaction networks, gene regulatory networks
- Transportation: routing, traffic optimization
- Finance: correlation networks, risk analysis
- Materials science: molecular graphs, crystal structures
The numbers decide which of these is realistic today. Locating one marked vertex among candidates costs oracle calls with a quantum walk against classically, so the gain is real only when the oracle itself is cheap to apply. Triangle finding on the same scale costs queries quantum against the classical — roughly 830× fewer, but still a query volume that needs a memory architecture able to service it. Community detection and max-cut sit in a different category: they are NP-hard objectives where quantum annealing and QAOA supply heuristics, so they are judged by solution quality on a fixed time budget rather than by query complexity.
Python: Quantum Walk on Graph
import numpy as np
import scipy.linalg
def quantum_walk_search(graph, target, steps=50):
# Quantum walk search for a marked vertex.
n = len(graph)
A = np.array(graph, dtype=complex)
# Hamiltonian
H = A
t = steps / 2.0
U = scipy.linalg.expm(-1j * H * t)
# Initial state: uniform
psi0 = np.ones(n, dtype=complex) / np.sqrt(n)
psi_t = U @ psi0
probs = np.abs(psi_t)**2
return np.argmax(probs), probs
# Complete graph K4
graph = [[0,1,1,1],[1,0,1,1],[1,1,0,1],[1,1,1,0]]
target = 2
found, probs = quantum_walk_search(graph, target)
print(f"Target: {target}, Found: {found}, Match: {target == found}")
print(f"Probabilities: {np.round(probs, 3)}")
Graph Quantum Walk Algorithms
| Algorithm | Problem | Queries |
|---|---|---|
| Spatial search | Find marked vertex | O(sqrtN) |
| Element distinctness | Find duplicate | O(N^2/3) |
| Triangle finding | Find triangle | O(N^5/4) |
| Graph connectivity | Test connectivity | O(sqrtN) |
Graph Invariants from Walks
The quantum walk spectrum encodes:
- Adjacency spectrum: eigenvalues of adjacency matrix
- Laplacian spectrum: eigenvalues of graph Laplacian
- Signless Laplacian: eigenvalues of
- Walk matrix: eigenvalues of
These invariants separate the overwhelming majority of non-isomorphic pairs in milliseconds, and the rare collisions are exactly the pairs a second-stage test must handle.
Python: Catching a Cospectral Pair
The spectrum alone declares the rook's graph and the Shrikhande graph identical. Adding one structural check — how the neighbours of a vertex connect to each other — separates them:
import numpy as np
def rook_graph(n=4):
adj = [[0] * (n * n) for _ in range(n * n)]
for a in range(n * n):
ra, ca = divmod(a, n)
for b in range(n * n):
rb, cb = divmod(b, n)
if a != b and (ra == rb or ca == cb):
adj[a][b] = 1
return adj
def shrikhande_graph(n=4):
# Cayley graph on Z_4 x Z_4 with connection set {(+-1,0),(0,+-1),(1,1),(-1,-1)}.
shifts = [(1, 0), (-1, 0), (0, 1), (0, -1), (1, 1), (-1, -1)]
adj = [[0] * (n * n) for _ in range(n * n)]
for x in range(n):
for y in range(n):
u = x * n + y
for dx, dy in shifts:
v = ((x + dx) % n) * n + ((y + dy) % n)
adj[u][v] = 1
return adj
def local_components(adj, v):
# The induced subgraph on v's neighbours is 2-regular: 2 components = two
# triangles, 1 component = a single 6-cycle.
nbrs = [u for u in range(len(adj)) if adj[v][u]]
seen, comps = set(), 0
for start in nbrs:
if start in seen:
continue
comps += 1
stack = [start]
while stack:
u = stack.pop()
if u in seen:
continue
seen.add(u)
stack += [w for w in nbrs if adj[u][w] and w not in seen]
return comps
for name, g in [("rook", rook_graph()), ("shrikhande", shrikhande_graph())]:
eig = np.round(np.linalg.eigvalsh(np.array(g)), 6)
counts = {float(e): list(eig).count(float(e)) for e in set(eig)}
print(f"{name:11s} spectrum={counts} local components={local_components(g, 0)}")
Both graphs print the same spectrum — eigenvalues , and with multiplicities , and — while the local component count reads 2 for the rook's graph and 1 for the Shrikhande graph. That mismatch is the whole lesson about invariants: a fingerprint that agrees is evidence of similarity, never proof of identity.
Summary
Quantum walks are the graph-native tool in the quantum toolbox. Phase evolution under the adjacency matrix spreads amplitude quadratically, which is what converts to spatial search, element distinctness and triangle finding — polynomial gains rather than exponential ones, and only where the query model matches the problem in front of you. Isomorphism is the cautionary case: spectra, walk matrices and colour refinement are cheap fingerprints that collide on structured pairs such as Shrikhande against the 4×4 rook's graph, while Babai's classical algorithm still sets the bar for the general problem. Dense objectives such as modularity and max-cut are a third category again, where QAOA and annealing compete on solution quality per second, not on complexity class. Choosing the right category — walk for search, fingerprint for identity, heuristic for dense objective — is the practical skill this material builds.
Common Mistakes
Treating a matching adjacency spectrum as proof that two graphs are isomorphic
Fix: The Shrikhande and 4x4 rook graphs share eigenvalues 6, 2 and -2 yet differ structurally; escalate to neighbourhood, triangle-count and canonical-form checks when spectra agree
Quoting the O(sqrt N) spatial search bound as if it applied to any graph
Fix: The bound assumes a uniform start and a usable spectral gap; on irregular graphs measure the hitting time first, and remember the marked amplitude oscillates so the run must stop at the first peak
Presenting QAOA results on MaxCut as a quantum speedup
Fix: At P equals 1 QAOA reaches about 0.6924 on 3-regular graphs against the 0.878 classical Goemans-Williamson guarantee, so always report the SDP baseline next to the quantum number
Carrying one Grover-style iteration count over to a different graph
Fix: Optimal runtime scales with the inverse spectral gap of the walk Hamiltonian, so recompute the gap or re-derive the stopping time whenever the graph changes
Key Takeaways
- Continuous-time quantum walks evolve under the adjacency matrix and spread amplitude as t squared instead of t, which is the source of the O(sqrt N) spatial search bound
- Element distinctness at N to the two-thirds and triangle finding at N to the five-fourths are the graph problems with proven quantum query improvements
- Cospectral graphs such as Shrikhande and the 4x4 rook graph show why an agreeing spectrum never proves isomorphism — the induced neighbourhood structure still differs
- Community detection and max-cut are NP-hard objectives where quantum methods are heuristics judged on solution quality per second, not on complexity bounds