# Min-Cut in a Graph

Let ${\displaystyle G(V,E)}$ be a multi-graph, which allows parallel edges between two distinct vertices ${\displaystyle u}$ and ${\displaystyle v}$ but does not allow any self-loop, i.e. an edge connect a vertex to itself. Such a multi-graph can be represented as data structures like adjacency matrix ${\displaystyle A}$, where ${\displaystyle A}$ is symmetric (undirected graph) with zero diagonal, and each entry ${\displaystyle A(u,v)}$ is a nonnegative integer giving the number of edges between vertices ${\displaystyle u}$ and ${\displaystyle v}$.

A cut in a multi-graph ${\displaystyle G(V,E)}$ is an edge set ${\displaystyle C\subseteq E}$, which can be equivalently defined as

• there exists a nonempty ${\displaystyle S\subset V}$, such that ${\displaystyle C=\{uv\in E\mid u\in S,v\not \in S\}}$; or
• removing of ${\displaystyle C}$ disconnects ${\displaystyle G}$, that is, ${\displaystyle G'(V,E\setminus C)}$ disconnects.

The min-cut or minimum cut problem is defined as follows:

• Input: a multi-graph ${\displaystyle G(V,E)}$;
• Output: a cut ${\displaystyle C}$ in ${\displaystyle G}$ with the minimum size ${\displaystyle |C|}$.

The problem itself is well-defined on simple graph (without parallel edges), and our main goal is indeed solving the min-cut in simple graphs, however, as we shall see the algorithm creates parallel edges during its running, even though we start with a simple graph without parallel edges.

A canonical deterministic algorithm for this problem is through the max-flow min-cut theorem. A global minimum cut is the minimum ${\displaystyle s}$-${\displaystyle t}$ min-cut, which is equal to the minimum ${\displaystyle s}$-${\displaystyle t}$ max-flow.

## Karger's Min-Cut Algorithm

We will introduce a very simple and elegant algorithm discovered by David Karger.

We define an operation on multi-graphs called contraction: For a multigraph ${\displaystyle G(V,E)}$, for any edge ${\displaystyle uv\in E}$, let ${\displaystyle contract(G,uv)}$ be a new multigraph obtained by:

• replacing the vertices ${\displaystyle u}$ and ${\displaystyle v}$ by a new vertex ${\displaystyle x\not \in V}$;
• for each ${\displaystyle w\not \in \{u,v\}}$ replacing any edge ${\displaystyle uw}$ or ${\displaystyle vw}$ by the edge ${\displaystyle xw}$;
• removing all parallel edges between ${\displaystyle u}$ and ${\displaystyle v}$ in ${\displaystyle E}$;
• the rest of the graph remains unchanged.

To conclude, the ${\displaystyle contract(G,uv)}$ operation merges the two vertices ${\displaystyle u}$ and ${\displaystyle v}$ into a new vertex which maintains the old neighborhoods of both ${\displaystyle u}$ and ${\displaystyle v}$ except for that all the parallel edges between ${\displaystyle u}$ and ${\displaystyle v}$ are removed.

Perhaps a better way to look at contraction is to interpret it as union of equivalent classes of vertices. Initially every vertex is in a dinstinct equivalent class. Upon call a ${\displaystyle contract(G,uv)}$, the two equivalent classes corresponding to ${\displaystyle u}$ and ${\displaystyle v}$ are unioned together, and only those edges crossing between different equivalent classes are counted as valid edges in the graph.

 RandomContract (Karger 1993) while ${\displaystyle |V|>2}$ do choose an edge ${\displaystyle uv\in E}$ uniformly at random; ${\displaystyle G=contract(G,uv)}$; return ${\displaystyle C=E}$ (the parallel edges between the only remaining vertices in ${\displaystyle V}$);

A multi-graph can be maintained by appropriate data strucrtures such that each contraction takes ${\displaystyle O(n)}$ time, where ${\displaystyle n}$ is the number of vertices, so the algorithm terminates in time ${\displaystyle O(n^{2})}$. We leave this as an exercise.

## Analysis of accuracy

For convenience, we assume that each edge has a unique "identity" ${\displaystyle e}$. And when an edge ${\displaystyle uv\in E}$ is contracted to new vertex ${\displaystyle x}$, and each adjacent edge ${\displaystyle uw}$ of ${\displaystyle u}$ (or adjacent edge ${\displaystyle vw}$ of ${\displaystyle v}$) is replaced by ${\displaystyle xw}$, the identity ${\displaystyle e}$ of the edge ${\displaystyle uw}$ (or ${\displaystyle vw}$) is transfered to the new edge ${\displaystyle xw}$ replacing it. When referring a cut ${\displaystyle C}$, we consider ${\displaystyle C}$ as a set of edge identities ${\displaystyle e}$, so that a cut ${\displaystyle C}$ is changed by the algorithm only if some of its edges are removed during contraction.

We first prove some lemma.

 Lemma 1 If ${\displaystyle C}$ is a cut in a multi-graph ${\displaystyle G}$ and ${\displaystyle e\not \in C}$, then ${\displaystyle C}$ is still a cut in ${\displaystyle G'=contract(G,e)}$.
Proof.
 It is easy to verify that ${\displaystyle C}$ is a cut in ${\displaystyle G'=contract(G,e)}$ if none of its edges is lost during the contraction. Since ${\displaystyle C}$ is a cut in ${\displaystyle G(V,E)}$, there exists a nonempty vertex set ${\displaystyle S\subset V}$ and its complement ${\displaystyle {\bar {S}}=V\setminus S}$ such that ${\displaystyle C=\{uv\mid u\in S,v\in {\bar {S}}\}}$. And if ${\displaystyle e\not \in C}$, it must hold that either ${\displaystyle e\in G[S]}$ or ${\displaystyle e\in G[{\bar {S}}]}$ where ${\displaystyle G[S]}$ and ${\displaystyle G[{\bar {S}}]}$ are the subgraphs induced by ${\displaystyle S}$ and ${\displaystyle {\bar {S}}}$ respectively. In both cases none of edges in ${\displaystyle C}$ is removed in ${\displaystyle G'=contract(G,e)}$.
${\displaystyle \square }$
 Lemma 2 The size of min-cut in ${\displaystyle G'=contract(G,e)}$ is at least as large as the size of min-cut in ${\displaystyle G}$, i.e. contraction never reduces the size of min-cut.
Proof.
 Note that every cut in the contracted graph ${\displaystyle G'}$ is also a cut in the original graph ${\displaystyle G}$.
${\displaystyle \square }$
 Lemma 3 If ${\displaystyle C}$ is a min-cut in a multi-graph ${\displaystyle G(V,E)}$, then ${\displaystyle |E|\geq {\frac {|V||C|}{2}}}$.
Proof.
 It must hold that the degree of each vertex ${\displaystyle v\in V}$ is at least ${\displaystyle |C|}$, or otherwise the set of adjacent edges of ${\displaystyle v}$ forms a cut which separates ${\displaystyle v}$ from the rest of ${\displaystyle V}$ and has size less than ${\displaystyle |C|}$, contradicting the assumption that ${\displaystyle |C|}$ is a min-cut. And the bound ${\displaystyle |E|\geq {\frac {|V||C|}{2}}}$ follows directly from the fact that every vertex in ${\displaystyle G}$ has degree at least ${\displaystyle |C|}$.
${\displaystyle \square }$

For a multigraph ${\displaystyle G(V,E)}$, fixed a minimum cut ${\displaystyle C}$ (there might be more than one minimum cuts), we analyze the probability that ${\displaystyle C}$ is returned by the above algorithm.

Initially ${\displaystyle |V|=n}$. We say that the min-cut ${\displaystyle C}$ "survives" a random contraction if none of the edges in ${\displaystyle C}$ is chosen to be contracted. After ${\displaystyle (i-1)}$ contractions, denote the current multigraph as ${\displaystyle G_{i}(V_{i},E_{i})}$. Supposed that ${\displaystyle C}$ survives the first ${\displaystyle (i-1)}$ contractions, according to Lemma 1 and 2, ${\displaystyle C}$ must be a minimum cut in the current multi-graph ${\displaystyle G_{i}}$. Then due to Lemma 3, the current edge number is ${\displaystyle |E_{i}|\geq |V_{i}||C|/2}$. Uniformly choosing an edge ${\displaystyle e\in E_{i}}$ to contract, the probability that the ${\displaystyle i}$th contraction contracts an edge in ${\displaystyle C}$ is given by:

{\displaystyle {\begin{aligned}\Pr _{e\in E_{i}}[e\in C]&={\frac {|C|}{|E_{i}|}}&\leq |C|\cdot {\frac {2}{|V_{i}||C|}}&={\frac {2}{|V_{i}|}}.\end{aligned}}}

Therefore, conditioning on that ${\displaystyle C}$ survives the first ${\displaystyle (i-1)}$ contractions, the probability that ${\displaystyle C}$ survives the ${\displaystyle i}$th contraction is at least ${\displaystyle 1-2/|V_{i}|}$. Note that ${\displaystyle |V_{i}|=n-i+1}$, because each contraction decrease the vertex number by 1.

The probability that no edge in the minimum cut ${\displaystyle C}$ is ever contracted is:

{\displaystyle {\begin{aligned}&\quad \,\prod _{i=1}^{n-2}\Pr[\,C{\mbox{ survives all }}(n-2){\mbox{ contractions }}]\\&=\prod _{i=1}^{n-2}\Pr[\,C{\mbox{ survives the }}i{\mbox{-th contraction}}\mid C{\mbox{ survives the first }}(i-1){\mbox{-th contractions}}]\\&\geq \prod _{i=1}^{n-2}\left(1-{\frac {2}{|V_{i}|}}\right)\\&=\prod _{i=1}^{n-2}\left(1-{\frac {2}{n-i+1}}\right)\\&=\prod _{k=3}^{n}{\frac {k-2}{k}}\\&={\frac {2}{n(n-1)}}.\end{aligned}}}

This gives the following theorem.

 Theorem For any multigraph with ${\displaystyle n}$ vertices, the RandomContract algorithm returns a minimum cut with probability at least ${\displaystyle {\frac {2}{n(n-1)}}}$.

Run RandomContract independently for ${\displaystyle n(n-1)/2}$ times and return the smallest cut returned. The probability that a minimum cut is found is at least:

{\displaystyle {\begin{aligned}1-\Pr[{\mbox{failed every time}}]&=1-\Pr[{RandomContract}{\mbox{ fails}}]^{n(n-1)/2}\\&\geq 1-\left(1-{\frac {2}{n(n-1)}}\right)^{n(n-1)/2}\\&\geq 1-{\frac {1}{e}}.\end{aligned}}}

A constant probability!

## A Corollary by the Probabilistic Method

Karger's algorithm and its analysis implies the following combinatorial theorem regarding the number of distinct minimum cuts in a graph.

 Corollary For any graph ${\displaystyle G(V,E)}$ of ${\displaystyle n}$ vertices, the number of distinct minimum cuts in ${\displaystyle G}$ is at most ${\displaystyle {\frac {n(n-2)}{2}}}$.
Proof.
 For each minimum cut ${\displaystyle C}$ in ${\displaystyle G}$, we define ${\displaystyle {\mathcal {E}}_{C}}$ to be the event that RandomContract returns ${\displaystyle C}$. Due to the analysis of RandomContract, ${\displaystyle \Pr[{\mathcal {E}}_{C}]\geq {\frac {2}{n(n-1)}}}$. The events ${\displaystyle {\mathcal {E}}_{C}}$ are mutually disjoint for distinct ${\displaystyle C}$ and the event that RandomContract returns a min-cut is the disjoint union of ${\displaystyle {\mathcal {E}}_{C}}$ over all min-cut ${\displaystyle C}$. Therefore, {\displaystyle {\begin{aligned}&\Pr[{\mbox{ RandomContract returns a min-cut}}]\\=&\sum _{{\mbox{min-cut }}C{\mbox{ in }}G}\Pr[{\mathcal {E}}_{C}]\\\geq &\sum _{{\mbox{min-cut }}C{\mbox{ in }}G}{\frac {2}{n(n-1)}},\end{aligned}}} which must be no greater than 1 for a well-defined probability space. This means the total number of min-cut in ${\displaystyle G}$ must be no greater than ${\displaystyle {\frac {n(n-1)}{2}}}$.
${\displaystyle \square }$

Note that the statement of this theorem has no randomness at all, however the proof involves a randomized algorithm. This is an example of the probabilistic method.

## Fast Min-Cut

In the analysis of RandomContract, we have the following observation:

• The probability of success is only getting worse when the graph becomes small.

This motivates us to consider the following alternation to the algorithm: first using random contractions to reduce the number of vertices to a moderately small number, and then recursively finding a min-cut in this smaller instance. This seems just a restatement of exactly what we have been doing. Inspired by the idea of boosting the accuracy via independent repetition, here we apply the recursion on two smaller instances generated independently.

The algorithm obtained in this way is called FastCut. We first define a procedure to randomly contract edges until there are ${\displaystyle t}$ number of vertices left.

 RandomContract${\displaystyle (G,t)}$ while ${\displaystyle |V|>t}$ do choose an edge ${\displaystyle uv\in E}$ uniformly at random; ${\displaystyle G=contract(G,uv)}$; return ${\displaystyle G}$;

The FastCut algorithm is recursively defined as follows.

 FastCut${\displaystyle (G)}$ if ${\displaystyle |V|\leq 6}$ then return a mincut by brute force; else let ${\displaystyle t=\left\lceil 1+|V|/{\sqrt {2}}\right\rceil }$; ${\displaystyle G_{1}=RandomContract(G,t)}$; ${\displaystyle G_{2}=RandomContract(G,t)}$; return the smaller one of ${\displaystyle FastCut(G_{1})}$ and ${\displaystyle FastCut(G_{2})}$;

As before, all ${\displaystyle G}$ are multigraphs.

Let ${\displaystyle C}$ be a min-cut in the original multigraph ${\displaystyle G}$. By the same analysis as in the case of RandomContract, we have

{\displaystyle {\begin{aligned}&\Pr[C{\text{ survives all contractions in }}RandomContract(G,t)]\\=&\prod _{i=1}^{n-t}\Pr[C{\text{ survives the }}i{\text{-th contraction}}\mid C{\text{ survives the first }}(i-1){\text{-th contractions}}]\\\geq &\prod _{i=1}^{n-t}\left(1-{\frac {2}{n-i+1}}\right)\\=&\prod _{k=t+1}^{n}{\frac {k-2}{k}}\\=&{\frac {t(t-1)}{n(n-1)}}.\end{aligned}}}

When ${\displaystyle t=\left\lceil 1+n/{\sqrt {2}}\right\rceil }$, this probability is at least ${\displaystyle 1/2}$.

We use ${\displaystyle p(n)}$ to denote the probability that ${\displaystyle C}$ is returned by ${\displaystyle FastCut(G)}$, where ${\displaystyle G}$ is a multigraph of ${\displaystyle n}$ vertices. We then have the following recursion for ${\displaystyle p(n)}$.

{\displaystyle {\begin{aligned}p(n)&=\Pr[C{\text{ is returned by }}{\textit {FastCut}}(G)]\\&=1-\left(1-\Pr[C{\text{ survives in }}G_{1}\wedge C={\textit {FastCut}}(G_{1})]\right)^{2}\\&=1-\left(1-\Pr[C{\text{ survives in }}G_{1}]\Pr[C={\textit {FastCut}}(G_{1})\mid C{\text{ survives in }}G_{1}]\right)^{2}\\&\geq 1-\left(1-{\frac {1}{2}}p\left(\left\lceil 1+n/{\sqrt {2}}\right\rceil \right)\right)^{2},\end{aligned}}}

where the last inequality is due to the fact that ${\displaystyle \Pr[C{\text{ survives all contractions in }}RandomContract(G,t)]\geq 1/2}$ and our previous discussions in the analysis of RandomContract that if the min-cut ${\displaystyle C}$ survives all first ${\displaystyle (n-t)}$ contractions then ${\displaystyle C}$ must be a min-cut in the remaining multigraph.

The base case is that ${\displaystyle p(n)=1}$ for ${\displaystyle n\leq 6}$. Solving this recursion of ${\displaystyle p(n)}$ (or proving by induction) gives us that

${\displaystyle p(n)=\Omega \left({\frac {1}{\log n}}\right).}$

Recall that we can implement an edge contraction in ${\displaystyle O(n)}$ time, thus it is easy to verify the following recursion of time complexity:

${\displaystyle T(n)=2T\left(\left\lceil 1+n/{\sqrt {2}}\right\rceil \right)+O(n^{2}),}$

where ${\displaystyle T(n)}$ denotes the running time of ${\displaystyle FastCut(G)}$ on a multigraph ${\displaystyle G}$ of ${\displaystyle n}$ vertices.

Solving the recursion of ${\displaystyle T(n)}$ with the base case ${\displaystyle T(n)=O(1)}$ for ${\displaystyle n\leq 6}$, we have ${\displaystyle T(n)=O(n^{2}\log n)}$.

Therefore, for a multigraph ${\displaystyle G}$ of ${\displaystyle n}$ vertices, the algorithm ${\displaystyle FastCut(G)}$ returns a min-cut in ${\displaystyle G}$ with probability ${\displaystyle \Omega \left({\frac {1}{\log n}}\right)}$ in time ${\displaystyle O(n^{2}\log n)}$. Repeat this independently for ${\displaystyle O(logn)}$ times, we have an algorithm which runs in time ${\displaystyle O(n^{2}\log ^{2}n)}$ and returns a min-cut with probability ${\displaystyle 1-O(1/n)}$, a high probability.