Short answer: Karger’s algorithm finds a global minimum cut of an undirected multigraph by randomly contracting edges until two supernodes remain. The edges between those two supernodes are a cut, and each run returns the minimum cut with probability at least 1/binom(n, 2), about 2/n². Repeating O(n² log n) independent runs and keeping the lightest cut raises the failure probability below 1/n. One run is O(E) with a suitable graph representation, or O(n²) in the usual adjacency form.
What the problem actually asks
A global min-cut is a partition of the vertices into two nonempty sides with as few edges across as possible. It is not an s-t cut for a designated pair, and it is not a spanning tree. Flows compute an s-t cut. Karger’s observation is that a random contraction keeps every edge of a fixed min-cut alive with a probability that is only polynomially small.
Contraction of an edge merges its endpoints and destroys self-loops, while edges to the rest of the graph become parallel edges. Parallel edges matter. The cut value is a count of edges, or a sum of weights if the algorithm is extended carefully. The basic algorithm is unweighted.
What the algorithm guarantees
A single run returns some cut. For any fixed minimum cut, the probability that no contracted edge belonged to it is at least 2/(n(n−1)). Therefore O(n² log n) independent runs include that cut, and hence some minimum cut, with probability at least 1 − 1/n. The algorithm can return a cut that is not minimum on any one run. The repetition is part of the method, not an optional booster.
Fast implementations use Karger–Stein contraction, which stops the random contraction early and recurses twice, improving the repetition count. The basic algorithm’s probability is the one to learn first. Stoer–Wagner computes a global min-cut deterministically. Karger is the randomized existence proof that became an algorithm.
The working steps
- Copy the undirected multigraph. Parallel edges stay parallel. Self-loops are irrelevant and should be dropped.
- While more than two supernodes remain, pick an edge uniformly from the remaining multiset and contract it. Replace the two ends by one supernode, delete self-loops, and keep parallel edges to other supernodes.
- The surviving edges between the last two supernodes form a cut. Record its size.
- Repeat from a fresh copy O(n² log n) times, or a larger constant times that. Keep the smallest cut observed, together with the partition that produced it.
- If edge weights must be handled, contract with probability proportional to weight only in the weighted variant. The unweighted proof picks an edge uniformly.
The probability bound is for one fixed min-cut surviving a uniform random contraction. It does not say one run is probably optimal. It says one run succeeds with probability Ω(1/n²). An s-t minimum cut with capacities belongs to a flow algorithm. A deterministic global min-cut belongs to Stoer-Wagner.
Approaches that look simpler and fail
| Approach | Why it fails when one contraction is treated as the answer |
|---|---|
| Return the first two-supernode cut | That cut is some cut. The success probability of one run is only about 2/n², so a single run is usually not minimum on a large graph. |
| Contract vertices instead of a random edge | Merging a random pair that is not an edge skips the probability proof and can separate a min-cut edge early. |
| Drop parallel edges after contraction | The cut value counts multiplicity. Collapsing parallels undercounts the cut and changes which edge is chosen next. |
| Use the algorithm for an s-t cut and force s and t to stay apart | That modification is a different procedure. The basic probability is for an unrestricted global cut. |
A deterministic global min-cut is Stoer-Wagner. An s-t cut is a maximum flow. Karger–Stein is the recursive contraction schedule that reduces the number of repetitions.
A working example
This Python fragment contracts a random edge and keeps parallel edges, then repeats. The graph is a 4-cycle with one diagonal. Over seeded trials the lightest cut found is the bridge-free min cut of weight 2.
import random
edges = [(0, 1), (1, 2), (2, 3), (3, 0), (0, 2)] # unit weights, min cut 2
def contract_once(rng):
comp = list(range(4))
alive = 4
pool = edges[:]
while alive > 2:
u, v = pool[rng.randrange(len(pool))]
if comp[u] == comp[v]:
continue
survivor, doomed = comp[u], comp[v]
for i in range(4):
if comp[i] == doomed:
comp[i] = survivor
alive -= 1
pool = [(a, b) for a, b in pool if comp[a] != comp[b]]
return len(pool)
best = min(contract_once(random.Random(seed)) for seed in range(40))
assert best == 2
print(best)
Where it is used
Karger’s contractions estimate a global minimum cut of a network by randomly merging vertices. It is a Monte Carlo check of connectivity. Stoer-Wagner is the deterministic min-cut a reliability calculation can cite without a failure probability.
When you can drop this algorithm
Drop basic Karger when a deterministic answer is required and n is small enough for Stoer-Wagner. Keep the repeated contractions when a simple Monte Carlo global min-cut is acceptable and the failure probability is driven down by the O(n² log n) repetitions.
Why this stays published
We publish this so a search for Karger’s algorithm returns the 1/n² success probability of one run and the repetitions that make it reliable. Karger’s algorithm returns a global min-cut by random edge contraction, and one run succeeds with probability only about 2/n², so the algorithm repeats.
本文由 HoHo 與 AI 協作整理,最後更新於 2026 年 11 月 13 日。
