Karger's algorithm
In computer science and graph theory, Karger's algorithm is a randomized algorithm to compute the minimum cut of a connected graph. It was invented by David Karger and first published in 1993.[1]
The idea of the algorithm is based on the concept of contraction of an edge in an undirected graph . Informally speaking, the contraction of an edge merges the nodes and into one, reducing the total number of nodes of the graph by one. All other edges connecting either or are "reattached" to the merged node, effectively producing a multigraph. Karger's basic algorithm iteratively contracts randomly chosen edges until only two nodes remain; those nodes represent a cut in the original graph. By iterating this basic algorithm a sufficient number of times, a minimum cut can be found with high probability.
The general min-cut problem
This problem is that given an undirected graph , trying to find a partition that divides into a pair of non-empty, disjoint node sets that minimizes the number of crossed edges between and :
Algorithm description
The fundamental operation of Karger’s algorithm is a form of edge contraction. The result of contracting the edge is new node . Every edge or for to the endpoints of the contracted edge is replaced by an edge to the new node. Finally, the contracted nodes and with all their incident edges are removed. In particular, the resulting graph contains no self-loops.
This algorithm works by repeatedly contracting random edges in the graph, until only two nodes remain, at which point there is only a single cut.
procedure contract(): while choose uniformly at random return the only cut in
When the graph is represented using adjacency lists or an adjacency matrix, a single edge contraction operation can be implemented with a linear number of updates to the data structure, for a total running time of . Alternatively, the algorithm can be viewed as the first constructing the minimum spanning tree in a graph where the edges have weights according to a random permutation . Removing the heaviest edge of this tree results in two components that describe a cut. In this way, the algorithm can be implemented like Kruskal’s algorithm in time . The best known implementations use time and space, or time and space, respectively.[2]
Analysis
Proof of correctness
Lemma 1: let k denote the actual result of the min-cut of G, every node in the graph has a degree that is equal or larger than k.
Proof: If there exists a node N in G, whose degree is smaller than k, then select N as on one side and the other nodes on the other side. As a result we get a min-cut which is smaller than k. This is a contradiction. ∎
Theorem: With high probability we can find the min-cut of given graph G by executing Karger's algorithm.
Proof: Let C denote the edge set of minimum k-cut. At each stage. we have n − i node and by Lemma 1 there are at least (n − i)k⁄2 edges. As such, the probability of selecting an edge in C to make a contraction is
In this manner, we have to run n − 2 iterations to reduce a graph of n nodes to a graph of only two nodes with i from 0 to n − 3. Thus, the probability of C surviving after n − 2 iterations is
Therefore, we have at least Ω(1/n2) chances to find the min-cut C in one execution of procedure contract(). Suppose Pr[Failure] indicates that the probability of failing finding the min-cut via executing the inner while loop once. As such if we repeat the procedure T = cn(n − 1)/2 = O(n2) times, the probability of successfully returning C is
Running time
Karger's algorithm is the fastest known minimum cut algorithm, is randomized, and computes a minimum cut with high probability in time O(|V|2 log3|V|). To prove this authors at first mention that contraction of to vertices can be implemented in time. And the running time is . This recurrence is solved by . One run of an algorithm finds a particular minimum cut with probability . Running algorithm times reduce the chance of missing any particular minimum cut to O(1/n2).
- Lemma 2: For each execution of the inner while loop (Line 3–5) of Karger's Basic Algorithm, it takes running time.
Proof: We can represent this graph G by maintaining an adjacency list, which means all edges incident to node v are in a linked list. What is more, we have to construct pointers between the two copies the same edge (u, w) and (w, u). When v and w are contracted, we traverse the adjacency list of v, and for each edge (v, u) find the corresponding edge(u, v) by the pointer and rename it to (u, w). As such, each contraction costs O(n) time and we have to contract n − 2 times, which in total is O(n2).∎
According to the algorithm, we have to repeat the inner while loop of Karger's Basic Algorithm O(n2) times. Hence, with the correctness of Lemma 2, the overall running time is O(n4).
The Karger–Stein's algorithm
This algorithm is developed by David Karger and Clifford Stein. And it is an order of magnitude improvement of the running time compared with Karger's Basic Algorithm.[3]
Before we move forwards to the detailed description, we notice that when we do the contractions until i vertices are left, the probability that C survives is
Algorithm description
Inspired by the formula above, we can find that the less edges that left in this graph, the less chance that C survives. We, therefore, improve the basic algorithm that
INPUT: An undirected graph G = (V, E)
OUTPUT: find the min-cut of G function Karger–Stein's Min-Cut(G): 1, run the Karger's Basic Algorithm to i = n⁄√2 twice getting G1 and G2, 2, recursively run the Karger–Stein's Min-Cut Algorithm on G1 and G2 end function
Running time
Then we can get the probability of min cut survive P(n) (n is the number of vertices) meets this recurrence relation:
Also, we can prove that . and the recurrence relation of running time is
According to the Master Theorem, . Therefore the overall running time is , which is an order of magnitude improvement.
Finding all min-cuts
Theorem: With high probability we can find all min cuts in the running time of .
Proof: Since we know that , therefore after running this algorithm times The probability of missing a specific min-cut is
- .
And there are at most min-cuts, hence the probability of missing ant min-cut is
The probability of failures is considerably small when n is large enough.∎
Improvement bound
To determine a min-cut, one has to touch every edge in the graph at least once, which is time. The Karger–Stein's min-cut algorithm takes the running time of , which is very close to that.
References
- ^ Karger, David (1993). "Global Min-cuts in RNC and Other Ramifications of a Simple Mincut Algorithm". Proc. 4th Annual ACM-SIAM Symposium on Discrete Algorithms.
{{cite conference}}
: Unknown parameter|booktitle=
ignored (|book-title=
suggested) (help) - ^ (Karger 1993)
- ^
Karger, David (1996). "A New Approach to the Minimum Cut Problem". Journal of the ACM. 43 (4): 601–640.
{{cite journal}}
: Unknown parameter|coauthors=
ignored (|author=
suggested) (help)