Chapter 5: Course Graphs Algorithms
Chapter 5: Course Graphs Algorithms
MAXIMUM FLOW
Introduction
Flow networks can model many problems:
Liquids flowing through pipes,
Parts through assembly lines,
Current through electrical networks,
Information through communication
networks.
Introduction
Example: Trucking Problem
The Vancouver factory is
the source s, and the
Winnipeg warehouse is
the sink t .
The company ships
products through
intermediate cities, but
only c(u,v) crates per
day can go from city u to
city v.
Each edge is labeled
with its capacity.
Introduction
Example:
Trucking Problem
A flow f in G with value . Each edge is labeled by.
The slash notation merely separates the flow and capacity; it
does not indicate division.
Definitions
A flow network is a connected directed graph G(V,E)
in which each edge has a nonnegative capacity
It has two specifics vertices for called the source and
one called the sink (termination) of the network.
In most cases, the source vertex s does not have edges
directed toward s (all the edges connected to s are
directed from s to other vertices , means they have the
form
Also, the edges connected to the sink vertex t are
directed toward t, means they have the form .
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 , or each edge has a capacity
The nonnegative quantity assigned to an edge is called
and it represents the used capacity of that edge.
When there can be no flow from to , and =0
Definitions
The assigned flow for an edge should not be greater than the
capacity of this edge. (i.e. constraint of capacity). (not
exceed the given 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.
i.e. the flow-in into a vertex other than the source or sink must
equal the total flow out of that vertex—informally, “flow in equals
flow out.”
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)
The value of a flow f is defined as:
where represents the flow-out of the source s and represents the flow-in o
the source s.
But we have :
Therefore, the value of the network flow f is equal to the value
of the flow of the source s, because we don’t have any losses
during transportation (in the network):
Conclusion:
For each edge in G we have in two edges and based on:
in exists if
exists in Gf if (different than zero)
Example 1
Find the residual graph of the graph G
below.
Example 1
Find the residual graph of the graph G
below.
Example 2
Why it is useful to get ?
Remark: the cost of the flow is calculated using all the edges of the network
having flow’s value different than zero.
Minimum Cost Network Flow Problem
A variant of the max-flow problem
Each edge has capacity and cost :
we must pay as amount of money for each unit flow
flowing through
Problem: find the maximum flow that has the
minimum total cost
Minimum Cost Network Flow Problem
The algorithm of Ford and Fulkerson can solve the
problem of minimum cost network flow.
After getting residual graph, the algorithm needs to
search the path from s to t having the minimum cost
(shortest path to go from s to t).
Minimum Cost Network Flow Problem
Residual in this case?
Minimum Cost Network Flow Problem
The residual graph in this case is determined as:
For each edge in the graph G,
a. If then add edge inwith a flow value equal to , and
unit cost equal to
b. If , then add the edge in with a flow value equal to ,
and unit cost equal to
Minimum Cost Network Flow Problem
1. Initialize flow of all edges to 0 ()
2. Draw on the residual graph
3. Find the shortest path P from the vertex s to the vertex t in (suppose
that the egdes belong to the path P are where
4. If P cannot be found, goto step 8.
5. Find the flow minimum m that can be sent along this path,
0/(300,1) u 0/(300,1) u
0/(500,10) 0/(500,10)
s 0/(500,1) s 0/(500,1)
t t
0/(300,1) v 300/(300,1) v
0/(600,1) 300/(600,1)
Shortest path from s to t:
s,v,t; min=300;
(300,1) u 300/(300,1) u
(500,10) 0/(500,10)
s (500,1)
t s 300/(500,1)
t
(300,-1) v (300,1) 300/(300,1) v 600/(600,1)
(300,-1)
Shortest path from s to t: s,u,v,t; min=300;
(300,-1) u
(500,10) 300/(300,1) u
s (200,1) 0/(500,10)
(200,-1) t s 300/(500,1)
(300,-1) v t
300/(300,1) v 600/(600,1)
(600,-1)
There are no more path from s to t Flow maximum is 600, at minimum cost :
300*1+300*1+300*1+600*1=1500
Minimum Cost Network Flow Problem
Example 2: (4,8)
4 (7,3)
(5,4)
2
(2,5)
1 (3,5)
(5,2) 5 7
(8,2)
3 (3,4)
(2,6) 6
(4,-3)
(4,-4) (4,-8)
4/(4,8) (1,4) 4
4 2 (3,3)
4/(5,4) 2 4/(7,3) (2,5)
0/(2,5) 1 (3,-5)
1 3/(3,5) (2,2) 5 7
3/(5,2) 5 7 (3,2)
5/(8,2) 3 (3,-2) (1,4)
3 (5,-2)
6 2/(3,4)
(2,-6) 6
2/(2,6)
(2,-4)
There are no more path from 1 to 7
4/(4,8)
4
4/(5,4) 2 4/(7,3)
0/(2,5)
1 3/(3,5)
3/(5,2) 5 7
5/(8,2)
3
6 2/(3,4)
2/(2,6)
7 CB=13
11 A B 4
S 3 5 t
9 10
C 4 D
CB B 4
11 A B’ t
S 3 5
9 10
C 4 D