network flow ii
play

Network Flow II Lecture 13 October 10, 2013 - PowerPoint PPT Presentation

CS 573: Algorithms, Fall 2013 Accountability Network Flow II Lecture 13 October 10, 2013 http://www.cs.berkeley.edu/jrs/ Calvin Sariel (UIUC) CS573 1 Fall 2013 1 / 24 Sariel (UIUC) CS573 2 Fall 2013 2 / 24 Accountability Ford


  1. CS 573: Algorithms, Fall 2013 Accountability Network Flow II Lecture 13 October 10, 2013 http://www.cs.berkeley.edu/˜jrs/ Calvin Sariel (UIUC) CS573 1 Fall 2013 1 / 24 Sariel (UIUC) CS573 2 Fall 2013 2 / 24 Accountability Ford Fulkerson People that do not know maximum flows: essentially everybody. 1 algFordFulkerson ( G , s , t ) Initialize flow f to zero Average salary on earth ¡ $ 5 , 000 2 while ∃ path π from s to t in G f do People that know maximum flow – most of them work in 3 � � � c f ( π ) ← min c f ( u , v ) � ( u → v ) ∈ π � programming related jobs and make at least $ 10 , 000 a year. for ∀ ( u → v ) ∈ π do Salary of people that learned maximum flows: > $ 10 , 000 f ( u , v ) ← f ( u , v ) + c f ( π ) 4 f ( v , u ) ← f ( v , u ) − c f ( π ) Salary of people that did not learn maximum flows: < $ 5 , 000 . 5 Salary of people that know Latin: 0 (unemployed). 6 Lemma Conclusion If the capacities on the edges of G are integers, then algFordFulkerson runs in O ( m | f ∗ | ) time, where | f ∗ | is the amount Thus, by just learning maximum flows (and not knowing of flow in the maximum flow and m = | E ( G ) | . Latin) you can double your future salary! Sariel (UIUC) CS573 3 Fall 2013 3 / 24 Sariel (UIUC) CS573 4 Fall 2013 4 / 24

  2. Proof of Lemma... Integrality theorem Proof. Observation (Integrality theorem) Observe that the algFordFulkerson method performs only If the capacity function c takes on only integral values, then the subtraction, addition and min operations. Thus, if it finds an maximum flow f produced by the algFordFulkerson method has the augmenting path π , then c f ( π ) must be a positive integer number. property that | f | is integer-valued. Moreover, for all vertices u and Namely, c f ( π ) ≥ 1 . Thus, | f ∗ | must be an integer number (by v , the value of f ( u , v ) is also an integer. induction), and each iteration of the algorithm improves the flow by at least 1 . It follows that after | f ∗ | iterations the algorithm stops. Each iteration takes O ( m + n ) = O ( m ) time, as can be easily verified. Sariel (UIUC) CS573 5 Fall 2013 5 / 24 Sariel (UIUC) CS573 6 Fall 2013 6 / 24 Edmonds-Karp algorithm The disappearing/reappearing lemma Edmonds-Karp : modify algFordFulkerson so it always returns the Lemma shortest augmenting path in G f . During execution Edmonds-Karp , edge ( u → v ) might Definition disappear/reappear from G f at most n / 2 times, n = | V ( G ) | . For a flow f , let δ f ( v ) be the length of the shortest path from the Proof. source s to v in the residual graph G f . Each edge is considered to be iteration when edge ( u → v ) disappears. of length 1 . 1 ( u → v ) appeared in augmenting path π . 2 Assume the following key lemma: Fully utilized: c f ( π ) = c f ( uv ) . f flow in beginning of iter. 3 Lemma till ( u → v ) “magically” reappears. 4 ∀ v ∈ V \ { s , t } the function δ f ( v ) increases. ... augmenting path σ that contained the edge ( v → u ) . 5 g : flow used to compute σ . 6 We have: δ g ( u ) = δ g ( v ) + 1 ≥ δ f ( v ) + 1 = δ f ( u ) + 2 7 distance of s to u had increased by 2 . QED. 8 Sariel (UIUC) CS573 7 Fall 2013 7 / 24 Sariel (UIUC) CS573 8 Fall 2013 8 / 24

  3. Comments... Edmonds-Karp # of iterations δ ? ( u ) might become infinity. 1 Lemma u is no longer reachable from s . 2 Edmonds-Karp handles O ( nm ) augmenting paths before it stops. By monotonicity, the edge ( u → v ) would never appear again. � nm 2 � 3 Its running time is O , where n = | V ( G ) | and m = | E ( G ) | . Observation Proof. For every iteration/augmenting path of Edmonds-Karp algorithm, Every edge might disappear at most n / 2 times. 1 at least one edge disappears from the residual graph G ? . At most nm / 2 edge disappearances during execution 2 Edmonds-Karp . In each iteration, by path augmentation, at least one edge 3 disappears. Edmonds-Karp algorithm perform at most O ( mn ) iterations. 4 Computing augmenting path takes O ( m ) time. 5 � nm 2 � Overall running time is O . 6 Sariel (UIUC) CS573 9 Fall 2013 9 / 24 Sariel (UIUC) CS573 10 Fall 2013 10 / 24 Shortest distance increases during Edmonds-Karp Proof continued... execution π = s → · · · → u → v : shortest path in G g from s to v . 1 ( u → v ) ∈ E ( G g ) , and thus δ g ( u ) = δ g ( v ) − 1 . 2 Lemma By choice of v : δ g ( u ) ≥ δ f ( u ) . 3 Edmonds-Karp run on G = ( V , E ) , s , t , then ∀ v ∈ V \ { s , t } , (i) If ( u → v ) ∈ E ( G f ) then the distance δ f ( v ) in G f increases monotonically. δ f ( v ) ≤ δ f ( u ) + 1 ≤ δ g ( u ) + 1 = δ g ( v ) − 1 + 1 = δ g ( v ) . Proof This contradicts our assumptions that δ f ( v ) > δ g ( v ) . By Contradiction. f : flow before (first fatal) iteration. 1 g : flow after. 2 v : vertex s.t. δ g ( v ) is minimal, among all counter example 3 vertices. v : δ g ( v ) is minimal and δ g ( v ) < δ f ( v ) . 4 Sariel (UIUC) CS573 11 Fall 2013 11 / 24 Sariel (UIUC) CS573 12 Fall 2013 12 / 24

  4. Proof continued II Bipartite Matching (ii) f ( u → v ) / ∈ E ( G f ) : 1 π used in computing g from f contains ( v → u ) . 1 s t ( u → v ) reappeared in the residual graph G g (while not being 2 present in G f ). 1 = ⇒ π pushed a flow in the other direction on the edge 3 ( u → v ) . Namely, ( v → u ) ∈ π . 1 Algorithm always augment along the shortest path. By 4 assumption δ g ( v ) < δ f ( v ) , and definition of u : δ f ( u ) = δ f ( v ) + 1 > δ g ( v ) = δ g ( u ) + 1 , = ⇒ δ f ( u ) > δ g ( u ) 5 = ⇒ monotonicity property fails for u . But: δ g ( u ) < δ g ( v ) . A contradiction. Sariel (UIUC) CS573 13 Fall 2013 13 / 24 Sariel (UIUC) CS573 14 Fall 2013 14 / 24 Bipartite matching Computing bipartite matching Theorem Definition Compute maximum bipartite matching in O ( nm ) time. G = ( V , E ) : undirected graph. M ⊆ E : matching if all vertices v ∈ V , at most one edge of M is Proof. incident on v . G : bipartite graph G . ( n vertices and m edges) 1 M is maximum matching if for any matching M ′ : | M | ≥ | M ′ | . Create new graph H with source on left and sink right. 2 M is perfect if it involves all vertices. Direct all edges from left to right. Set all capacities to one. 3 By Integrality theorem, flow in H is 0 / 1 on edges. 4 A flow of value k in H = ⇒ a collection of k vertex disjoint 5 s − t paths = ⇒ matching in G of size k . M : matching of k edge in G , = ⇒ flow of value k in H . 6 Running time of the algorithm is O ( nm ) . Max flow is n , and as 7 such, at most n augmenting paths. Sariel (UIUC) CS573 15 Fall 2013 15 / 24 Sariel (UIUC) CS573 16 Fall 2013 16 / 24

  5. Extension: Multiple Sources and Sinks Proof by figures Question Given a flow network with several sources and sinks, how can we s 1 s 1 t 1 t 1 ∞ compute maximum flow on such a network? s ∞ t ∞ s 2 s 2 ∞ Solution t 2 t 2 The idea is to create a super source, that send all its flow to the old sources and similarly create a super sink that receives all the flow. Clearly, computing flow in both networks in equivalent. Sariel (UIUC) CS573 17 Fall 2013 17 / 24 Sariel (UIUC) CS573 18 Fall 2013 18 / 24

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend