Karger's Algorithm

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,YX,Y which are supernodes, the super edge between them is a set which contains all the edges (x,y)(x, y) such that xX,yYx \in X, y \in Y.

If we had a graph with 4 vertices, and edges

(1,4),(2,4),(3,4)(1, 4), (2, 4), (3, 4)

We could define 2 supernodes

X={1,2,3}Y={4}\begin{aligned} X &= \{1, 2, 3\}\\ Y &= \{4\} \end{aligned}

The superedge between XX and YY is then defined as

EXY={(u,v)uX,vY}E_{XY} = \{(u, v) | u \in X, v \in Y\}

Algorithm

Karger’s algorithm roughly works as follows -

  1. While the number of supernodes >2> 2, pick an edge, and merge the two end points of that edge.
  2. Output the remaining superedge when #supernodes=2\#\text{supernodes} = 2

An example of how the merges happen in Karger's Algorithm 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,
Γ\Gamma : Set of supernodes
FF : Set of superedges
V(U)V(U) : nodes in supernode(n)
vˉ\bar v : supernode containing vv

Initially ΓV,FE\Gamma \leftarrow V, F \leftarrow E
Merge(a,b,Γ)\text{Merge}(a, b, \Gamma)
Suppose we want to merge a,bΓa, b \in \Gamma

  1. xx \leftarrow new empty supernode
  2. V(x)V(a)V(b)V(x) \leftarrow V(a) \cup V(b)
  3. For each dΓ\{a,b}d \in \Gamma \backslash \{a, b\}, EdxEdaEdbE_{dx} \leftarrow E_{da} \cup E_{db}
  4. Γ(Γ\{a,b}){x}\Gamma \leftarrow (\Gamma \backslash \{a, b\}) \cup \{x\}

Karger(G(V,E))\text{Karger}(G(V, E))

  1. Initialize (Γ,E)(\Gamma, E)
  2. While Γ>2|\Gamma| > 2
    1. Pick an edge ee from FF randomly.
    2. ΓMerge(uˉ,vˉ,Γ)\Gamma \leftarrow \text{Merge}(\bar u, \bar v, \Gamma)
    3. FF\Euˉ,vˉF \leftarrow F \backslash E_{\bar u, \bar v}
  3. Return the only superedge

Karger’s algorithm states that the superedge is definitely a cut, and a min cut with some probability.

Claim: If kk is the min cut size then GG has at least kn2\frac{kn}{2} edges.
We know that if kk is the min cut size, then the min degree of any node is kk.
If there is some node of degree k1k - 1 or lesser, we could just remove all the edges incident on it to make it disconnected, achieving a min cut less than kk.

Now, we can get a lower bound on the number of edges.

#Edgesminimum degreen2\#\text{Edges} \geq \frac{\text{minimum degree} * n}{2}

(The min degree doesn’t have to be exactly kk 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 n2\leq n - 2 as each merge reduces the number of supernodes by 11.
Hence, the time complexity is O(n(union+set union))O(n \cdot (|\text{union}| + |\text{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.

EiE_{i} - Event that an edge from the mincut does not get contracted in the iith iteration. 1in21 \leq i \leq n - 2
If it’s a connected graph, it’ll need n2n - 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=1n2Ei\cap_{i=1}^{n-2} E_{i}

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)

Hence, we want to find

Pr[i=1n2Ei]=Pr[E1]×Pr[E2E1]××Pr[En2j=1n3Ej]Pr[\cap_{i = 1}^{n - 2} E_{i}] = Pr[E_{1}] \times Pr[E_{2}| E_{1}] \times \dots \times Pr[E_{n-2} | \cap_{j=1}^{n - 3} E_{j}]
Pr[E1]=EkE1kkn2=12nPr[E_{1}] = \frac{|E| - k}{|E|} \geq 1 - \frac{k}{\frac{kn}{2}} = 1 - \frac{2}{n}
Pr[E2E1]=F1kF112n1Pr[E_2 | E_{1}]= \frac{|F_{1}|- k}{|F_{1}|} \geq 1 - \frac{2}{n - 1}

Now, we claim that

Pr[Eij=1i1Ej]12n(i1)Pr[E_{i}| \cap_{j=1}^{i-1}E_{j}]\geq 1 - \frac{2}{n - (i - 1)}

Say the first iteration E1E_{1} occurs. After this, the number of nodes in the graph is n1n - 1, hence the minimum number of edges in the graph is k(n1)2\frac{k(n - 1)}{2} now. Making this generalized, just before EiE_{i} occurs, there will be n(i1)n - (i - 1) vertices in the graph, implying that there are at least k(n(i1))2\frac{k(n - (i - 1))}{2} edges, which leads to

EjkEj=12nj+1\frac{|E_{j}| - k}{|E_{j}|} = 1 - \frac{2}{n - j + 1}

This would give us

Pr[i=1n2Ei]i=1n2(12n(i1))=i=1n2(ni1ni+1)=2n(n1)Pr[\cap_{i=1}^{n-2} E_{i}] \geq \prod_{i=1}^{n-2}\left(1 - \frac{2}{n - (i - 1)}\right) = \prod_{i=1}^{n-2} \left(\frac{n - i - 1}{n - i + 1}\right) = \frac{2}{n (n - 1)}

Boosting Success Probability

  • Say we run a random experiment ss times independently, and the probability that it gives the correct answer is pp.
  • Probability that none of the ss trials give me the correct answer is (1p)s(1 - p)^s. Therefore with probability of 1(1p)s1 - (1 - p)^{s}, the algorithm gives us the correct answer.

In the case of mincut, p=1n2p = \frac{1}{n^{2}}
Therefore, the probability of all failing is

(1p)s(11n2)sesn2\leq (1 - p)^ {s}\leq \left(1 - \frac{1}{n^{2}}\right)^{s} \approx e^{-\frac{s}{n^{2}}}

If sn2s \approx n^{2}, then

1e11 - e^{-1}

Therefore the total time complexity is the time taken to run one instance of Karger’s algorithm, into ss, the number of times we run Karger’s.
Hence, we get

Ts=nmergen2=n3mergeT \cdot s = n \cdot |\text{merge}| \cdot n^{2} = n^{3}\cdot |\text{merge}|

Theorem: With probability 1esn21 - e^{-\frac{s}{n^2}} and in running time s(nmerge)s \cdot (n \cdot | \text{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

Ekn2|E| \geq \frac{kn}{2}

doesn’t hold anymore. Hence, we can’t use the same error bound for the weighted flows problem.

Published Feb 2, 2023