Comp 260: Advanced Algorithms Tufts University, Fall 2021 Prof. Lenore Cowen Scribe: Jun Zhou Lecture 5: Minimum Cut Problem with Parallel Algorithm 1 The Minimum Cut Problem 1.1 Formulation Given a graph G = (V, E), the Minimum Cut (min cut) of G is defined as the partition of the vertex set V into two sets, V1 and V2 where V1 ∩ V2 = ∅, such that the set of edges between them E(V, V) has a minimum size. 2 Non-randomized Min Cut Algorithm Before considering a randomized min cut algorithm, lets review a non-randomized version. The max-flow min-cut theorem (discussed in lecture 2) stated that in a flow network, the maximum amount of flow passing from the source to the sink is equal to the total weight of the edges in a minimum cut, i.e. the smallest total weight of the edges which if removed would disconnect the source from the sink. This enable us to utilized algorithms of max-flow to deal with the min-cut problem. However, we have to pick two nodes as our source s and sink t. To do that, we have to try out every possible combination of s and t. Max flow Algorithm with min cut Algorithm: In a network G = (V, E) with n vertices and m edges: • Fix a source vertex t. 1 • Try all other vertices as the sink vertex t. Find max flow / min cut, return min cut amongst those choices. • Repeat step one and two n − 1 times with different source t, return min cut amongst all. 2.1 Complexity Analysis The max flow / min cut algorithm time (Push–relabel max runs in Õ(mn) n2 imum flow algorithm runs in O mn log m , where Õ(n) is defined as T(n) = O n logk n , where k > 0. If we fix s in one partition and all n choices of t are explored, since m can be O (n2 ), we obtain a running time of O (n4 ). This is very slow. 3 Randomized Min Cut Algorithm In the following section we consider the randomized version. Before that, let’s examine the contraction Algorithm. 3.1 The Contraction Algorithm (Karger’s algorithm) The contraction Algorithm uses one fundamental operation, contraction. To contract two vertices v1 and v2 , we replace them by a vertex v on v1 and v2 Contraction Algorithm. Given a multigraph G = (V, E), repeat the following procedure until just 2 vertices remain: • Pick an edge e ∈ E at random and contract its two endpoints vertices. Then the contraction Algorithm terminates, yielding a graph with two meta-vertices a and b, we have a cut (A, B) where A = s(a) (all vertices that are contracted to a) and B = s(b) (all vertices that are contracted to b). This process can be seen in Fig. 1 . 2 This algorithm may or may not yield the minimum cut. We can analysis the possibility of this algorithm yielding the desired result in G = (V, E) . Lemma 3.1.1. A cut (A, B) is output by the Contraction Algorithm if and only if no edge crossing (A, B) is contracted by the algorithm. Proof. The backward direction is obvious. For the forward direction, consider two vertices on opposite sides of the cut (A, B). If they end up in the same meta-vertex, then there must be a path between them consisting of edges that were contracted. However, any path between them crosses (A, B), so an edge crossing cut (A, B) would have had to be contracted. This contradicts our hypothesis. Theorem 3.1.2. A particular minimum cutin G is returned by the Con−1 traction Algorithm with probability at least n2 = Ω (n−2 ). Proof. Consider on a min cut (A, B) with c crossing edges. By Lemma 3.1.1, we know that if we never selct a num cut edge during the contraction algorithm, then we must end up with a min cut. After each contraction, the min cut of the new graph must still be at least c, since every cut in the contracted graph corresponds to a cut of the same value in original graph, thus at least c. Also, if we contract an edge (v, w) that does not cross (A, B), then the cut (A, B) corresponds to a cut of value c in G/(v, w); this corresponding cut is a min cut in the contracted graph. At each contraction, the number of vertices in the G is reduced by one. Consider the stage when there is r vertices. Since the contracted graph has a min cut value of at least c, the minimum degree of the graph is c. Thus at least cr/2 edges. However, there is only c edges in the min cut. Therefore, the probability that a randomly chosen edge is in the min cut is at most 2/r. The probability that we never contract a min cut edge during the n − 2 contractions is at least 3 2 2 n−2 n−3 2 1 2 1− ··· 1 − = ··· 1− n n−1 3 n n−1 4 3 −1 n = 2 = Ω n−2 (1) Given the above probability that contraction algorithm produces the correct min cut, we can run it many times and take the minimum cut of all of the runs to increase the possibility of finding the correct min cut. Lets say we run contraction algorithm 20n2 times: Pr[ final cut is not the min cut ] = 2 1− 2 n 20n2 < 0.01 In another way, contraction algorithm will produce the real min cut 99% of the time when used in this way. Contraction algorithm does not really improve on previous runtimes of max flow/min cut algorithms, but it is easier to parallelize. However, it turns out that we improve the runtime using the same methods. Let’s examine this variation in the next section below. 3.2 Karger-Stein Randomized Min Cut Notice that by Theorem 3.1.2, we also that probability that a min cut survives down to k vertices is k2 / n2 . The probability that we choose an edge from the min cut goes up when we are further down in the contraction process. This inspires a variation of contraction algorithm where we stop early when there are still l vertices remaining and then recursion. We set l appropriately to optimize the expected running time. 4 Karger-Stein Randomized Min Cut Algorithm for G = (V, E): • If |V | = 6, use traditional Karger’s Algorithm (Contraction Alg.) to find the min cut. • If |V | > 6, do the following independently twice to return min cut. √ – Run Karger’s Algorithm down to |V |/ 2 + 1 vertices to create G1 . √ – Run Karger’s Algorithm down to |V |/ 2 + 1 vertices to create G2 . • Return min(Karger-Stein(G1, G2)). √ When we contract the graph until it has |V |/ 2 + 1 vertices, the probability of not contracting a minimum cut edge is greater than 50%, Therefore, we recursively apply the algorithm to each of the two partially contracted graphs. Lemma 3.2.1. Karger-Stein’s Algorithm runs in O(n2 logn) time. Proof. For each level √ sub√ of recursion, we divide the problem into two problem with |V |/ 2 + 1 vertices. Perform a contraction to |V |/ 2 + 1 vertices can be implemented to take O(n2 ) time. Thus, we obtained our recursion: n 2 T (n) = 2 n + T √ + 1 2 This recursion can be solved with the Master Theorem with the result: T (n) = O(n2 logn) It is important to note that this algorithm still doesn’t guarantee the correct output: 5 Lemma 3.2.2. Karger-Stein’s Algorithm finds a particular minimum cut with probability Ω(1/logn). It is shown by Karger that the probability of success in finding the min cut: 1 P(n) ≥ 1 − 1 − P 2 = Ω(1/ log n) n √ 2+1 2 Due to the time limitation in the lecture, we omitted this part of proof in the lecture. Reader can look up to the original paper to find the detailed proof. Therefore, we can run the Karger-Stein’s Algorithm O(log 2 n) times for a total running time of O(n3 logn). This algorithm therefore is much faster than our original contraction algorithm. 4 4.1 Parallel Algorithm Parallel random-access machine Parallel Random Access Machines (PRAM) is a model, which is considered for most of the parallel algorithms. In PRAM, multiple processors are attached to a single block of memory. 6 In this model, n number of processors can perform independent operations on n number of data in a particular unit of time. This may result in simultaneous access of same memory location by different processors. 4.2 Complexity class NC A language is in the complexity class NC if it can be solved using a deterministic algorithm on a PRAM with a polynomial time (the time is O(logn) for some constant c). 5 Maximal Independent Set Problem In this section we examine the Maximal Independent Set problem. 5.1 Formulation In graph theory, a maximal independent set (MIS) is an independent set that is not a subset of any other independent set. In other words, there is no vertex outside the independent set that may join it because it is maximal with respect to the independent set property. 7 Formally, for a graph G = (V, E), an independent set is a set S ⊂ V which contains no edges of G i.e., for all (u, v) ∈ E either u ∈ / S or v ∈ / S. The independent set S is a maximal independent set if for all v ∈ V , either v ∈ S or N (v) ∩ S 6= ∅ where N (v) denotes the neighbors of v. It is important to note the difference between maximal independent set problem and maximum independent set problem. Maximum independent set problem is a NP-hard problem. It is a special kind of maximal independent set problem where the cardinality of the set the maximum. 8