Flow Networks

# Flow Networks

## Flow Networks

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

1. Flow Networks zichun@comp.nus.edu.sg

2. Formalization Basic Results Min-cut Ford-Fulkerson Edmunds-Karp Bipartite Matching

3. Flow Network • Directed Graph G = (V, E) • Each edge has a capacity

4. Properties of Flow Capacity Constraint Skew Symmetry Flow Conservation

5. Maximum Flow • Returns Maximum Flow of G Value of Flow

6. Motivating Problem 12 v1 v3 20 16 Factory Warehouse s t 10 4 7 9 13 4 v2 v4 14

7. Motivating Problem 12/12 v1 v3 11/16 15/20 Factory Warehouse s t 10 1/4 7/7 4/9 8/13 4/4 v2 v4 11/14

8. 12/12 v1 v3 11/16 15/20 Factory Warehouse s t 10 1/4 7/7 4/9 8/13 4/4 v2 v4 11/14

9. Multiple Sources / Sinks 12 v1 v3 20 16 t1 s1 10 4 7 9 13 4 4 s2 t2 v2 v4 4 14

10. Multiple Sources / Sinks 12 v1 v3 20 16 t1 s1 10 4 7 9 13 t S 4 4 s2 t2 v2 v4 4 14

11. Implicit Summation Notation

12. Key Equalities Let G = (V, E) be a flow network, and let f be a flow in G. Then

13. Capacity Constraint Skew Symmetry Flow Conservation Homomorphism

14. Flow Value Prove Definition Homomorphism Flow Conservation Skew Symmetry Homomorphism Flow Conservation

15. Ford-Fulkerson flow=0while(augmenting path p)) { augment flow f along p } return flow

16. Residual network Induced network from G=(V, E) and flow f

17. 12/12 v1 v3 11/16 15/20 Factory Warehouse s t 10 1/4 7/7 4/9 8/13 4/4 v2 v4 11/14 v1 0 v3 5 11 12 Factory Warehouse 5 15 5 s t 3 11 7 0 4 8 0 5 11 v2 v4 4 3

18. Augmenting Path A pathof non-zeroweight from s to t in Gf

19. 12/12 v1 v3 11/16 15/20 Factory Warehouse s t 10 1/4 7/7 4/9 8/13 4/4 v2 v4 11/14 v1 0 v3 5 11 12 Factory Warehouse 5 15 5 s t 3 11 7 0 4 8 0 5 11 v2 v4 4 3

20. 12/12 v1 v3 11/16 15/20 Factory Warehouse s t 10 1/4 7/7 4/9 8/13 4/4 v2 v4 11/14 v1 0 v3 5 11 12 Factory Warehouse 5 15 5 s t 3 11 7 0 4 8 0 5 11 v2 v4 4 3

21. 12/12 v1 v3 11/16 15/20 Factory Warehouse s t 10 1/4 7/7 4/9 8/13 4/4 v2 v4 11/14 v1 0 v3 5 11 12 Factory Warehouse 5 15 5 s t 3 11 7 0 4 8 0 5 11 v2 v4 4 3

22. 12/12 v1 v3 11/16 20/20 Factory Warehouse s t 10 1/4 7/7 0/9 13/13 4/4 v2 v4 11/14 v1 0 v3 0 11 12 Factory Warehouse 5 20 9 s t 3 11 7 0 0 13 0 0 11 v2 v4 4 3

23. S-T Cut • A cut C=(S, T) of a flow network G=(V, E) is a partition of V into S and T = V – S • Net flow across • Capacity of cut:

24. 12/12 v1 v3 11/16 15/20 Factory Warehouse s t 10 1/4 7/7 4/9 8/13 4/4 v2 v4 11/14 f(S, T) = 12 – 4 + 11 = 19c(S, T) = 12 + 14 = 26

25. Let f be a flow in a flow network G with source s and sink t, and let (S, T) be a cut of G. Then the net flow across (S, T) is f(S, T) = |f| Homomorphism Flow Conservation Homomorphism Flow Conservation Definition

26. The value of any flow f in a flow network G is bounded by the capacity of any cut of G

27. Min-Cut Max-Flow • f is a maximum flow in G • The residual network Gf contains no augmenting path • |f|= c(S, T) for some cut (S, T) of G

28. Premise: f is a max-flow in G • Assume Gf has augmenting path p • We can augment Gf with p to get a flow f’ > f • Contradicts [1] • Hence Gf has no augmenting paths

29. Premise: Gf has no augmenting paths • Let • T = V-S • (S, T) is a cut • Otherwise

30. The value of any flow f in a flow network G is bounded by the capacity of any cut of G • , |f| is maximum

31. Ford-Fulkerson flow=0while(augmenting path p)) { augment flow f along p } return flow Termination: Gf has no augmenting path iff flow is maximum

32. Run-time flow=0while(augmenting path p)) { augment flow f along p } return flow O(E|f*|) where |f*| is the maximum flow

33. v1 1,000,000 1,000,000 s 1 t 1,000,000 1,000,000 v2

34. v1 1,000,000 1,000,000 s 1 t 1,000,000 1,000,000 v2

35. v1 999,999 1,000,000 1 s 1 t 1 1,000,000 1,000,000 v2

36. v1 999,999 1,000,000 1 s 1 t 1 1,000,000 1,000,000 v2

37. v1 999,999 999,999 1 1 s 1 t 1 1 999,999 1,000,000 v2

38. v1 999,999 999,999 1 1 s 1 t 1 1 999,999 1,000,000 v2

39. Edmunds Karp flow=0while(augmenting path p)) { find augmenting path by BFS augment flow f along p } return flow Run-time: O(VE2)

40. v1 0 v3 5 11 12 Factory Warehouse 5 15 5 s t 3 11 7 0 4 8 0 5 11 v2 v4 4 3 Critical Edge

41. Lemma: Edges can be critical at most times v1 0 v3 5 11 12 Factory Warehouse 5 15 5 s t 3 11 7 0 4 8 0 5 11 v2 v4 4 3 Critical Edge

42. v1 0 v3 5 11 12 Factory Warehouse 5 15 5 s t 3 11 7 0 4 8 0 5 11 v2 v4 4 3

43. Assume (u, v) is a critical edge • Augmenting-paths are shortest path [by EK] • [from 1] • After flow-augmentation, cf(u,v) = 0 • (u, v) cannot be critical path until another augmenting path containing (v, u). • Let the flow at this point be f’ • i.e, each time (u, v) is augmenting-path, path length increases by 2 • (u, v) can be critical edge at most times

44. Lemma: Edges can be critical at most times Since there are O(E) edges, the number of augmenting path is bounded by O(VE) [by Lemma]. Run-time: O(VE2)

45. Bipartite Matching

46. Bipartite Matching