Max Flow: Shortest Augmenting Path

# Max Flow: Shortest Augmenting Path

Télécharger la présentation

## Max Flow: Shortest Augmenting Path

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
##### Presentation Transcript

1. Max Flow: Shortest Augmenting Path

2. 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) • Max bottleneck capacity. • Sufficiently large capacity. • Fewest number of edges.

3. Shortest Augmenting Path • Shortest augmenting path. • Find augmenting path with fewest number of edges. • BFS is an efficient implementation. may implement by accident! Shortest-Augmenting-Path(G, s, t, c) { foreach e  E f(e)  0 Gf residual graph while (there exists an augmenting path) { find such a shortest such path P using BFS f  Augment(f, c, P) update Gf } return f }

4. Shortest Augmenting Path: Overview of Analysis • Proof outline. • L1. Throughout the algorithm, the length of the shortest path never decreases. • L2. After at most m shortest path augmentations, the length of the shortest augmenting path strictly increases. • Theorem. The shortest augmenting path algorithm performs at most O(mn) augmentations. It can be implemented in O(m2n) time. • O(m) time to find shortest augmenting path via BFS. • O(m) augmentations for paths of exactly k edges. • If there is an augmenting path, there is a simple one. 1  k < n O(mn) augmentations. ▪ proof ahead proof ahead

5. Shortest Augmenting Path: Analysis number of edges • Level graph. G = (V, E), s • For each vertex v, define (u) to be the length of shortest s-u path. • L = (V, F) is subgraph of G that contains only those edges (u, v)  E with (v) = (u) + 1. • Compute in O(m+n) time using BFS, deleting back and side edges. • P is a shortest s-u path in G iff it is an s-u path LG. 2 5 L: s 3 6 t  = 1  = 2  = 3  = 0

6. Shortest Augmenting Path: Analysis • L1. Throughout the algorithm, the length of the shortest path never decreases. • Let f and f' be flow before and after a shortest path augmentation. • Let Land L' be level graphs of Gf and Gf ' • Only back edges added to Gf ' • Path with back edge has length greater than previous length. 2 5 L s 3 6 t  = 1  = 2  = 3  = 0 2 5 L' s 3 6 t

7. Shortest Augmenting Path: Analysis • L2. After at most m shortest path augmentations, the length of the shortest augmenting path strictly increases. • At least one edge (the bottleneck edge) is deleted from L after each augmentation. • No new edges added to L until length of shortest path strictly increases. 2 5 L s 3 6 t  = 1  = 2  = 3  = 0 2 5 L' s 3 6 t

8. Shortest Augmenting Path: Review of Analysis • L1. Throughout the algorithm, the length of the shortest path never decreases. • L2. After at most m shortest path augmentations, the length of the shortest augmenting path strictly increases. • Theorem. The shortest augmenting path algorithm performs at most O(mn) augmentations. It can be implemented in O(m2n) time. • Note: (mn) augmentations necessary on some networks. • Try to decrease time per augmentation instead. • Dynamic trees  O(mn log n) Sleator-Tarjan, 1983 • Simple idea O(mn2)

9. Shortest Augmenting Path: Improved Version • Two types of augmentations. • Normal augmentation: length of shortest path doesn't change. • Special augmentation: length of shortest path strictly increases. • L3. Group of normal augmentations takes O(mn) time. • Explicitly maintain level graph - it changes by at most 2n edges after each normal augmentation. • Start at s, advance along an edge in Luntil reach t or get stuck. • if reach t, augment and delete at least one edge • if get stuck, delete node 2 5 L s 3 6 t  = 1  = 2  = 3  = 0

10. Shortest Augmenting Path: Improved Version 2 5 L augment bottleneck edge s 3 6 t 2 5 L delete 3 got stuck,delete node s 3 6 t 2 5 augment L s 6 t bottleneck edge

11. Shortest Augmenting Path: Improved Version 2 5 L augment bottleneck edge s 6 t 2 5 L s 6 t Stop: length of shortest path must have strictly increased.

12. Shortest Augmenting Path: Improved Version Advance-Retreat(V, E, f, s, t) { array pred[u  V] L  level graph of Gf u  s, pred[v]  nil repeat { while (there exists (u, v)  L) { pred[v]  u, u  v if (u = t) { P  path defined by pred[] f  Augment(f, P) update L u  s, pred[u]  nil } } delete u from L } until (u = s) return f } advance retreat

13. Shortest Augmenting Path: Improved Version • Two types of augmentations. • Normal augmentation: length of shortest path doesn't change. • Special augmentation: length of shortest path strictly increases. • L3. Group of normal augmentations takes O(mn) time. • At most n advance steps before you either • get stuck: delete a node from level graph • reach t: augment and delete an edge from level graph • Theorem. Algorithm runs in O(mn2) time. • O(mn) time between special augmentations. • At most n special augmentations.

