TExcelTAD

The Max-Cut SDP

Max-cut: split the vertices of a graph into two sides so that as many edges as possible go across. It is NP-hard, a random split cuts half the edges in expectation, and the natural LP relaxation is useless (its gap tends to 2). This lesson writes the relaxation that changed the picture: give each vertex a unit vector instead of a sign. It computes the optimal vectors of odd cycles analytically, proves their optimality with an SDP dual certificate, and finds and certifies optimal vectors for small irregular graphs with a simple local method, since no SDP solver is needed for graphs this small. The rounding of these vectors to a cut is the next lesson.

From signs to vectors

Encode a cut by xi∈{−1,+1}x_i \in \{ -1, +1 \}. Edge ijij is cut exactly when xixj=−1x_i x_j = -1, so

maxcut⁡(G)=max⁡x∈{±1}n  ∑ij∈E1−xixj2.\operatorname{maxcut}(G) = \max_{x \in \{\pm 1\}^n} \; \sum_{ij \in E} \frac{1 - x_i x_j}{2} .

Replace each xix_i by a unit vector vi∈Rnv_i \in \mathbb{R}^n and each product by an inner product:

SDP⁡(G)=max⁡  ∑ij∈E1−vi⋅vj2s.t.∥vi∥=1  ∀i.\operatorname{SDP}(G) = \max \; \sum_{ij \in E} \frac{1 - v_i \cdot v_j}{2} \quad \text{s.t.} \quad \lVert v_i \rVert = 1 \ \ \forall i .

Vectors in a one-dimensional space are ±1\pm 1, so every cut is a feasible solution and SDP⁡(G)≥maxcut⁡(G)\operatorname{SDP}(G) \ge \operatorname{maxcut}(G): it is a relaxation. With Xij=vi⋅vjX_{ij} = v_i \cdot v_j and the graph Laplacian LL (degrees on the diagonal, −1-1 for each edge), the objective is 14⟨L,X⟩\frac{1}{4} \langle L, X \rangle, and the problem is the SDP

max⁡  14⟨L,X⟩s.t.Xii=1,X⪰0.\max \; \tfrac{1}{4} \langle L, X \rangle \quad \text{s.t.} \quad X_{ii} = 1, \quad X \succeq 0 .

An edge contributes 1−cos⁡θij2\frac{1 - \cos \theta_{ij}}{2}, where θij\theta_{ij} is the angle between its two vectors: 0 for parallel vectors, 1 for opposite ones. The SDP tries to make adjacent vectors point apart.

Odd cycles by hand

On an even cycle, alternate ++ and −-: every edge is cut, so SDP = maxcut. On an odd cycle CnC_n the best cut misses one edge (n−1n - 1), but vectors can spread the "frustration" evenly. Place vkv_k in a plane at angle k⋅(n−1)πnk \cdot \frac{(n-1)\pi}{n}: consecutive vectors are at angle π−πn\pi - \frac{\pi}{n}, and after nn steps the angle (n−1)π(n - 1)\pi closes up (it is a multiple of 2π2\pi for odd nn). Every edge contributes 1+cos⁡(π/n)2\frac{1 + \cos(\pi / n)}{2}, so

SDP⁡(Cn)≥n2(1+cos⁡πn).\operatorname{SDP}(C_n) \ge \frac{n}{2}\left(1 + \cos \frac{\pi}{n}\right).

To prove this is optimal, use the dual SDP: min⁡∑iyi\min \sum_i y_i subject to Diag⁡(y)−14L⪰0\operatorname{Diag}(y) - \frac{1}{4} L \succeq 0. Weak duality holds because, for feasible XX and yy,

∑iyi−14⟨L,X⟩=⟨Diag⁡(y)−14L, X⟩≥0,\sum_i y_i - \tfrac{1}{4} \langle L, X \rangle = \big\langle \operatorname{Diag}(y) - \tfrac{1}{4} L,\ X \big\rangle \ge 0,

