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 . Edge is cut exactly when , so
Replace each by a unit vector and each product by an inner product:
Vectors in a one-dimensional space are , so every cut is a feasible solution and : it is a relaxation. With and the graph Laplacian (degrees on the diagonal, for each edge), the objective is , and the problem is the SDP
An edge contributes , where 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 the best cut misses one edge (), but vectors can spread the "frustration" evenly. Place in a plane at angle : consecutive vectors are at angle , and after steps the angle closes up (it is a multiple of for odd ). Every edge contributes , so
To prove this is optimal, use the dual SDP: subject to . Weak duality holds because, for feasible and ,
using and the fact that the inner product of two PSD matrices is non-negative. For a cycle (and any vertex-transitive graph) take every ; then . The program checks both sides for .
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 , a certified optimum. The ratio is close to the Goemans-Williamson constant of the next lesson.
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 ; the triangle gives ), 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 , 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 is feasible for every graph, not only for symmetric ones, so weak duality gives
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 , 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 and repeatedly replace each by the unit vector that maximizes its own terms, (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 around or more its local optima are typically global (Boumal, Voroninski and Bandeira, 2016). Whatever it returns can be certified: complementary slackness, , forces , and if this is dual feasible, the vectors are optimal.
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?
- Because vectors are longer than numbers
- Because unit vectors in are , so every cut is feasible with the same objective value
- Because it has fewer constraints
- Because it is linear
What does an edge whose vectors are at angle contribute to the SDP objective?
What is the SDP value of the 5-cycle?
- 4
- 5