Download presentation

Presentation is loading. Please wait.

1
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow

3
Outline Network flow definitions Flow examples Augmenting Paths Residual Graph Ford Fulkerson Algorithm Cuts Maxflow-MinCut Theorem

4
Network Flow Definitions Capacity Source, Sink Capacity Condition Conservation Condition Value of a flow

5
Flow Example u st v 20 30 10

6
Flow assignment and the residual graph u st v 15/20 20/20 15/30 0/10 5/10 u st v 5 15 10 520 15 5

7
Network Flow Definitions Flowgraph: Directed graph with distinguished vertices s (source) and t (sink) Capacities on the edges, c(e) >= 0 Problem, assign flows f(e) to the edges such that: –0 <= f(e) <= c(e) –Flow is conserved at vertices other than s and t Flow conservation: flow going into a vertex equals the flow going out –The flow leaving the source is a large as possible

8
Flow Example a s d b cf e g h i t 20 5 55 5 5 10 20 5 5 5 5 10 30

9
Find a maximum flow a s d b cf e g h i t 25 5 20 30 20 55 5 5 10 20 5 10 5 20 5 5 30 Value of flow: Construct a maximum flow and indicate the flow value

10
Find a maximum flow a s d b cf e g h i t 25 5 20 30 20 55 5 5 10 20 5 10 5 20 5 5 30

11
Augmenting Path Algorithm Augmenting path –Vertices v 1,v 2,…,v k v 1 = s, v k = t Possible to add b units of flow between v j and v j+1 for j = 1 … k-1 u st v 10/20 15/20 10/30 0/10 5/10

12
Find two augmenting paths st 2/5 0/1 3/4 3/3 2/4 1/3 3/3 2/2 3/4 1/3 3/3 2/2 3/3 1/3 2/2 1/3

13
Residual Graph Flow graph showing the remaining capacity Flow graph G, Residual Graph G R –G: edge e from u to v with capacity c and flow f –G R : edge e’ from u to v with capacity c – f –G R : edge e’’ from v to u with capacity f

14
Build the residual graph s d e g h t 3/5 2/4 3/3 1/5 1/1 3/3 2/5 s d e g h t Residual graph:

15
Augmenting Path Lemma Let P = v 1, v 2, …, v k be a path from s to t with minimum capacity b in the residual graph. b units of flow can be added along the path P in the flow graph. u st v 15/20 20/20 15/30 0/10 5/10 u st v 5 15 10 520 15 5

16
Proof Add b units of flow along the path P What do we need to verify to show we have a valid flow after we do this? –

17
Ford-Fulkerson Algorithm (1956) while not done Construct residual graph G R Find an s-t path P in G R with capacity b > 0 Add b units along in G If the sum of the capacities of edges leaving S is at most C, then the algorithm takes at most C iterations

18
Cuts in a graph Cut: Partition of V into disjoint sets S, T with s in S and t in T. Cap(S,T): sum of the capacities of edges from S to T Flow(S,T): net flow out of S –Sum of flows out of S minus sum of flows into S Flow(S,T) <= Cap(S,T)

19
What is Cap(S,T) and Flow(S,T) a s d b cf e g h i t 15/25 5/5 20/20 25/30 20/20 5/5 20/20 0/5 20/20 15/20 10/10 20/20 5/5 20/20 30/30 S={s, a, b, e, h}, T = {c, f, i, d, g, t} 0/5 0/20 0/5 0/10

20
Minimum value cut u st v 40 10

21
Find a minimum value cut s t 6 6 10 7 3 5 36 2 4 5 8 5 4 8

22
MaxFlow – MinCut Theorem There exists a flow which has the same value of the minimum cut Proof: Consider a flow where the residual graph has no s-t path with positive capacity Let S be the set of vertices in G R reachable from s with paths of positive capacity st

23
stuv S T What can we say about the flows and capacity between u and v?

24
Max Flow - Min Cut Theorem Ford-Fulkerson algorithm finds a flow where the residual graph is disconnected, hence FF finds a maximum flow. If we want to find a minimum cut, we begin by looking for a maximum flow.

25
Performance The worst case performance of the Ford- Fulkerson algorithm is horrible u st v 1000 1

26
Better methods of finding augmenting paths Find the maximum capacity augmenting path –O(m 2 log(C)) time algorithm for network flow Find the shortest augmenting path –O(m 2 n) time algorithm for network flow Find a blocking flow in the residual graph –O(mnlog n) time algorithm for network flow

Similar presentations

© 2021 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google