You are on page 1of 18

Summary Chapter 5

Maximum Flow
Definitions
• A flow network is a directed graph G(V,E). It has
two specifics vertices for called the source and
one called the sink (termination) of the network.
• In most cases, the source vertex do not have edges
directed toward s (all the edges connected to s are
directed from s to other vertices , i.e. (s,u) where
u 𝜖 E). Also, the edges connected to the vertex t
are directed toward t, means they have the form
(u,t) where u 𝜖 E.
Definitions
• Flow networks can model many problems,
including liquids flowing through pipes, parts
through assembly lines, current through
electrical networks, and information through
communication networks.
Definitions
• In a directed graph the value on each edge is the
maximum flow that can be transported along this edge.
These values are called the capacities of the edges. Each
edge 𝑒𝑖 has a capacity value 𝑐 𝑒𝑖 .
• The assigned flow for an edge should not be greater than
the capacity of this edge. (i.e. 𝑓(𝑒𝑖 ) ≤ 𝑐 𝑒𝑖 constraint
of capacity). A Network with all edges are respecting
this property is called a compatible network.
• the flow enters in each vertex must equal to the flow
leaving this vertex. We call this property “flow
conservation”. This is applied for all vertices except for
s and t.
Example
• In the Network flow below, the flow
conservation concepts is verified.
• Input flow of x =output flow of x :(1+3=0+2+2)
• Input flow of z= output flow of z: (3+2=3+2)
Definitions
• For s and t, the sum of the output flows of s should be equal to
the sum of the input flows of t (because we don’t have any
losses during transportation from s to t). This sum is called the
flow of the network.
• for example, the flow of the network in the figure is equal to 9
• 𝑓𝑙𝑜𝑤 = 𝑓 𝑠, 𝑥 + 𝑓 𝑠, 𝑤 + 𝑓( 𝑠, 𝑦 )=2+3+4=9, it is also
equal to 𝑓 𝑥, 𝑡 + 𝑓 𝑧, 𝑡 = 6 + 3 = 9
Definitions
• A Network flow is complete, if each path from
s to t contains at least one saturate edge. An
edge is called saturated if the flow of this edge
is equal to its capacity (meaning we cannot
increase the flow value of the edge).
Maximum Flow problem
• In the maximum-flow problem we wish to
compute the greatest rate at which we can ship
material from the source to the sink without
violating any capacity constraints.
Algorithm Ford and Fulkerson
• This algorithm finds the maximum flow that
can be transported through the edges of a
given Network. The algorithm shows the flows
assigned to all the edges of the network.
• The algorithm uses the concept of residual
graph noted as Gf.
• How we can build such graph? Please refer to
next slide.
Algorithm Ford and Fulkerson
• Residual Graph Gf(V,Ef)
• Gf has the same vertices as G, however it has
different edges. the values on the edges of Gf
are the residual flows that can be assigned to
each edge.
• How we can determine the set of edges of Gf?
• For each edge ei = (𝑢, 𝑣)in the graph G,
a. if c ei − 𝑓 𝑒𝑖 > 0 Then add ei = (𝑢, 𝑣) in
Gf with a flow value equal to c ei − 𝑓 𝑒𝑖 .
b. if 𝑓 𝑒𝑖 > 0 Then add the edge (𝑣, 𝑢)in Gf
with a flow value equal to 𝑓 𝑒𝑖
Example

Conclusion:
For each edge (u,v) in G we have in Gf two edges (u,v) and (v,u)
based on:
• (u,v) in Gf exists if c((u,v))-f((u,v))>0.
• (v,u) exists in Gf if f(u,v)>0 (f(u,v) different than zero)
Algorithm Ford and Fulkerson
1. Initialize flow of all edges to 0 (𝑓 𝑒𝑖 = 0; ∀𝑒𝑖 ∈ 𝐸)
2. Draw on the residual graph 𝐺𝑓
3. Find a path P from the vertex s to the vertex t in 𝐺𝑓 , suppose
that the egdes belong to the path P are 𝑒𝑖 where 𝑖 = 1, … 𝑘.
4. If P cannot be found, goto step 7.
5. Find the flow minimum m that can be transported along this
path, 𝑚 = min 𝑓 𝑒𝑖 ;
𝑖∈1,…,𝑘
6. Apply m to the flows in the graph G as follow:
i. If 𝑒𝑖 ∈ 𝐸 then 𝑓 𝑒𝑖 = 𝑓 𝑒𝑖 + 𝑚
ii. Else (𝑒𝑖 ∉ 𝐸 ) then this is a residual edge,
𝑓 𝑒𝑖 = 𝑓 𝑒𝑖 − 𝑚
7. Goto step 2
8. End of the algorithm
Example
• Given the graph
shown in the figure,
determine the flow
maximum of this
network using the
algorithm of Ford and
Fulkerson.
Example 2
Gf G

The shaded lines are the edges


of the chosen path.
* Path 1: s,v1,v3,v2,v4,t
m=min(16,12,9,14,4)=4
*path 2: s,v1,v2,v4,v3,t
m=min(12,10,10,7,20)=7
*path 3: s,v2,v1,v3,t
m=min(13,11,8,13)=8
*path 4:s,v2,v3,t
m=min(5,4,5)=4
The final network is the
network with maximal flow
which is equal to : 11+12=23
Cost of flow network
• In some applications, each edge in the network are
associated with a number that represents the cost of
transferring one unit of flow through this edge. The cost
could of time units, money unit, etc.…
• Example: calculate the cost of transferring the flow showing
in the graph.
• Cost= 𝑒𝑖∈𝐸 𝑓 𝑒𝑖 ∗ 𝑐𝑜𝑠𝑡 𝑒𝑖 = 4 ∗ 2 + 3 ∗ 3 + 4 ∗ 1 + 3 ∗
2 + 4 ∗ 5 = 47
• Remark:
the cost of the flow will be is calculated using all the edges of
the network having flow’s value different than zero.

You might also like