14. Choosing Good Augmenting Paths: Summary Method Augmentations Asymptotic time Augmenting path nU mnC † Max capacity m log C m log C (m + n log n) † Capacity scaling m log C m2 log C † Improved capacity scaling m log C mnlog C † Shortest path mn m2n Improved shortest path mn mn2 † Edge capacities are between 1 and C.

15. History of Worst-Case Running Times Year Discoverer Method Asymptotic Time 1951 Dantzig Simplex m n2 C † 1955 Ford, Fulkerson Augmenting path m n C † 1970 Edmonds-Karp Shortest path m2 n 1970 Edmonds-Karp Fattest path m log U (m log n) † 1970 Dinitz Improved shortest path m n2 1972 Edmonds-Karp, Dinitz Capacity scaling m2 log C † 1973 Dinitz-Gabow Improved capacity scaling m nlog C † 1974 Karzanov Preflow-push n3 1983 Sleator-Tarjan Dynamic trees m n log n 1986 Goldberg-Tarjan FIFO preflow-push m n log (n2 / m) . . . . . . . . . . . . 1997 Goldberg-Rao Length function m3/2 log (n2 / m) log C †mn2/3 log (n2 / m) log C † † Edge capacities are between 1 and C.

16. Unit Capacity Simple Networks 1 • Unit capacity simple network. • Every edge capacity is one. • Every node has either:(i) at most one incoming edge, or(ii) at most one outgoing edge. • If G is simple unit capacity, then so isGf, assuming f is 0-1 flow. • Shortest augmenting path algorithm. • Normal augmentation: length of shortest path doesn't change. • Special augmentation: length of shortest path strictly increases. • Theorem. Shortest augmenting path algorithm runs in O(m n1/2) time. • L1. Each phase of normal augmentations takes O(m) time. • L2. After at most n1/2 phases, | f |  | f *| - n1/2. • L3. After at most n1/2 additional augmentations, flow is optimal. 1 1

17. Unit Capacity Simple Networks Lemma 1. Phase of normal augmentations takes O(m) time. • Start at s, advance along an arc in LG until reach t or get stuck. • if reach t, augment and delete ALL arcs on path • if get stuck, delete node and go to previous node Augment Level graph

18. Unit Capacity Simple Networks Lemma 1. Phase of normal augmentations takes O(m) time. • Start at s, advance along an arc in LG until reach t or get stuck. • if reach t, augment and delete ALL arcs on path • if get stuck, delete node and go to previous node Delete node and retreat Level graph

19. Unit Capacity Simple Networks Lemma 1. Phase of normal augmentations takes O(m) time. • Start at s, advance along an arc in LG until reach t or get stuck. • if reach t, augment and delete ALL arcs on path • if get stuck, delete node and go to previous node Augment Level graph

20. Unit Capacity Simple Networks Lemma 1. Phase of normal augmentations takes O(m) time. • Start at s, advance along an arc in LG until reach t or get stuck. • if reach t, augment and delete ALL arcs on path • if get stuck, delete node and go to previous node STOPLength of shortest path has increased. Level graph

21. Unit Capacity Simple Networks • Lemma 1. Phase of normal augmentations takes O(m) time. • Start at s, advance along an arc in LG until reach t or get stuck. • if reach t, augment and delete ALL arcs on path • if get stuck, delete node and go to previous node • O(m) running time. • O(m) to create level graph • O(1) per arc, since each arc traversed at most once • O(1) per node deletion

22. ARRAY pred[v  V] LG level graph of Gf v  s, pred[v]  nil REPEAT WHILE (there exists (v,w)  LG) pred[w]  v, v  w IF (v = t) P  path defined by pred[] f  augment(f, P) update LG v  s, pred[v]  nil delete v from LG UNTIL (v = s) RETURN f AdvanceRetreat(V, E, f, s, t) Unit Capacity Simple Networks advance augment retreat

23. Unit Capacity Simple Networks • Lemma 2. After at most n1/2 phases, | f |  | f *| - n1/2. • After n1/2 phases, length of shortest augmenting path is > n1/2. • Level graph has more than n1/2 levels. • Let 1  h  n1/2 be layer with min number of nodes: |Vh|  n1/2. Level graph V0 V1 Vh Vn1/2

24. Unit Capacity Simple Networks • Lemma 2. After at most n1/2 phases, | f |  | f *| - n1/2. • After n1/2 phases, length of shortest augmenting path is > n1/2. • Level graph has more than n1/2 levels. • Let 1  h  n1/2 be layer with min number of nodes: |Vh|  n1/2. • S := {v : (v) <h}  {v : (v) =h and v has  1 outgoing residual arc}. • capf (S, T)  |Vh|  n1/2  | f |  | f *| - n1/2. Residual arcs Level graph V0 V1 Vh Vn1/2