learngraphtheory.org

Guest

Sign in to keep your graphs and progress.

Algorithm Selection

Select an algorithm and generate steps to begin visualization

Maximum Cut (Max-Cut) Visualizer

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

Time: O(V(V + E))
Space: O(V + E)
Use Case: Ising models and QUBO, circuit layout, clustering with conflicts, quantum optimisation benchmarks
Showing the example graph for this algorithm.
Algorithm Execution

Select an algorithm and generate steps to begin visualization

About Maximum Cut (Greedy and Local Search)

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.

How it works

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.

Applications

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.

Pseudocode

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 sides

The 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.

Worked example, step by step

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.

  1. A and B. Neither has a placed neighbour, so both go blue. Cut 0.
  2. C to F. C sees A on blue and goes orange, cut 1. D sees B blue and C orange, a tie, and goes blue, cut 2. E sees A and goes orange, cut 3. F sees A and B on blue and E on orange, so it goes orange, cut 5.
  3. G and H. Both see one blue and one orange neighbour and go blue. Cut 7 of 11, at least half as promised.
  4. Local search. D is blue with B, G and H and has only C across: 3 of its edges are uncut. Moving it to orange gains 3 − 1 = 2, cut 9. No other move gains anything.
  5. Exact check. With 8 vertices the 128 splits can all be tried: none beats 9.

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.

Complexity, and where it comes from

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.

When to use Maximum Cut (Greedy and Local Search), and when not to

Approaches to maximum cut and what they guarantee.

AlternativePrefer it whenCost
Random splitA trivial baseline. Each edge is cut with probability 1/2, so half the weight on average.O(n), 1/2 in expectation
Goemans–WilliamsonThe 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

Common pitfalls

  • Confusing it with minimum cut. A minimum cut separates the graph with as little weight as possible and is solved exactly with flows. Maximum cut wants as much weight as possible across and is NP-hard. Same word, opposite difficulty.
  • Taking a local optimum for the best. Local search stops when no single move helps, which can be below the optimum. Here it reaches 9, the true maximum, but on other graphs the page reports a gap. Restart from several random splits on real instances.
  • Using negative weights. With negative weights the half-of-the-weight argument breaks, because cutting a negative edge lowers the total. The visualizer refuses them. Problems with signed weights are usually written as QUBO or correlation clustering instead.

Frequently asked questions

Why is maximum cut hard when minimum cut is easy?
Minimum cut has max-flow min-cut duality, which gives a polynomial algorithm. Maximum cut has no such structure. Karp showed in 1972 that it is NP-complete, and approximating it beyond 16/17 is NP-hard as well.
When can every edge be cut?
Exactly when the graph is bipartite. Then the two colour classes cut every edge. An odd cycle always keeps one edge uncut, which is why the two triangles here limit the cut to 9.
What does maximum cut have to do with physics and quantum computers?
An Ising model assigns each spin +1 or −1, and its antiferromagnetic ground state puts as many coupled spins as possible on opposite sides: a maximum cut. Any QUBO problem can be rewritten the same way, so maximum cut is the standard test for quantum annealers and for QAOA.

Related algorithms: Minimum Cut, Stoer-Wagner Min Cut, Kernighan–Lin Bisection, Bipartite Check, Spectral Partitioning (Fiedler Vector)

Built by Mohammed Islam HadjoudjWork with me

An example graph: you can change it, or start blank.

Zoom Controls

38%
Nodes: 8
Edges: 11