cs 401
play

CS 401 Max Flow / Bipartite Matching Xiaorui Sun 1 Flow network - PowerPoint PPT Presentation

CS 401 Max Flow / Bipartite Matching Xiaorui Sun 1 Flow network Flow network. G = (V, E) = directed graph, no parallel edges. Two distinguished nodes: s = source, t = sink. c(e) = capacity of edge e. 9 2 5 10 15 15 10 4 source 5


  1. CS 401 Max Flow / Bipartite Matching Xiaorui Sun 1

  2. Flow network Flow network. G = (V, E) = directed graph, no parallel edges. Two distinguished nodes: s = source, t = sink. c(e) = capacity of edge e. 9 2 5 10 15 15 10 4 source 5 sink 8 s 3 6 10 t 15 4 6 10 15 capacity 30 4 7

  3. Minimum Cut Problem Min s-t cut problem. Find an s-t cut of minimum capacity. 9 2 5 10 15 15 10 4 5 8 s 3 6 10 t 15 4 6 10 A 15 Capacity = 10 + 8 + 10 = 28 30 3 4 7

  4. Maximum Flow Problem Max flow problem. Find s-t flow of maximum value. 9 9 2 5 10 9 1 10 15 15 0 10 4 0 4 9 8 5 8 s 3 6 10 t 4 10 0 15 0 4 6 10 capacity 15 flow 14 14 Value = 28 30 4 4 7

  5. Max Flow Algorithm Ford-Fulkerson(G, s, t, c) { foreach e Î E f(e) ¬ 0 G f ¬ residual graph while (there exists augmenting path P) { f ¬ Augment(f, c, P) update G f } return f } Max-flow min-cut theorem. [Ford-Fulkerson 1956] The value of the max flow is equal to the value of the min cut.

  6. Running Time Assumption. All capacities are integers between 1 and C. Invariant. Every flow value f(e) and every residual capacities c f (e) remains an integer throughout the algorithm. Theorem. The algorithm terminates in at most v(f*) £ nC iterations. Pf. Each augmentation increase value by at least 1. ▪ Corollary. If C = 1, Ford-Fulkerson runs in O(mn) time. Integrality theorem. If all capacities are integers, then there exists a max flow f for which every flow value f(e) is an integer. Pf. Since algorithm terminates, theorem follows from invariant. ▪

  7. 7.3 Choosing Good Augmenting Paths

  8. Ford-Fulkerson: Exponential Number of Augmentations Q. Is generic Ford-Fulkerson algorithm polynomial in input size? m, n, and log C A. No. If max capacity is C, then algorithm can take C iterations. 1 1 X X 1 X 0 0 0 0 1 1 C C C C X 1 X s X t s t 1 0 1 0 0 1 C C C C X X X 1 0 0 1 0 0 1 2 2

  9. Choosing Good Augmenting Paths Use care when selecting augmenting paths. Some choices lead to exponential algorithms. Clever choices lead to polynomial algorithms. If capacities are irrational, algorithm not guaranteed to terminate! Goal: choose augmenting paths so that: Can find augmenting paths efficiently. Few iterations. Choose augmenting paths with: [Edmonds-Karp 1972, Dinitz 1970] Sufficiently large bottleneck capacity. Fewest number of edges.

  10. Capacity Scaling Intuition. Choosing path with highest bottleneck capacity increases flow by max possible amount. How to find exact highest bottleneck path? Homework 4 Maintain scaling parameter D . Let G f ( D ) be the subgraph of the residual graph consisting of only arcs with capacity at least D . 4 4 110 102 110 102 1 s s t t 122 170 122 170 2 2 G f G f (100)

  11. Capacity Scaling Scaling-Max-Flow(G, s, t, c) { foreach e Î E f(e) ¬ 0 D ¬ smallest power of 2 greater than or equal to C G f ¬ residual graph while ( D ³ 1) { G f ( D ) ¬ D -residual graph while (there exists augmenting path P in G f ( D )) { f ¬ augment(f, c, P) update G f ( D ) } D ¬ D / 2 } return f }

  12. Capacity Scaling: Correctness Assumption. All edge capacities are integers between 1 and C. Integrality invariant. All flow and residual capacity values are integral. Correctness. If the algorithm terminates, then f is a max flow. Pf. By integrality invariant, when D = 1 Þ G f ( D ) = G f . Upon termination of D = 1 phase, there are no augmenting paths. ▪

  13. Capacity Scaling: Running Time Lemma 1. The outer while loop repeats 1 + é log 2 C ù times. Pf. Initially C £ D < 2C. D decreases by a factor of 2 each iteration. ▪ Lemma 2. Let f be the flow at the end of a D -scaling phase. Then the value of the maximum flow is at most v(f) + m D . proof on next slide Lemma 3. There are at most 2m augmentations per scaling phase. Let f be the flow at the end of the previous scaling phase. L2 Þ v(f*) £ v(f) + m (2 D ). Each augmentation in a D -phase increases v(f) by at least D . ▪ Theorem. The scaling max-flow algorithm finds a max flow in O(m log C) augmentations. It can be implemented to run in O(m 2 log C) time. ▪

  14. Capacity Scaling: Running Time Lemma 2. Let f be the flow at the end of a D -scaling phase. Then value of the maximum flow is at most v(f) + m D . Pf. (almost identical to proof of max-flow min-cut theorem) We show that at the end of a D -phase, there exists a cut (A, B) such that cap(A, B) £ v(f) + m D . Choose A to be the set of nodes reachable from s in G f ( D ). By definition of A, s Î A. By definition of f, t Ï A. A B t s original network

  15. Summary Min s-t cut problem. Find an s-t cut of minimum capacity. Max flow problem. Find s-t flow of maximum value. Max-flow min-cut theorem. The value of the max flow is equal to the value of the min cut. Ford-Fulkerson Algorithm. Augment flow along augmenting path Running time: • O(nm) for unit capacity graph • O(m 2 log C) for integer capacity graph 15

  16. Bipartite Matching

  17. Maximum Matching Problem Given an undirected graph ! = ($, &) . A set ( ⊆ & is a matching if each node appears in at most 1 edge in ( . Goal: find a matching with largest cardinality. 17

  18. Bipartite Matching Problem Given an undirected bipartite graph ! = ($ ∪ &, () A set * ⊆ ( is a matching if each node appears in at most 1 edge in * . Goal: find a matching with largest cardinality. 1 1' 2 2' 3 3' Y X 4 4' 5 5' 18

  19. Bipartite Matching using Max Flow Create digraph ! as follows: • Orient all edges from " to # , and assign infinite (or unit) capacity. • Add source $ , and unit capacity edges from $ to each node in % . • Add sink & , and unit capacity edges from each node in ' to & . ∞ H 1 1' 1 1 2 2' s 3 3' t 4 4' 5 5' 19 Y X

  20. Bipartite Matching: Proof of Correctness Thm. Max cardinality matching in ! = value of max flow in H. Proof. Matching value £ maxflow value Given max matching " of cardinality # . Consider flow $ that sends 1 unit along each of # edges of " . $ is a flow, and has cardinality # . ▪ ∞ H 1 1' 1 1' G 1 1 2 2' 2 2' 3 3' s 3 3' t 4 4' 4 4' 20 5 5' 5 5'

  21. Bipartite Matching: Proof of Correctness Thm. Max cardinality matching in G = value of max flow in H. Proof. (matching val ≥ maxflow val) Let " be a max flow in # of value $ . Integrality theorem Þ $ is integral and we can assume " is 0-1. Consider % = set of edges from & to ' with " ( = 1 . • each node in & and ' participates in at most one edge in % . • |%| = $ : consider s-t cut (. ∪ &, 1 ∪ ') G ∞ 1 1' 1 1' H 2 2' 1 1 2 2' 3 3' s 3 3' t 4 4' 4 4' 5 5' 21 5 5'

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