Chapter 11 Randomized Algorithms III – Min Cut CS 573: Algorithms, Fall 2013 October 1, 2013 11.1 Min Cut 11.1.1 Problem Definition 11.2 Min cut 11.2.0.1 Min cut G = ( V, E ): undirected graph, n vertices, m edges. Interested in cuts in G . S V \ S Definition 11.2.1. cut in G : a partition of V : S and V \ S . Edges of the cut: { � } ( S, V \ S ) = uv � u ∈ S, v ∈ V \ S, and uv ∈ E , � | ( S, V \ S ) | is size of the cut minimum cut / mincut : cut in graph with min size. 11.2.0.2 Some definitions [ ] ( X = x ) ∩ ( Y = y ) Pr [ ] (A) conditional probability of X given Y is Pr X = x | Y = y = . [ ] Y = y Pr [ ] [ � ] Pr ( X = x ) ∩ ( Y = y ) = Pr X = x � Y = y · Pr [ Y = y ] . � 1
[ ] [ ] [ ] (B) X, Y events are independent , if Pr X = x ∩ Y = y = Pr X = x · Pr Y = y . [ � ] [ ] = ⇒ Pr X = x � Y = y = Pr X = x . � 11.2.0.3 Some more probability Lemma 11.2.2. E 1 , . . . , E n : n events (not necessarily independent). Then, [ ] [ ] [ ] [ � ] ∩ n Pr = Pr ∗ Pr E 2 | E 1 ∗ Pr � E 1 ∩ E 2 ∗ . . . i =1 E i E 1 E 3 � [ � ] ∗ Pr � E 1 ∩ . . . ∩ E n − 1 . E n � 11.3 The Algorithm 11.3.0.4 Edge contraction... y { x , y } x G /xy : G : (A) edge contraction : e = xy in G . (B) ... merge x, y into a single vertex. (C) ...remove self loops. (D) ... parallel edges – multi-graph . (E) ... weights/ multiplicities on the edges. 11.3.0.5 Min cut in weighted graph 2 2 2 2 Edge contraction implemented in O ( n ) time: (A) Graph represented using adjacency lists. (B) Merging the adjacency lists of the two vertices being contracted. (C) Using hashing to do fix-ups. (i.e., fix adjacency list of vertices connected to x, y .) (D) Include edge weight in computing cut weight. 11.3.0.6 Cuts under contractions Observation 11.3.1. (A) A cut in G /xy is a valid cut in G . (B) There ∃ cuts in G are not in G /xy . (C) The cut S = { x } is not in G /xy . (D) = ⇒ size mincut in G /xy ≥ mincut in G . (A) Idea : Repeatedly perform edge contractions (benefits: shrink graph)... (B) Every vertex in contracted graph is a connected component in the original graph.) 2
11.3.0.7 Contraction 2 2 2 2 y { x , y } x (2) (3) (4) (5) (7) 2 2 2 2 2 2 4 4 4 2 3 3 2 2 2 2 2 2 5 5 (8) (9) (10) (11) (12) 9 (13) (14) 11.3.0.8 Contraction - all together now 2 2 2 2 2 y x (a) (b) (c) (d) 2 2 2 2 4 4 4 2 2 2 3 3 2 2 2 5 5 (e) (f) (g) (h) 9 (i) (j) 11.3.0.9 But... (A) Not min cut! 3
(B) Contracted wrong edge somewhere... (C) If never contract an edge in the cut... (D) ...get min cut in the end! (E) We might still get min cut even if we contract edge min cut. Why??? 11.3.1 The resulting algorithm 11.3.1.1 The algorithm... Algorithm MinCut ( G ) G 0 ← G i = 0 while G i has more than two vertices do e i ← random edge from E ( G i ) G i +1 ← G i /e i i ← i + 1 Let ( S, V \ S ) be the cut in the original graph corresponding to the single edge in G i return ( S, V \ S ) . 11.3.1.2 How to pick a random edge? Lemma 11.3.2. X = { x 1 , . . . , x n } : elements, ω ( x i ) : integer positive weight. Pick randomly, in O ( n ) time, an element ∈ X , with prob picking x i being ω ( x i ) /W , where W = ∑ n i =1 ω ( x i ) . Proof : Randomly choose r ∈ [0 , W ]. Precompute β i = ∑ i k =1 ω ( x k ) = β i − 1 + ω ( x i ). Find first index i , β i − 1 < r ≤ β i . Return x i . (A) Edges have weight... (B) ...compute total weight of each vertex (adjacent edges). (C) Pick randomly a vertex by weight. (D) Pick random edge adjacent to this vertex. 11.3.2 Analysis 11.3.2.1 The probability of success 11.3.2.2 Lemma... Lemma 11.3.3. G : mincut of size k and n vertices, then | E ( G ) | ≥ kn 2 . Proof : Each vertex degree is at least k , otherwise the vertex itself would form a minimum cut of size smaller than k . As such, there are at least v ∈ V degree(v) / 2 ≥ nk/ 2 edges in the graph. ∑ 11.3.2.3 Lemma... 2 Lemma 11.3.4. If we pick in random an edge e from a graph G , then with probability at most n it belong to the minimum cut. Proof : There are at least nk/ 2 edges in the graph and exactly k edges in the minimum cut. Thus, the probability of picking an edge from the minimum cut is smaller then k/ ( nk/ 2) = 2 /n. 4
11.3.2.4 Lemma 2 Lemma 11.3.5. MinCut outputs the mincut with prob. ≥ n ( n − 1) . Proof (A) E i : event that e i is not in the minimum cut of G i . (B) MinCut outputs mincut if all the events E 0 , . . . , E n − 3 happen. 2 2 � [ ] (C) Pr E i � E 0 ∩ E 1 ∩ . . . ∩ E i − 1 ≥ 1 − | V ( G i ) | = 1 − n − i . � � � � [ ] [ ] [ ] = ⇒ ∆ = Pr [ E 0 ∩ . . . ∩ E n − 3 ] = Pr [ E 0 ] · Pr E 1 � E 0 · Pr E 2 � E 0 ∩ E 1 · . . . · Pr E n − 3 � E 0 ∩ . . . ∩ E n − 4 � � � 11.3.2.5 Proof continued... As such, we have n − 3 n − 3 2 n − i − 2 ( ) ∏ ∏ ∆ ≥ 1 − = n − i n − i i =0 i =0 n − 2 ∗ n − 3 n − 1 ∗ n − 4 n − 2 . . . · 2 4 · 1 = n 3 2 = n · ( n − 1) . 11.3.2.6 Running time analysis. 11.3.2.7 Running time analysis... Observation 11.3.6. MinCut runs in O ( n 2 ) time. Observation 11.3.7. The algorithm always outputs a cut, and the cut is not smaller than the minimum cut. Definition 11.3.8. Amplification : running an experiment again and again till the things we want to happen, with good probability, do happen. 11.3.2.8 Getting a good probability MinCutRep : algorithm runs MinCut n ( n − 1) times and return the minimum cut computed. Lemma 11.3.9. probability MinCutRep fails to return the minimum cut is < 0 . 14 . 2 Proof : MinCut fails to output the mincut in each execution is at most 1 − n ( n − 1) . MinCutRep fails, only if all n ( n − 1) executions of MinCut fail. ) n ( n − 1) ≤ exp = exp( − 2) < 0 . 14 , since 1 − x ≤ e − x for 0 ≤ x ≤ 1. ( ( ) 2 2 1 − − n ( n − 1) · n ( n − 1) n ( n − 1) 11.3.2.9 Result Theorem 11.3.10. One can compute mincut in O ( n 4 ) time with constant probability to get a correct result. In O ( n 4 log n ) time the minimum cut is returned with high probability. 5
11.4 A faster algorithm 11.4.0.10 Faster algorithm Why MinCutRep needs so many executions? Probability of failure in first ν iterations is ν − 1 ν − 1 2 n − i − 2 ( ) [ ] ∏ ∏ Pr E 0 ∩ . . . ∩ E ν − 1 ≥ 1 − = n − i n − i i =0 i =0 = n − 2 ∗ n − 3 n − 1 ∗ n − 4 n − 2 . . . n = ( n − ν )( n − ν − 1) . n · ( n − 1) = ⇒ ν = n/ 2: Prob of success ≈ 1 / 4. ⇒ ν = n − √ n : Prob of success ≈ 1 /n . = 11.4.0.11 Faster algorithm... Insight (A) As the graph get smaller probability for bad choice increases. (B) Currently do the amplification from the outside of the algorithm. (C) Put amplification directly into the algorithm. 11.4.1 Contract... 11.4.1.1 Contract( G, t ) shrinks G till it has only t vertices. FastCut computes the minimum cut using Contract. FastCut ( G = ( V, E ) ) G -- multi-graph begin n ← | V ( G ) | if n ≤ 6 then Contract ( G , t ) Compute minimum cut while | ( G ) | > t do of G and return cut. √ Pick a random edge ⌈ ⌉ t ← 1 + n/ 2 e in G . H 1 ← Contract ( G, t ) G ← G/e H 2 ← Contract ( G, t ) return G /* Contract is randomized!!! */ X 1 ← FastCut ( H 1 ) , X 2 ← FastCut ( H 2 ) return mincut of X 1 and X 2 . end 11.4.1.2 Lemma... Lemma 11.4.1. The running time of FastCut ( G ) is O ( n 2 log n ) , where n = | V ( G ) | . Proof : Well, we perform two calls to Contract ( G, t ) which takes O ( n 2 ) time. And then we perform two recursive calls on the resulting graphs. We have: ( ) T ( n ) = O ( n 2 ) + 2 T n √ 2 The solution to this recurrence is O ( n 2 log n ) as one can easily (and should) verify. 6
11.4.1.3 Success at each step Lemma 11.4.2. Probability that mincut in contracted graph is original mincut is at least 1 / 2 . √ ⌈ ⌉ Proof : Plug in ν = n − t = n − 1 + n/ 2 into success probability: [ ] t ( t − 1) Pr E 0 ∩ . . . ∩ E n − t ≥ n · ( n − 1) √ √ ⌈ ⌉(⌈ ⌉ ) 1 + n/ 2 1 + n/ 2 − 1 ≥ 1 = 2 . n ( n − 1) 11.4.1.4 Probability of success... Lemma 11.4.3. FastCut finds the minimum cut with probability larger than Ω (1 / log n ) . See class notes for a formal proof. We provide a more elegant direct argument shortly. 11.4.1.5 Amplification Lemma 11.4.4. Running FastCut repeatedly c · log 2 n times, guarantee that the algorithm outputs mincut with probability ≥ 1 − 1 /n 2 . c is a constant large enough. Proof : (A) FastCut succeeds with prob ≥ c ′ / log n , c ′ is a constant. (B) ...fails with prob. ≤ 1 − c ′ / log n . (C) ...fails in m reps with prob. ≤ (1 − c ′ / log n ) m . But then e − c ′ / log n ) m ≤ e − mc ′ / log n ≤ (1 − c ′ / log n ) m ≤ ( 1 n 2 , for m = (2 log n ) /c ′ . 11.4.1.6 Theorem Theorem 11.4.5. One can compute the minimum cut in a graph G with n vertices in O ( n 2 log 3 n ) time. The algorithm succeeds with probability ≥ 1 − 1 /n 2 . Proof : We do amplification on FastCut by running it O (log 2 n ) times. The running time bound follows from lemma... 11.5 On coloring trees and min-cut 11.5.0.7 Trees and coloring edges... (A) T h be a complete binary tree of height h . (B) Randomly color its edges by black and white. (C) E h : there exists a black path from root T h to one of its leafs. (D) ρ h = Pr [ E h ]. (E) ρ 0 = 1 and ρ 1 = 3 / 4 (see below). 7
Recommend
More recommend