Skip to content

[Rule] GraphPartitioning to QUBO #119

@zazabap

Description

@zazabap

Source: GraphPartitioning
Target: QUBO
Motivation: Enables solving graph bisection on quantum annealers (D-Wave); natural quadratic formulation with balance penalty.
Reference: Lucas, 2014, Ising formulations of many NP problems, Section 2.2

Reduction Algorithm

Notation:

  • Source: undirected graph $G = (V, E)$, $n = |V|$ (even), $m = |E|$
  • Target: QUBO with $n$ binary variables

Variable mapping: $x_i \in {0, 1}$ for each vertex $i$ ($x_i = 0$ if $i \in A$, $x_i = 1$ if $i \in B$).

Step 1 — Cut-counting term. For each edge $(u, v) \in E$, the expression $x_u + x_v - 2x_u x_v$ equals 1 iff $x_u \neq x_v$ (i.e., the edge is cut). Summing over all edges counts the cut size.

Step 2 — Balance penalty. The quadratic penalty $P(\sum_{i \in V} x_i - n/2)^2$ is zero iff exactly $n/2$ vertices are in $B$. Set $P > m$ to ensure any imbalanced partition has higher cost than any balanced one.

Step 3 — Construct the QUBO Q matrix. Initialize an $n \times n$ upper-triangular matrix $Q$ to zero. For each edge $(u,v) \in E$ with $u < v$:

  • $Q_{uu} \mathrel{+}= 1$, $Q_{vv} \mathrel{+}= 1$ (linear cut terms)
  • $Q_{uv} \mathrel{+}= -2$ (quadratic cut term)

Then add the expanded penalty $P(\sum x_i - n/2)^2 = P(1-n)\sum_i x_i + 2P\sum_{i<j} x_i x_j + Pn^2/4$:

  • For each $i$: $Q_{ii} \mathrel{+}= P(1-n)$
  • For each $i < j$: $Q_{ij} \mathrel{+}= 2P$

Resulting QUBO Q matrix entries:

$$Q_{ii} = \deg(i) + P(1 - n)$$

$$Q_{ij} = \begin{cases} -2 + 2P & \text{if } (i,j) \in E \\ 2P & \text{if } (i,j) \notin E \end{cases} \quad (i < j)$$

The QUBO objective is $\min_{x \in {0,1}^n} x^\top Q x$, equivalent to the original up to the constant offset $Pn^2/4$.

Solution extraction: $A = {i : x_i = 0}$, $B = {i : x_i = 1}$.

Size Overhead

Target metric (code name) Polynomial (using symbols above)
num_vars $n$

Validation Method

Closed-loop testing: solve GraphPartitioning by brute-force, solve the reduced QUBO, and verify both give the same optimal cut. Verify penalty $P$ is large enough.

Example

Source: 6 vertices, 9 edges: $(0,1), (0,2), (1,2), (1,3), (2,3), (2,4), (3,4), (3,5), (4,5)$.

QUBO: 6 variables, penalty $P = 10 &gt; m = 9$.

Degrees: $\deg(0)=2, \deg(1)=3, \deg(2)=4, \deg(3)=4, \deg(4)=3, \deg(5)=2$.

$Q_{ii} = \deg(i) + 10(1-6) = \deg(i) - 50$:

$$Q_{ii} = (-48,\ -47,\ -46,\ -46,\ -47,\ -48)$$

Off-diagonal ($i &lt; j$): $-2 + 2 \cdot 10 = 18$ for edges, $2 \cdot 10 = 20$ for non-edges:

$$Q = \begin{pmatrix} -48 & 18 & 18 & 20 & 20 & 20 \\ & -47 & 18 & 18 & 20 & 20 \\ & & -46 & 18 & 18 & 20 \\ & & & -46 & 18 & 18 \\ & & & & -47 & 18 \\ & & & & & -48 \end{pmatrix}$$

Optimal: $x = (0,0,0,1,1,1)$, cut edges: $(1,3), (2,3), (2,4)$, cut $= 3$, balance: $|B| = 3 = n/2$. Penalty $= 0$, $H = 3$.

Infeasible example: $x = (0,0,0,0,1,1)$ ($|B| = 2 \neq 3$), cut $= 3$ (edges $(2,4), (3,4), (3,5)$), penalty $= 10 \cdot (2 - 3)^2 = 10$, $H = 3 + 10 = 13$.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoodAn issue passed all checks.ruleA new reduction rule to be added.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions