Skip to main content
KetQat

Appearance

Theorem · intermediate

Swap networks make every pair adjacent once on a line

On a line of n qubits, n alternating layers of nearest-neighbour SWAPs reverse the order of the qubits and bring every pair of them next to each other exactly once, so any gate on every pair can be applied with linear depth and only nearest-neighbour connectivity.

Established resultMachine-checkedUpdated 2026-12-01 · last verified 2026-12-01

AI-assisted text, machine-checked, not yet reviewed by a person. Citations resolve and an automated pass compared the statements with the cited sources. That is not peer review; check the sources for anything you depend on.

After the nn rounds the qubit that started at position ii is at position n−1−in - 1 - i, the network contains exactly n(n−1)/2n(n-1)/2 SWAPs, and every unordered pair of qubits occupies adjacent positions and is swapped exactly once.

Consequently, a layer of commuting two-qubit gates acting on all (n2)\binom n2 pairs (for example the ZZZZ terms of a QAOA layer on a complete graph, or the pair terms of a Trotter step) can be applied on a line in depth nn by merging each pair's gate into the SWAP that exchanges it. For fermions under the Jordan–Wigner encoding the SWAP is replaced by a fermionic SWAP, which keeps the encoding local; Kivlichan et al. use this to apply a Trotter step of the electronic-structure Hamiltonian in depth NN with about N2/2N^2/2 entangling gates on a linear array. The output order is reversed, which is harmless if the next layer runs the network backwards.

Holds when

  • Qubits (or modes) at positions 0,…,n−10, \dots, n-1 of a path graph; in round t=1,…,nt = 1, \dots, n a SWAP is applied to every pair {y,y+1}\{y, y+1\} with y≡t−1(mod2)y \equiv t - 1 \pmod 2 and y+1≤n−1y + 1 \le n - 1.

Proof

Proof that swap networks make every pair adjacent onceMachine-checked

Active pairs. In round t+1t+1 the SWAPs act on the pairs {y,y+1}\{y, y+1\} with y≡t(mod2)y \equiv t \pmod 2. Each position xx belongs to at most one active pair: as its left member if x≡tx \equiv t and x≤n−2x \le n-2, as its right member if x≡t+1x \equiv t+1 and x≥1x \ge 1. Position n−1n-1 with n−1≡tn - 1 \equiv t and position 00 with 0≡t+10 \equiv t + 1 are the only positions not in an active pair.

Trajectories. Define the fold map F(u)=uF(u) = u for 0≤u≤n−10 \le u \le n-1, F(u)=2n−1−uF(u) = 2n-1-u for n≤u≤2n−1n \le u \le 2n-1 and F(u)=−1−uF(u) = -1-u for −n≤u≤−1-n \le u \le -1. For the qubit starting at ii put ui(t)=i+tu_i(t) = i + t if ii is even and ui(t)=i−tu_i(t) = i - t if ii is odd; for 0≤t≤n0 \le t \le n these stay in [−n,2n−1][-n, 2n-1]. Call the qubit a right-mover after tt rounds if ui(t)∈[0,n−1]u_i(t) \in [0, n-1] with ii even or ui(t)∈[−n,−1]u_i(t) \in [-n, -1] with ii odd, and a left-mover otherwise. From the formulas, F(ui(t+1))=F(ui(t))+1F(u_i(t+1)) = F(u_i(t)) + 1 for a right-mover not at position n−1n-1, F(ui(t+1))=F(ui(t))−1F(u_i(t+1)) = F(u_i(t)) - 1 for a left-mover not at position 00, and F(ui(t+1))=F(ui(t))F(u_i(t+1)) = F(u_i(t)) for a right-mover at n−1n-1 or a left-mover at 00. A direct parity check gives: a qubit with F(ui(t))=xF(u_i(t)) = x is a right-mover exactly when x≡t(mod2)x \equiv t \pmod 2 (for even ii unreflected x=i+tx = i + t; reflected x=2n−1−i−tx = 2n-1-i-t; for odd ii unreflected x=i−tx = i - t; reflected x=t−1−ix = t - 1 - i).

We show by induction on tt that after tt rounds the qubit starting at ii sits at F(ui(t))F(u_i(t)). This holds for t=0t = 0. Assume it after tt rounds and consider round t+1t+1. A right-mover at x≤n−2x \le n-2 has x≡tx \equiv t, so it is the left member of an active pair and moves to x+1x + 1. A left-mover at x≥1x \ge 1 has x≡t+1x \equiv t + 1, so it is the right member of an active pair and moves to x−1x - 1. A right-mover at n−1n - 1 (then n−1≡tn - 1 \equiv t) and a left-mover at 00 (then 0≡t+10 \equiv t+1) are in no active pair and stay. In every active pair the left member is a right-mover and the right member a left-mover, so these moves are exactly the SWAPs of the round, and each agrees with F(ui(t+1))F(u_i(t+1)) as computed above.

Reversal. The ranges stay within the domain of FF: for even ii, ui(n)=i+n∈[n,2n−1]u_i(n) = i + n \in [n, 2n-1], so xi(n)=2n−1−i−n=n−1−ix_i(n) = 2n - 1 - i - n = n - 1 - i; for odd ii, ui(n)=i−n∈[−n,−1]u_i(n) = i - n \in [-n, -1], so xi(n)=−1−i+n=n−1−ix_i(n) = -1 - i + n = n - 1 - i.

Every pair exactly once. Round t+1t+1 with tt even contains ⌊n/2⌋\lfloor n/2 \rfloor SWAPs and round t+1t+1 with tt odd contains ⌊(n−1)/2⌋\lfloor (n-1)/2 \rfloor. Among t=0,…,n−1t = 0, \dots, n-1 there are ⌈n/2⌉\lceil n/2 \rceil even and ⌊n/2⌋\lfloor n/2 \rfloor odd values, which gives n(n−1)/2n(n-1)/2 SWAPs in total for both parities of nn. A SWAP changes the relative order of only the two qubits it exchanges. Every pair i<ji < j ends in the opposite order, so it was swapped an odd number of times, at least once. With (n2)\binom n2 pairs and (n2)\binom n2 SWAPs, each pair is swapped exactly once, and it is adjacent at that moment.

Open in the knowledge graph

Contributions about this record

Nobody has published a contribution about it yet.

Publish a result, reproduction or commentPropose a correction to this page

References

  1. Ian D. Kivlichan, Jarrod McClean, Nathan Wiebe, … Ryan Babbush (2018). Quantum Simulation of Electronic Structure with Linear Depth and Connectivity. Physical Review Letters 120, 110501. doi:10.1103/PhysRevLett.120.110501arXiv:1711.04789

Contributors

  • KetQat maintainers · @ketqatConceptualization; Supervision (CRediT roles)
  • Claude (AI drafting assistant)Writing, original draft (CRediT roles)

Review history

  1. Automated source check · Pass · 2026-12-01 · Independent automated verification pass (AI, not the drafting session)

    Statement checked by exhaustive simulation (python) of the stated odd-even round schedule for n = 1..12: final order reversed, exactly n(n-1)/2 SWAPs, every unordered pair swapped exactly once. Fermionic swap network claim (Trotter step of electronic structure in depth N with N^2/2 two-qubit gates on a line) compared with the abstract of Kivlichan et al., arXiv 1711.04789 (PRL 120, 110501, 2018); Crossref metadata match.

Revision history

  1. 2026-12-01Content release 2.1.0: 35 more topics, an independent source check of every record, intake hardening (#17)80537b7e

Current revision 7bd96ba2d11311ee. Source file knowledge/records/theorem/swap-network-adjacency.md in the content repository (readable there once it is public).