using Xii=1X_{ii} = 1 and the fact that the inner product of two PSD matrices is non-negative. For a cycle (and any vertex-transitive graph) take every yi=14λmax⁡(L)y_i = \frac{1}{4} \lambda_{\max}(L); then Diag⁡(y)−14L=14(λmax⁡I−L)⪰0\operatorname{Diag}(y) - \frac{1}{4} L = \frac{1}{4}(\lambda_{\max} I - L) \succeq 0. The program checks both sides for C5C_5.

python · try it yourself
import math
import numpy as np

n = 5
E = [(k, (k + 1) % n) for k in range(n)]
L = np.zeros((n, n))
for u, v in E:
    L[u, u] += 1; L[v, v] += 1; L[u, v] -= 1; L[v, u] -= 1

step = (n - 1) * math.pi / n
V = np.array([[math.cos(k * step), math.sin(k * step)] for k in range(n)])
X = V @ V.T
primal = float(np.sum(L * X)) / 4
lam_max = float(np.linalg.eigvalsh(L).max())
y = np.full(n, lam_max / 4)
slack_min = float(np.linalg.eigvalsh(np.diag(y) - L / 4).min())
print("angle between consecutive vectors:", round(math.degrees(step), 4), "degrees")
print("primal value (vectors):", round(primal, 6), " formula:", round(n / 2 * (1 + math.cos(math.pi / n)), 6))
print("dual value sum y_i:   ", round(float(y.sum()), 6), " dual feasible:", slack_min > -1e-9)
print("max cut of C5 = 4, ratio maxcut / SDP =", round(4 / primal, 6))
angle between consecutive vectors: 144.0 degrees
primal value (vectors): 4.522542  formula: 4.522542
dual value sum y_i:    4.522542  dual feasible: True
max cut of C5 = 4, ratio maxcut / SDP = 0.884458

Primal and dual values agree, so SDP⁡(C5)=52(1+cos⁡π5)≈4.5225\operatorname{SDP}(C_5) = \frac{5}{2}(1 + \cos \frac{\pi}{5}) \approx 4.5225, a certified optimum. The ratio 44.5225≈0.8845\frac{4}{4.5225} \approx 0.8845 is close to the Goemans-Williamson constant 0.8780.878 of the next lesson.

python · try it yourself
import math

print("  n   max cut   SDP value   maxcut / SDP")
for n in [3, 5, 7, 9, 15, 51]:
    sdp = n / 2 * (1 + math.cos(math.pi / n))
    print(f"{n:3}   {n - 1:7}   {sdp:9.4f}   {(n - 1) / sdp:.4f}")
  n   max cut   SDP value   maxcut / SDP
  3         2      2.2500   0.8889
  5         4      4.5225   0.8845
  7         6      6.6534   0.9018
  9         8      8.7286   0.9165
 15        14     14.8361   0.9436
 51        50     50.9516   0.9813

The 5-cycle is the worst odd cycle (ratio 0.88450.8845; the triangle gives 22.25≈0.8889\frac{2}{2.25} \approx 0.8889), and long cycles approach ratio 1. The worst graphs for this SDP are not cycles: Feige and Schechtman (2002) built graphs (from points on high-dimensional spheres) whose ratio approaches 0.878…0.878\ldots, matching the rounding analysis, so the integrality gap of the max-cut SDP is exactly the Goemans-Williamson constant.

The eigenvalue bound

The uniform dual yi=14λmax⁡(L)y_i = \frac{1}{4} \lambda_{\max}(L) is feasible for every graph, not only for symmetric ones, so weak duality gives

maxcut⁡(G)≤SDP⁡(G)≤n4λmax⁡(L),\operatorname{maxcut}(G) \le \operatorname{SDP}(G) \le \frac{n}{4} \lambda_{\max}(L),

