Download presentation
Presentation is loading. Please wait.
Published byAshley Shaw Modified over 9 years ago
1
Flow Networks Ching-Chen Huang Hsi-Yue Hsiao
2
CONTENTS Network flows on directed acyclic graphs Ford-fulkerson Algorithms -Residual networks
3
Network flows on directed acyclic graphs DAG is a directed graph with no cycles. Flow network: a flow network G = (V,E) is a directed graph in which each edge (u,v) ∈ E has a nonnegative capacity c(u,v) >= 0. if (u,v) ∉ E, we assume that c(u,v) = 0. st We distinguish two vertices in flow network, source s and sink t. The source produces the material at a steady rate. The sink consumes the material at a steady rate. Objective : how much of material can be imposed through the network that it can handle.
4
Flow: A flow in G is a real-valued function f : V × V → R that satisfies three properties: 1. Capacity constraint : For all u,v ∈ V, we require f(u,v) ≤ c(u,v). The net flow from one vertex to another must not exceed the given capacity. 2. Skew symmetry : For all u,v ∈ V, we require f(u,v) = -f(v,u). The net flow from a vertex u to a vertex v is the negative of the net flow in the 3. Flow conservation : For all u ∈ V - {s,t}, we require ∑ f(u,v) = 0. v ∈ V The quantity f(u,v),which can be positive or negative, is called the net flow from vertex u to v. The value of the flow is defined as | f | = ∑ f(s,v) that is the totat net v ∈ V Flow out of the source.
5
Residual Capacity Given a flow f in network G = (V, E). Consider a pair of vertices u, v ∈ V. Residual capacity: The amount of additional flow we can push directly from u to v. c f (u, v) = c(u, v) f (u, v) ≥ 0 (since f (u, v) ≤ c(u, v)) Example: c(u,v) = 16, f(u,v) = 5 c f (u, v) = 11
6
Residual Network Residual network: G f = (V, E f ), E f = {(u, v) ∈ V × V : c f (u, v) > 0}. Each edge of the residual network can admit a positive flow. Given flows f 1 and f 2, the flow sum f 1 + f 2 is (f 1 + f 2 )(u, v) = f 1 (u, v) + f 2 (u, v) for all u, v ∈ V.
7
Consider the network G=(V,E) shown in the figure below. Each edge (u,v) ∈ E in the network is labeled with its capacity c(u,v). s b t a 5 4 3 1 2 s b t a 5 4 3 1 2 Flow: 1 1 1 1
8
Residual graph s b t a 5 4 2 1 1 1 1 s b t a 5 1/4 1/3 1/1 2/2
9
Residual graph s b t a 5 3 2 1 2 1 1 s b t a 1/5 2/4 1/3 0/1 2/2
10
s b t a 4 2 2 1 2 11 2 s b t a 3/5 2/4 3/3 1 2/2
11
s b t a 2 2 3 1 2 3 2 Max Flow : 5
12
Ford-Fulkerson Algorithm The Ford_Fulkerson method is iterative, Starts with f(u,v) for (u,v) ∈ V, initial flow of value 0. The method is based on the augmenting path which is defined as a path from s to t along which we can push more flow and then augment flow along this path.
13
Procedure Ford_Fulkerson_method(G,s,t): For each edge (u,v) ∈ E[G] do f[u,v] 0 f[v,u] 0 While there exists a path p from s to t in the residual network G1 do c1(p) min{ c1(u,v):(u,v) is in p} for each edge (u,v) in p do f[u,v] f[u,v] + c1(p) f[u,v] -f[u,v]
14
Running time for this algorithms is O(E * |f*|) where f* is the maximum flow found by algorithm. First three Lines take time θ(E). The while loop of last five lines is executed at most |f*| times, since the flow value increases by at least one unit in each iteration.
15
Ford-Fulkerson Algorithm Ford-Fulkerson(G, s, t) ; G = (V, E) 1 for each edge (u,v) in E 2 f(u,v) = f(v,u) = 0 3 while exists path p from s to t in residual network G f 4 do c f (p) = min{c f (u, v) : (u, v) is in p} 5 for each edge (u,v) on p 6 f(u,v) = f(u,v) + c f (p) 7 f(v,u) = -f(u,v)
16
st v1v2 v4v3 13 16 12 20 14 4 10 4 9 st v1v2 v4v3 13 4/16 4/12 20 4/14 4/4 10 4 4/9 7 7 Example:
17
st v1v2 v4v3 13 12 8 20 10 4 4 5 4 74 4 st v1v2 v4v3 13 11/16 7/20 11/14 4/4 7/10 4 4/9 7/7 4/12 4
18
st v1v2 v4v3 13 5 8 3 4 3 11 5 4 7 4 7 st v1v2 v4v3 8/13 11/16 15/20 11/14 4/4 10 1/4 4/9 7/7 12/12
19
st v1v2 v4v3 8 5 12 5 3 4 11 3 5 4 7 15 5 11 s v1v2 v4v3 12/13 11/16 11/14 4/4 10 1/4 9 7/7 12/12 t 19/20
20
st v1v2 v4v3 1 5 12 1 3 4 11 3 9 7 19 12 11
21
Reference Class Notes from Dr. Istvan Jonyer of Oklahoma State University Class Notes from CSE 5311 of 2004, made by Hiren Patel, Ujjval Patel
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.