Karger’s algorithm is a randomized algorithm that solves the Global minimum cut problem.
Terminology
We have 2 new terms, supernodes and superedges Supernode - A set of vertices Superedge - For X,Y which are supernodes, the super edge between them is a set which contains all the edges (x,y) such that x∈X,y∈Y.
If we had a graph with 4 vertices, and edges
(1,4),(2,4),(3,4)
We could define 2 supernodes
XY={1,2,3}={4}
The superedge between X and Y is then defined as
EXY={(u,v)∣u∈X,v∈Y}
Algorithm
Karger’s algorithm roughly works as follows -
While the number of supernodes >2, pick an edge, and merge the two end points of that edge.
Output the remaining superedge when #supernodes=2
In this algorithm, we continue to merge supernodes till the the number of supernodes is 2, and then we take a look at the cardinality of the remaining super edge between the superedges, which is a cut for the graph.
Formally, Γ : Set of supernodes F : Set of superedges V(U) : nodes in supernode(n) vˉ : supernode containing v
Initially Γ←V,F←E Merge(a,b,Γ)
Suppose we want to merge a,b∈Γ
x← new empty supernode
V(x)←V(a)∪V(b)
For each d∈Γ\{a,b}, Edx←Eda∪Edb
Γ←(Γ\{a,b})∪{x}
Karger(G(V,E))
Initialize (Γ,E)
While ∣Γ∣>2
Pick an edge e from F randomly.
Γ←Merge(uˉ,vˉ,Γ)
F←F\Euˉ,vˉ
Return the only superedge
Karger’s algorithm states that the superedge is definitely a cut, and a min cut with some probability.
Claim: If k is the min cut size then G has at least 2kn edges. We know that if k is the min cut size, then the min degree of any node is k.
If there is some node of degree k−1 or lesser, we could just remove all the edges incident on it to make it disconnected, achieving a min cut less than k.
Now, we can get a lower bound on the number of edges.
#Edges≥2minimum degree∗n
(The min degree doesn’t have to be exactly k as it could be higher. For example, two densely connected components connected by one edge)
Time Complexity Analysis of Karger’s
We can see that the number of iterations of step 2 in the above algorithm is ≤n−2 as each merge reduces the number of supernodes by 1.
Hence, the time complexity is O(n⋅(∣union∣+∣set union∣))
Correctness Analysis of Karger’s
If we want this algorithm to return the min cut, we need to ensure that in each of the iterations, the end points of an edge from min-cut shouldn’t be contracted/merged.
Ei− Event that an edge from the mincut does not get contracted in the ith iteration. 1≤i≤n−2 If it’s a connected graph, it’ll need n−2 iterations. If it’s disconnected, then it’ll run in less iterations
For the algorithm to run correctly, all of these events must occur, i.e
∩i=1n−2Ei
We want to find the probability of this occurring.
In this analysis, we’re assuming that we only pick valid edges (i.e edges connecting two different supernodes)
Say the first iteration E1 occurs. After this, the number of nodes in the graph is n−1, hence the minimum number of edges in the graph is 2k(n−1) now. Making this generalized, just before Ei occurs, there will be n−(i−1) vertices in the graph, implying that there are at least 2k(n−(i−1)) edges, which leads to
Say we run a random experiment s times independently, and the probability that it gives the correct answer is p.
Probability that none of the s trials give me the correct answer is (1−p)s. Therefore with probability of 1−(1−p)s, the algorithm gives us the correct answer.
In the case of mincut, p=n21
Therefore, the probability of all failing is
≤(1−p)s≤(1−n21)s≈e−n2s
If s≈n2, then
1−e−1
Therefore the total time complexity is the time taken to run one instance of Karger’s algorithm, into s, the number of times we run Karger’s.
Hence, we get
T⋅s=n⋅∣merge∣⋅n2=n3⋅∣merge∣
Theorem: With probability 1−e−n2s and in running time s⋅(n⋅∣merge∣) min cut can be found.
Weighted Case
We only considered unweighted case, but in flows we usually consider the weighted case. What do we do? We no longer have a bound on the number of edges, but we have a bound on the weight of edges.
Therefore the statement
∣E∣≥2kn
doesn’t hold anymore. Hence, we can’t use the same error bound for the weighted flows problem.