Guest
Sign in to keep your graphs and progress.
Select an algorithm and generate steps to begin visualization
The opposite of a minimum cut, and far harder
Splits the vertices into two sides with as much edge weight between them as possible: a greedy pass and single-vertex moves guarantee at least half
Select an algorithm and generate steps to begin visualization
The maximum cut problem splits the vertices of a graph into two sides so that the total weight of the edges between the sides is as large as possible. Its twin, the minimum cut, is solved in polynomial time with flows, but maximum cut is NP-hard and one of Karp's 21 NP-complete problems from 1972. A bipartite graph can have every edge cut, and each odd cycle forces at least one edge to stay inside a side. Half of the weight is always within reach: a random split cuts half on average, and greedy placement or local search guarantee it. Goemans and Williamson's semidefinite rounding from 1995 reaches 0.878 of the optimum, the best possible ratio if the Unique Games Conjecture holds. On planar graphs the problem is solvable in polynomial time.
The visualizer first places the vertices one by one, each on the side opposite most of its already placed neighbours' weight, so at least half of the weight ends up cut. Then local search moves single vertices to the other side while that raises the cut, the best move first. The sides are blue and orange, cut edges are magenta, and each step writes the weights that decide, for instance F: placed neighbours weigh 2 on blue, 1 on orange. For graphs of up to 18 vertices it also tries every split to compare the result with the true optimum. In the example, 8 vertices and 11 edges, the greedy pass cuts 7, and moving D to the orange side adds 2, giving 9. Trying all 128 splits confirms that 9 is the best, which the two edge-disjoint triangles A, E, F and C, D, G explain: each one keeps at least one edge uncut.
Maximum cut appears wherever things should be split so that conflicts fall between groups: assigning wires to the two layers of a circuit board with as few vias as possible, splitting a dataset into two clusters of dissimilar items, and finding the ground state of an Ising spin glass in statistical physics, which is a maximum cut. Every quadratic unconstrained binary optimisation (QUBO) problem can be written as a maximum cut, so it is the standard benchmark for quantum annealers, coherent Ising machines and the quantum approximate optimisation algorithm QAOA. Neo4j Graph Data Science offers an approximate maximum k-cut that uses the same local moves for k groups.
A greedy pass that guarantees half the weight, then single-vertex moves.
MaxCut(G):
for each vertex v, in order: // greedy
put v on the side opposite most of
its already placed neighbours' weight
repeat: // local search
v = the vertex whose move gains the most
if the gain > 0: move v to the other side
until no move raises the cut
return the two sidesThe greedy guarantee: each edge is decided when its second end is placed, and the vertex goes to the side where at least half of its already decided weight crosses. Summed over all vertices, at least half of all the weight W is cut. Local search keeps that bound: at a local optimum every vertex has at least half of its own weight crossing, and summing over the vertices again gives at least W / 2.
The 8-vertex, 11-edge graph loaded on this page, all weights 1.
Example graph: Edges A–C, A–E, A–F, B–D, B–F, C–D, C–G, D–G, D–H, E–F, E–H. It contains two triangles, A, E, F and C, D, G, that share no edge.
Cut 9 of 11 with sides {A, B, G, H} and {C, D, E, F}. Each of the two disjoint triangles must keep one edge uncut, so 9 is the best possible here, as the exact check confirms.
Time: O(n + m) greedy, O(n + m) per local search move · Space: O(n + m)
The greedy pass looks at each edge once. Each local search round computes every vertex's gain from its own edges, O(n + m) in all, and each move raises the cut, so with integer weights there are at most W moves. The exact check tries 2ⁿ⁻¹ splits at O(m) each, which is why it stops at 18 vertices.
Approaches to maximum cut and what they guarantee.
| Alternative | Prefer it when | Cost |
|---|---|---|
| Random split | A trivial baseline. Each edge is cut with probability 1/2, so half the weight on average. | O(n), 1/2 in expectation |
| Goemans–Williamson | The best guarantee known. Solves a semidefinite program and rounds it with a random hyperplane. | polynomial but heavy, 0.878 |
| Exact solvers (branch and bound, SDP bounds) | The true optimum is needed for graphs of up to a few hundred vertices. | exponential in the worst case |
Related algorithms: Minimum Cut, Stoer-Wagner Min Cut, Kernighan–Lin Bisection, Bipartite Check, Spectral Partitioning (Fiedler Vector)
Built by Mohammed Islam Hadjoudj · Work with me