高级算法 (Fall 2016)/Min-Cut and Max-Cut
Contents
Graph Cut
Let be an undirected graph. A subset of edges is a cut of graph if becomes disconnected after deleting all edges in .
More restrictively, we consider the cuts which disconnect a subset of vertices from the rest of the graph.
A pair of disjoint subsets of vertices is called a bipartition of if and are not empty and .
Given a bipartition of , a cut is given by
- ,
where is defined as
which represents the set of "crossing edges" with one endpoint in each of and .
Given a graph , there might be many cuts in , and we are interested in finding the minimum or maximum cut.
Min-Cut
The min-cut problem, also called the global minimum cut problem, is defined as follows.
Min-cut problem - Input: an undirected graph ;
- Output: a cut in with the smallest size .
Equivalently, the problem asks to find a bipartition of into disjoint non-empty subsets and that minimizes .
We consider the problem in a slightly more generalized setting, where the input graphs can be multi-graphs, meaning that there could be multiple edges between two vertices and . We call such edges the parallel edges. The cuts in multi-graphs are defined in the same way as before, and the cost of a cut is given by the total number of edges (including parallel edges) in . Equivalently, one may think of a multi-graph as a graph with integer edge weights, and the cost of a cut is the total weights of all edges in .
A canonical deterministic algorithm for this problem is through the max-flow min-cut theorem. The max-flow algorithm finds us a minimum - cut, which disconnects a source from a sink , both specified as part of the input. A global min cut can be found by exhaustively finding the minimum - cut for an arbitrarily fixed source and all possible sink . This takes max-flow time where is the number of vertices.
The fastest known deterministic algorithm for the minimum cut problem on multi-graphs is the Stoer–Wagner algorithm, which achieves an time complexity where is the total number of edges (counting the parallel edges).
If we restrict the input to be simple graphs (meaning there is no parallel edges) with no edge weight, there are better algorithms. The most recent one was published in STOC 2015, achieving a near-linear (in the number of edges) time complexity.
Karger's Contraction algorithm
We will describe a simple and elegant randomized algorithm for the min-cut problem. The algorithm is due to David Karger.
Let be a multi-graph, which allows more than one parallel edges between two distinct vertices and but does not allow any self-loops: the edges that adjoin a vertex to itself. A multi-graph can be represented by an adjacency matrix , in the way that each non-diagonal entry takes nonnegative integer values instead of just 0 or 1, representing the number of parallel edges between and in , and all diagonal entries (since there is no self-loop).
Given a multi-graph and an edge , we define the following contraction operator Contract(, ), which transform to a new multi-graph.
The contraction operator Contract(, ) - say :
- replace by a new vertex ;
- for every edge (no matter parallel or not) in the form of or that connects one of to a vertex in the graph other than , replace it by a new edge ;
- the reset of the graph does not change.
- say :
In other words, the merges the two vertices and into a new vertex whose incident edges preserves the edges incident to or in the original graph except for the parallel edges between them. Now you should realize why we consider multi-graphs instead of simple graphs, because even if we start with a simple graph without parallel edges, the contraction operator may create parallel edges.
The contraction operator is illustrated by the following picture:
Karger's algorithm uses a simple idea:
- At each step we randomly select an edge in the current multi-graph to contract until there are only two vertices left.
- The parallel edges between these two remaining vertices must be a cut of the original graph.
- We return this cut and hope that with good chance this gives us a minimum cut.
The following is the pseudocode for Karger's algorithm.
RandomContract (Karger 1993) - Input: multi-graph ;
- while do
- choose an edge uniformly at random;
- ;
- return (the parallel edges between the only two vertices in );
Another way of looking at the contraction operator Contract(,) is that we are dealing with classes of vertices. Let be the set of all vertices. We start with vertex classes with each class contains one vertex. By calling , where and for distinct , we take union of and . The edges in the contracted multi-graph are the edges that cross between different vertex classes.
This view of contraction is illustrated by the following picture:
The following claim is left as an exercise for the class:
- With suitable choice of data structures, each operation can be implemented within running time where is the number of vertices.
In the above RandomContract algorithm, there are precisely contractions. Therefore, we have the following time upper bound.
Theorem - For any multigraph with vertices, the running time of the RandomContract algorithm is .
We emphasize that it's the time complexity of a "single running" of the algorithm: later we will see we may need to run this algorithm for many times to guarantee a desirable accuracy.
Analysis of accuracy
We now analyze the performance of the above algorithm. Since the algorithm is randomized, its output cut is a random variable even when the input is fixed, so the output may not always be correct. We want to give a theoretical guarantee of the chance that the algorithm returns a correct answer on an arbitrary input.
More precisely, on an arbitrarily fixed input multi-graph , we want to answer the following question rigorously:
To answer this question, we prove a stronger statement: for arbitrarily fixed input multi-graph and a particular minimum cut in ,
Obviously this will imply the previous lower bound for because the event in implies the event in .
- In above argument we use the simple law in probability that if , i.e. event implies event .
We introduce the following notations:
- Let denote the sequence of random edges chosen to contract in a running of RandomContract algorithm.
- Let denote the original input multi-graph. And for , let be the multigraph after th contraction.
Obviously are random variables, and they are the only random choices used in the algorithm: meaning that they along with the input , uniquely determine the sequence of multi-graphs in every iteration as well as the final output.
We now compute the probability by decompose it into more elementary events involving . This is due to the following proposition.
Proposition 1 - If is a minimum cut in a multi-graph and , then is still a minimum cut in the contracted graph .
Proof. We first observe that contraction will never create new cuts: every cut in the contracted graph must also be a cut in the original graph .
We then observe that a cut in "survives" in the contracted graph if and only if the contracted edge .
Both observations are easy to verify by the definition of contraction operator (in particular, easier to verify if we take the vertex class interpretation). The detailed proofs are left as an exercise.
Recall that denote the sequence of random edges chosen to contract in a running of RandomContract algorithm.
By Proposition 1, the event is equivalent to the event . Therefore:
The last equation is due to the so called chain rule in probability.
- The chain rule, also known as the law of progressive conditioning, is the following proposition: for a sequence of events (not necessarily independent) ,
- .
- It is a simple consequence of the definition of conditional probability. By definition of conditional probability,
- ,
- and equivalently we have
- .
- Recursively apply this to we obtain the chain rule.
Back to the analysis of probability .
Now our task is to give lower bound to each . The condition means the min-cut survives all first contractions , which due to Proposition 1 means that is also a min-cut in the multi-graph obtained from applying the first contractions.
Then the conditional probability is the probability that no edge in is hit when a uniform random edge in the current multi-graph is chosen assuming that is a minimum cut in the current multi-graph. Intuitively this probability should be bounded from below, because as a min-cut should be sparse among all edges. This intuition is justified by the following proposition.
Proposition 2 - If is a min-cut in a multi-graph , then .
Proof. - It must hold that the degree of each vertex is at least , or otherwise the set of edges incident to forms a cut of size smaller than which separates from the rest of the graph, contradicting that is a min-cut. And the bound follows directly from applying the handshaking lemma to the fact that every vertex in has degree at least .
Let and denote the vertex set and edge set of the multi-graph respectively, and recall that is the multi-graph obtained from applying first contractions. Obviously . And due to Proposition 2, if is still a min-cut in .
The probability can be computed as
where the inequality is due to Proposition 2.
We now can put everything together. We arbitrarily fix the input multi-graph and any particular minimum cut in .
This gives us the following theorem.
Theorem - For any multigraph with vertices, the RandomContract algorithm returns a minimum cut with probability at least .
At first glance this seems to be a miserable chance of success. However, notice that there may be exponential many cuts in a graph (because potentially every nonempty subset corresponds to a cut ), and Karger's algorithm effectively reduce this exponential-sized space of feasible solutions to a quadratic size one, an exponential improvement!
We can run RandomContract independently for times and return the smallest cut ever returned. The probability that a minimum cut is found is at least:
Recall that a running of RandomContract algorithm takes time. Altogether this gives us a randomized algorithm running in time and find a minimum cut with high probability.
A Corollary by the Probabilistic Method
The analysis of Karger's algorithm implies the following combinatorial proposition for the number of distinct minimum cuts in a graph.
Corollary - For any graph of vertices, the number of distinct minimum cuts in is at most .
Proof. Let denote the set of all minimum cuts in . For each min-cut , let denote the event " is returned by RandomContract", whose probability is given by
- .
Clearly we have:
- for any distinct , and are disjoint events; and
- the union is precisely the event "a minimum cut is returned by RandomContract", whose probability is given by
- .
Due to the additivity of probability, it holds that
By the analysis of Karger's algorithm, we know . And since is a well defined probability, due to the unitarity of probability, it must hold that . Therefore,
- ,
which means .
Note that the statement of this theorem has no randomness at all, while the proof consists of a randomized procedure. This is an example of the probabilistic method.
Fast Min-Cut
In the analysis of RandomContract algorithm, recall that we lower bound the probability that a min-cut is returned by RandomContract by the following telescopic product:
- .
Here the index corresponds to the th contraction. The factor is decreasing in , which means:
- The probability of success is only getting bad when the graph is getting "too contracted", that is, when the number of remaining vertices is getting 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 number of vertices left.
RandomContract - Input: multi-graph , and integer ;
- while do
- choose an edge uniformly at random;
- ;
- return ;
The FastCut algorithm is recursively defined as follows.
FastCut - Input: multi-graph ;
- if then return a mincut by brute force;
- else let ;
- ;
- ;
- return the smaller one of and ;
As before, all are multigraphs.
Let be a min-cut in the original multigraph . By the same analysis as in the case of RandomContract, we have
When , this probability is at least . The choice of is due to our purpose to make this probability at least . You will see this plays a critical role in the analysis of accuracy below.
We use to denote the probability that is returned by , where is a multigraph of vertices. We then have the following recursion for .
where the last inequality is due to the fact that and our previous discussions in the analysis of RandomContract that if the min-cut survives all first contractions then must be a min-cut in the remaining multigraph.
The base case is that for . By induction it is easy to prove that
Recall that we can implement an edge contraction in time, thus it is easy to verify the following recursion of time complexity:
where denotes the running time of on a multigraph of vertices.
By induction with the base case for , it is easy to verify that .
Theorem - For any multigraph with vertices, the FastCut algorithm returns a minimum cut with probability in time .
At this point, we see the name FastCut is misleading because it is actually slower than the original RandomContract algorithm, only the chance of successfully finding a min-cut is much better (improved from an to an ).
Given any input multi-graph, repeatedly running the FastCut algorithm independently for some times and returns the smallest cut ever returned, we have an algorithm which runs in time and returns a min-cut with probability , i.e. with high probability.
Recall that the running time of best known deterministic algorithm for min-cut on multi-graph is . On dense graph, the randomized algorithm greatly outperforms the best known deterministic algorithm.
Max-Cut
The maximum cut problem, in short the max-cut problem, is defined as follows.
Max-cut problem - Input: an undirected graph ;
- Output: a bipartition of into disjoint subsets and that maximizes .
The problem is a typical MAX-CSP, an optimization version of the constraint satisfaction problem. An instance of CSP consists of:
- a set of variables usually taking values from some finite domain;
- a sequence of constraints (predicates) defined on those variables.
The MAX-CSP asks to find an assignment of values to variables which maximizes the number of satisfied constraints.
In particular, when the variables takes Boolean values and every constraint is a binary constraint in the form of , then the MAX-CSP is precisely the max-cut problem.
Unlike the min-cut problem, which can be solved in polynomial time, the max-cut is known to be NP-hard. Its decision version is among the 21 NP-complete problems found by Karp. This means we should not hope for a polynomial-time algorithm for solving the problem if a famous conjecture in computational complexity is correct. And due to another less famous conjecture in computational complexity, randomization alone probably cannot help this situation either.
We may compromise our goal and allow algorithm to not always find the optimal solution. However, we still want to guarantee that the algorithm always returns a relatively good solution on all possible instances. This notion is formally captured by approximation algorithms and approximation ratio.
Greedy algorithm
A natural heuristics for solving the max-cut is to sequentially join the vertices to one of the two disjoint subsets and to greedily maximize the current number of edges crossing between and .
To state the algorithm, we overload the definition . Given an undirected graph , for any disjoint subsets of vertices, we define
- .
We also assume that the vertices are ordered arbitrarily as .
The greedy heuristics is then described as follows.
GreedyMaxCut - Input: undirected graph ,
- with an arbitrary order of vertices ;
- initially ;
- for
- joins one of to maximize the current (breaking ties arbitrarily);
- Input: undirected graph ,
The algorithm certainly runs in polynomial time.
Without any guarantee of how good the solution returned by the algorithm approximates the optimal solution, the algorithm is only a heuristics, not an approximation algorithm.
Approximation ratio
For now we restrict ourselves to the max-cut problem, although the notion applies more generally.
Let be an arbitrary instance of max-cut problem. Let denote the size of the of max-cut in graph . More precisely,
- .
Let be the size of of the cut returned by the GreedyMaxCut algorithm on input graph .
As a maximization problem it is trivial that for all . To guarantee that the GreedyMaxCut gives good approximation of optimal solution, we need the other direction:
Approximation ratio - We say that the approximation ratio of the GreedyMaxCut algorithm is , or GreedyMaxCut is an -approximation algorithm, for some , if
- for every possible instance of max-cut.
- We say that the approximation ratio of the GreedyMaxCut algorithm is , or GreedyMaxCut is an -approximation algorithm, for some , if
With this notion, we now try to analyze the approximation ratio of the GreedyMaxCut algorithm.
A dilemma to apply this notion in our analysis is that in the definition of approximation ratio, we compare the solution returned by the algorithm with the optimal solution. However, in the analysis we can hardly conduct similar comparisons to the optimal solutions. A fallacy in this logic is that the optimal solutions are NP-hard, meaning there is no easy way to calculate them (e.g. a closed form).
A popular step (usually the first step of analyzing approximation ratio) to avoid this dilemma is that instead of directly comparing to the optimal solution, we compare to an upper bound of the optimal solution (for minimization problem, this needs to be a lower bound), that is, we compare to something which is even better than the optimal solution (which means it cannot be realized by any feasible solution).
For the max-cut problem, a simple upper bound to is , the number of all edges. This is a trivial upper bound of max-cut since any cut is a subset of edges.
Let be the input graph and . Initially . And for , we let and be the respective and after joins one of . More precisely,
- and if ;
- and if otherwise.
Finally, the max-cut is given by
We first observe that we can count the number of edges by summarizing the contributions of individual 's.
Proposition 1 - .
Proof. Note that , i.e. and together contain precisely those vertices preceding . Therefore, by taking the sum
- ,
we effectively enumerate all that and . The total number is precisely .
We then observe that the can be decomposed into contributions of individual 's in the same way.
Proposition 2 - .
Proof. It is east to observe that , i.e. once an edge joins the cut between current it will never drop from the cut in the future.
We then define
to be the contribution of in the final cut.
It holds that
- .
On the other hand, due to the greedy rule:
- and if ;
- and if otherwise;
it holds that
- .
Together the proposition follows.
Combining the above Proposition 1 and Proposition 2, we have
Theorem - The GreedyMaxCut is a -approximation algorithm for the max-cut problem.
This is not the best approximation ratio achieved by polynomial-time algorithms for max-cut.
- The best known approximation ratio achieved by any polynomial-time algorithm is achieved by the Goemans-Williamson algorithm, which relies on rounding an SDP relaxation of the max-cut, and achieves an approximation ratio , where is an irrational whose precise value is given by .
- Assuming the unique game conjecture, there does not exist any polynomial-time algorithm for max-cut with approximation ratio .
Derandomization by conditional expectation
There is a probabilistic interpretation of the greedy algorithm, which may explains why we use greedy scheme for max-cut and why it works for finding an approximate max-cut.
Given an undirected graph , let us calculate the average size of cuts in . For every vertex let be a uniform and independent random bit which indicates whether joins or . This gives us a uniform random bipartition of into and .
The size of the random cut is given by
where is the Boolean indicator random variable that indicates whether event occurs.
Due to linearity of expectation,
Recall that is a trivial upper bound for the max-cut . Due to the above argument, we have
- In above argument we use a few probability propositions.
- linearity of expectation:
- Let be a random vector. Then
- ,
- where are scalars.
- That is, the order of computations of expectation and linear (affine) function of a random vector can be exchanged.
- Note that this property ignores the dependency between random variables, and hence is very useful.
- Let be a random vector. Then
- Expectation of indicator random variable:
- We usually use the notation to represent the Boolean indicator random variable that indicates whether the event occurs: i.e. if event occurs and if otherwise.
- It is easy to see that . The expectation of an indicator random variable equals the probability of the event it indicates.
By above analysis, the average (under uniform distribution) size of all cuts in any graph must be at least . Due to the probabilistic method, in particular the averaging principle, there must exists a bipartition of into and whose cut is of size at least . Then next question is how to find such a bipartition algorithmically.
We still fix an arbitrary order of all vertices as . Recall that each vertex is associated with a uniform and independent random bit to indicate whether joins or . We want to fix the value of one after another to construct a bipartition of such that
- .
We start with the first vertex and its random variable . By the law of total expectation,
There must exist an assignment of such that
- .
We can continuously applying this argument. In general, for any and any particular partial assignment of , by the law of total expectation
There must exist an assignment of such that
By this argument, we can find a sequence of bits which forms a monotone path:
We already know the first step of this monotone path . And for the last step of the monotone path since all random bits have been fixed, a bipartition is determined by the assignment , so the expectation has no effect except just retuning the size of that cut . We found the cut such that .
We translate the procedure of constructing this monotone path of conditional expectation to the following algorithm.
MonotonePath - Input: undirected graph ,
- with an arbitrary order of vertices ;
- initially ;
- for
- joins one of to maximize the average size of cut conditioning on the choices made so far by the vertices ;
- Input: undirected graph ,
We leave as an exercise to verify that the choice of each (to join which one of ) in the MonotonePath algorithm (which maximizes the average size of cut conditioning on the choices made so far by the vertices ) must be the same choice made by in the GreedyMaxCut algorithm (which maximizes the current ).
Therefore, the greedy algorithm for max-cut is actually due to a derandomization of average-case.
Derandomization by pairwise independence
We still construct a random bipartition of into and . But this time the random choices have bounded independence.
For each vertex , we use a Boolean random variable to indicate whether joins and . The dependencies between 's are to be specified later.
By linearity of expectation, regardless of the dependencies between 's, it holds that:
In order to have the average cut as the fully random case, we need . This only requires that the Boolean random variables 's are uniform and pairwise independent instead of being mutually independent.
The pairwise independent random bits can be constructed by at most mutually independent random bits by the following standard routine.
Theorem - Let be mutually independent uniform random bits.
- Let enumerate the nonempty subsets of .
- For each , let
- Then are pairwise independent uniform random bits.
If for each vertex is constructed in this way by at most mutually independent random bits , then they are uniform and pairwise independent, which by the above calculation, it holds for the corresponding bipartition of that
Note that the average is taken over the random choices of (because they are the only random choices used to construct the bipartition ). By the probabilistic method, there must exist an assignment of such that the corresponding 's and the bipartition of indicated by the 's have that
- .
This gives us the following algorithm for exhaustive search in a smaller solution space of size .
Algorithm - Enumerate vertices as ;
- let ;
- for all
- initialize ;
- for
- if then joins ;
- else joins ;
- return the with the smallest ;
The algorithm has approximation ratio 1/2 and runs in polynomial time.