Professional Documents
Culture Documents
chap10_1.7m
chap10_1.7m
chap10_1.7m
Contents
PART 1 1. Problem description and applications
COMBINATORIAL THEORY 2. Cut
3. Residual graph and Augmenting path
(Lý thuyết tổ hợp)
4. Ford-Fulkerson algorithm
5. Edmond-Karp algorithm
PART 2 6. Some applications
GRAPH THEORY
(Lý thuyết đồ thị)
2
1
Network Flow in network
Network is a directed graph G = (V, E): Definition. Flow f in network G=(V,E) is to assign value f(e) on each edge e
• There is only one vertex s without any incoming arcs, called (f(e) is flow on edge e) so that following conditions are satisfied:
source vertex and only vertex t without any outgoing arcs 1) Capacity rule:
called target vertex.
• Each edge e of G is assigned a nonnegative value c(e) which For each edge e, 0 f (e) c(e)
is called capacity of e. 2) Conservation Rule (Điều kiện cân bằng luồng): Each v s, t
Example: f ( e) f ( e )
eE ( v ) eE ( v )
v 3
6
1 Definition. Value of flow f is
7 t
s 3 (*)
1
w
9 5
val ( f ) f ( e) f (e)
eE ( s ) eE ( t )
5
u z Edges going out of s Edges going into t
2
(Equation (*) is obtained by summing up all the conservation rules.)
2
Maximum Flow problem Contents
A flow in network G is called
maximum flow if among all 2/6
v 1/3 1. Problem description and applications
1/1
flows in G, it is the one having
maximum value. s 3/3
3/7 t
2. Cut
w
3/5 1/1 2/9 4/5
3. Residual graph and Augmenting path
Maximum flow problem is u z
the problem aiming to
2/2
Flow with value 8 = 2 + 3 + 3 = 1 + 3 + 4 4. Ford-Fulkerson algorithm
determine a feasible flow
through the network with 4/6
v 3/3
5. Edmond-Karp algorithm
maximum value 1/1
3/7 t
s 3/3
w
6. Some applications
1/1 2/9 4/5
3/5
u z
2/2
Maximum flow with value 10 = 4 + 3 + 3 = 3 + 3 + 4
Network
transaction stations,
computers, satellites
cables
voice, video,
packets
cap ( S , T )
eS T
c(e),
3
Flow and cut Max Flow and Min Cut
Lemma 1. Assume f is flow, and (S, T) is a cut. Then Corollary. Assume f is a flow, (S, T) is a cut. If val( f ) = cap(S, T), then
Flow through this cut is equal to the value of flow f: f is maximum flow and (S, T) is minimum cut.
f (e ) f (e ) f (e ) f (e) val ( f )
eS T eT S eE (s ) eE (t )
4
f ( e) 8
t 4 9
8
eS T s 5 3 8 6 10 t
eS T
c ( e)
s
4
15 0
10
7 4 0 6 10
15
cap(S , T ) 6 14
4 30 7
14 Flow value = 28
Cut capacity = 28
4
Contents Greedy algorithm
1. Problem description and applications Greedy algorithm does not provide optimal solution.
4 5
2. Cut 0
0
4 0
Greedy algorithm:
4
Value of flow = 10
3. Residual graph and Augmenting path 10
0
4
4
10 10
4. Ford-Fulkerson algorithm s 10 2 13 3 10 t
5. Edmond-Karp algorithm
Optimal:
6. Some applications 4
4
5 Value of flow = 14
4 4 4
4
4 4
4
10 6 10
s 10 2 13 3 10 t
s->4->3->t ???
s->2->5->t ??? e = (u,v) eR = (v,u)
Residual graph: Gf = (V, Ef ).
4 5 • Ef = {e: f(e) < c(e) } {eR : f(e) > 0 }
0 • Capacity of each arc e
0 4 0 v 11 w
4
0 4 c(e) f (e) if e E 6
4 c f ( e)
0 10 0 10 0 10
f (e) if e R E
s 10 2 13 3 10 t
Value
Valueof
offlow
flow==10
0
5
Theorem about maximum flow and minimum cut Ford – Fulkerson algorithm
Augmenting path Theorem (Ford-Fulkerson, 1956): Flow is maximum if and Augmenting flow f along path P
only if there does not exist augmenting path on network. float Augment(f,P)
{
b cf(P)
Max flow and min cut Theorem (Ford-Fulkerson, 1956): the maximum FOR e P
possible flow in a network (from source to sink) is exactly equal to the IF (e E)
minimum capacity of all possible cuts. f(e) f(e) + b
ELSE
Ford-Fulkerson algorithm
f(eR) f(e) – b
float Ford_Fulkerson(G,c,s,t)
RETURN f
We will prove the following Theorem: }
{
FOR e E // initialize flow f to 0
Theorem. Assume f is a flow in network. The following three statements are f(e) 0
equivalent Gf residual graph for f
(i) Can find the cut (S, T) such that val( f ) = cap(S, T).
WHILE (there exists an augmenting path P)
(ii) f is maximum flow. {
(iii) Could not find augmenting path to augment value flow f. f augment(f, P)
Update residual graph Gf
}
RETURN f
}
6
Ford – Fulkerson algorithm is not polynomial algoirthm
Augmenting path P: s, 4, 2, t Augmenting path P’: s, 2, 4, t
Contents
Augment flow along P Augment flow along P’ 1. Problem description and applications
G 4 Gf 4
10 X
10
X
0 1
10
2. Cut
10 10
s
9
1X
0X10
9
t s
9
1
9
t
3. Residual graph and Augmenting path
10 10 10 10
4. Ford-Fulkerson algorithm
1X
09 X9 1
0 9 9
2
Gf 4
2 5. Edmond-Karp algorithm
Algorithm executes alternating 1
augmenting flow along two paths P and P’ 109-1 109 6. Some applications
(s, 4) 9
(s, 2) 210 iterations s 1 t
(4, 2)
(2, t ) 109 109 -1
(4, t ) 1
2
7
5. Edmonds – Karp Algorithm Applications
Edmonds and Karp, JACM 1972 • Some general flow problems:
• If the augmenting path is the shortest path from s to t, then • The problem with multiple sources and sinks
the computation time of the algorithm is O(|E|2 |V|). • The problem with limited capacities at nodes
• Airline scheduling
• Image segmentation
• Bipartite matching
• Data mining
• Project selection
• Network connectivity
• …
Ford-Fulkerson algorithm
float Ford_Fulkerson(G,c,s,t)
{
FOR e E // initialize flow to 0
f(e) 0
Gf residual graph for flow f