an eigenvalue bound on the maximum cut that predates the SDP (it appears in Mohar and Poljak's work around 1990). The SDP is the best bound of this type: it optimizes over all diagonal corrections yy, not only over the uniform ones, and on irregular graphs it can be much smaller than the eigenvalue bound. For vertex-transitive graphs like cycles and the Petersen graph the two coincide.

Optimal vectors for small irregular graphs

For a graph without symmetry, a simple local method finds optimal vectors on small instances: start from random unit vectors in Rd\mathbb{R}^d and repeatedly replace each viv_i by the unit vector that maximizes its own terms, vi=−∑j∈N(i)vj∥∑j∈N(i)vj∥v_i = -\frac{\sum_{j \in N(i)} v_j}{\lVert \sum_{j \in N(i)} v_j \rVert} (each sweep can only increase the objective). This is the low-rank approach of Burer and Monteiro (2003); it can get stuck in local optima in general, but for dd around 2n\sqrt{2n} or more its local optima are typically global (Boumal, Voroninski and Bandeira, 2016). Whatever it returns can be certified: complementary slackness, (Diag⁡(y)−14L)X=0(\operatorname{Diag}(y) - \frac{1}{4} L) X = 0, forces yi=14(LX)iiy_i = \frac{1}{4} (LX)_{ii}, and if this yy is dual feasible, the vectors are optimal.

python · try it yourself
import itertools
import random
import numpy as np

def sdp_local(n, E, d=4, sweeps=500, seed=0):
    rng = random.Random(seed)
    V = [np.array([rng.gauss(0, 1) for _ in range(d)]) for _ in range(n)]
    V = [v / np.linalg.norm(v) for v in V]
    nbrs = [[j for e in E for j in e if i in e and j != i] for i in range(n)]
    for _ in range(sweeps):
        for i in range(n):
            g = sum(V[j] for j in nbrs[i])
            if np.linalg.norm(g) > 1e-12:
                V[i] = -g / np.linalg.norm(g)
    return np.array(V)

def certify(n, E, V):
    L = np.zeros((n, n))
    for u, v in E:
        L[u, u] += 1; L[v, v] += 1; L[u, v] -= 1; L[v, u] -= 1
    X = V @ V.T
    y = np.diag(L @ X) / 4                                   # forced by complementary slackness
    feasible = float(np.linalg.eigvalsh(np.diag(y) - L / 4).min()) > -1e-9
    return float(np.sum(L * X)) / 4, float(y.sum()), feasible

graphs = {
    "7 vertices, 10 edges": (7, [(0, 1), (1, 2), (2, 3), (3, 4), (4, 0), (0, 5), (5, 2), (5, 6), (6, 3), (1, 6)]),
    "Petersen graph": (10, [(i, (i + 1) % 5) for i in range(5)] + [(i, i + 5) for i in range(5)]
                       + [(5 + i, 5 + (i + 2) % 5) for i in range(5)]),
}
for name, (n, E) in graphs.items():
    V = sdp_local(n, E)
    primal, dual, ok = certify(n, E, V)
    mc = max(sum((u in S) != (v in S) for u, v in E) for k in range(n + 1) for S in itertools.combinations(range(n), k))
    print(f"{name}: SDP {primal:.4f}, dual {dual:.4f}, certified {ok}; max cut {mc}, ratio {mc / primal:.4f}")
7 vertices, 10 edges: SDP 9.2840, dual 9.2840, certified True; max cut 9, ratio 0.9694
Petersen graph: SDP 12.5000, dual 12.5000, certified True; max cut 12, ratio 0.9600

Both runs end with a dual feasible certificate whose value equals the primal value, so these are the SDP optima (up to floating-point accuracy), found without an SDP solver. For larger graphs, use a real SDP solver (interior-point methods solve the max-cut SDP to high accuracy for thousands of vertices); the certificate check stays the same.

Test yourself

Why is the vector program a relaxation of max-cut?

  1. Because vectors are longer than numbers
  2. Because unit vectors in R1\mathbb{R}^1 are ±1\pm 1, so every cut is feasible with the same objective value
  3. Because it has fewer constraints
  4. Because it is linear

What does an edge whose vectors are at angle θ\theta contribute to the SDP objective?

  1. θ\theta
  2. 1−cos⁡θ2\frac{1 - \cos\theta}{2}
  3. cos⁡θ\cos\theta
  4. θπ\frac{\theta}{\pi}

What is the SDP value of the 5-cycle?

  1. 4
  2. 5
  3. 52(1+cos⁡π5)≈4.52\frac{5}{2}(1 + \cos\frac{\pi}{5}) \approx 4.52
  4. 5\sqrt{5}