Professional Documents
Culture Documents
Discrete Math 2
htthua@ptithcm.edu.vn
Content
• Definitions
• Maximum flow problem
• Ford-Fulkerson algorithm to find the maximum
flow
2
Definitions
Network
• Definition 1: The network is a directed graph G = (X,U) with no rings, where:
(1) There is only one vertex with no input arc, called the transmitting vertex, denoted x 0 .
(2) There is only one vertex with no outgoing arc, called the receiver vertex, denoted z.
(3) Each arc u U, is assigned a non-negative weight, denoted c(u)≥0, called the
throughability (bandwidth) of that arc.
Symbol: U– (x) = The set of arcs entering the vertex x; U+ (x) = Set of arcs
coming out from vertex x.
– We have: U– ( x 0 ) = ; U+ ( z ) =
4
Stream
• Definition 2: Given a network G = (X,U) with emitter vertex x0 , receiver z,
and throughput c(u), u U:
– (1) A flow on a network G is a non-negative function defined on U into R+, i.e. :U→R+,
u → (u)
Φ(u) is called the stream value Φ on arc u , satisfying the following conditions:
• Condition on arc : The flow per arc does not exceed the pass capacity on arc: 0≤ Φ(u) c(u ), uU
• Equilibrium condition on each vertex : Total value of flow on arcs entering each vertex (minus x 0 and z)
= Sum value of flow on arcs leaving that vertex:
5
Slice
• Definition 3: A slice (A, A') is a way of partitioning the vertex set X=A A' such
that A A'= and A contains x0 , A' contains z
– Passability of the slice (A, A') , denoted c(A, A') :
– The slice with the smallest passability is called the narrowest slice.
• Theorem 1 : The value of every stream Φ in the network is always less than or
equal to the pass capacity of any slice (A, A') in the network: 𝑣𝑎𝑙 () 𝑐 (A, A')
– Corollary : The value of the maximum flow in the network is equal to the throughput of the
narrowest slice in the network.
6
Maximum flow problem
Maximum flow problem
• Problem: Let the network G=(X,U). Find the flow Φ* on the network G such
that the value Val(Φ*) is maximum .
Note:
To find the maximum flow value:
1) Method 1: List all the slices on the G network and calculate the passability of these slices
to find the narrowest slice (which is the maximum flow value).
2) Method 2: If we know the maximum flow on G, we can determine the narrowest slice
from the Ford–Fulkerson Algorithm.
• Practical application:
– Consider the directed graph corresponding to the oil pipeline system
– The oil pipes correspond to the arcs of the graph
– The sending point is an oil tanker , the receiving point is an oil tank
– The junction between the pipes corresponds to the vertices of the graph
– The throughput of the arcs corresponding to the cross-section of the tubes
– Need to find the largest flow of oil that can be pumped from the tanker to the storage tank?
8
Example of Massive Flow Problem
9
Ford-Fulkerson algorithm to find
the maximum flow
flow increasing Graph, flow increasing Path
• Suppose f is a flow in the network G=(V,E). Construct the weight
graph G f = (V,E f ) with arc set E f is determined by the following
rule: Consider e =(u,v) E
– If f(u,v)<c(u,v), then (u,v ) E f with weight c(u,v) - f(u,v)
• can increase the flow f on arc (u,v) with a maximum value of c(u,v) - f (u,v);
• The arc (u,v) is called the forward arc on Gf
– If f(u,v) >0, then (v ,u) E f with weight f(u,v)
• can reduce the flow f on arc (u,v) with a maximum value of f (u,v);
• The arc (v,u) is called the inverse arc on Gf .
• G f is called a flow increasing graph and any path from s to t on a
flow increasing graph G f is called a flow increasing graph f .
11
Example: Flow increasing graph
12
Increase flow along the PATH
13
Example: Increase flow
by path
14
Flow Increase Path
15
The Ford-Fulkerson algorithm
1. Starting from a flow (any)- can be a flow 0
2. Build flow increasing graph Gf
3. From Gf, find a flow increasing path P
a) If there is no flow increasing path, ending .
b) If there is a flow increase path, then build new flow f’
4. Repeat the above process until no new flow increasing path can
be found.
16
The Ford-Fulkerson algorithm
• Example: Find the maximum flow in the following network G (s=1, t=4):
4,
2 (0) 3
6 3
,(0) 2 ,(0) ,(0)
fir 1 1 ,(0) 4
st ,(0)
5 6
,(0) 6 5 ,(0)
4 ,(0)
17
The Ford-Fulkerson algorithm
• Example: Find the maximum flow in the following network (s=1,t=4): (ct.)
18
The Ford-Fulkerson algorithm
• Example: Find the maximum flow in the following network (s=1,t=4): (ct.)
19
The Ford-Fulkerson algorithm
• Example: Find the maximum flow in the following network (s=1,t=4): (ct.)
20
The Ford-Fulkerson algorithm
• Example: Find the maximum flow in the following network (s=1,t=4): (ct.)
21
The Ford-Fulkerson algorithm
• Example: Find the maximum flow in the following network (s=1,t=4): (ct.)
23
Ford-Fulkerson Algorithm - Implementation
Flow-increasing Pathfinding Algorithm Stream increase algorithm
int Find_Path() { void Inc_Flow() {
assign all vertices unvisited; v=p[t]; u=t; tang=d[t];
while (u!=s){
queue= ; queue s ; p[s]=s ; d[s]=+vc ; parameter[s]=true;
if (v>0) f[v,u] = f[v,u] + tang;
while (queue!= ){ else{
u queue; v = -v; f[u,v] = f[u,v] - tang;
for (v sour greed) { }
if ( (c[u,v]>0)&&( f[u,v] <c[u,v]) ){ // G f has an equal arc (u,v) u = v; v = p[u];
}
p[v]=u; d[v]=min {d[u], c[u,v] – f[u,v]};
}
if (v == t) return 1;
queue ; parameter[v]=true;
Maximum flow finding algorithm
} void Max_Flow()
if ( (c[v,u]>0)&&(f[v,u]>0){ //coordinate (u,v) {//are you in a position?
p[v]=-u; d[v]=min {d[u], f[v,u]} ; for (u V )
If (v == t) return 1; for (v V) f(u,v)=0;
stop=0;
queue v; parameter[v]=true;
while (!stop)
} if (Find_Path()) Inc_Flow();
} else stop=1;
} }
return 0;
}
24
Exercise 1
• Let's apply the Ford-Fulkerson Algorithm to find the maximal flow f * from the
flow f on this network. Then determine a narrowest slice of the network G.
26