Network Models 00 - Maximum Flow - Shortest Path
Network Models 00 - Maximum Flow - Shortest Path
Prepared by:
Dr. Eng. Moustafa R. A. Eltantawi
NetworkModel-6
Network Terminology
• In a directed network with flow, the arc capacity is the maximum flow allowed on an arc.
• A supply node (or source node) has net flow out of the node.
• A demand node (or sink node) has net flow into the node.
• A transshipment node (or intermediate node) satisfies conservation of flow; flow in equals flow
out.
A
3 Sink
5 1 9 (Demand)
7 4 D
B
Source
6
(Supply) 4 2 5 1
4 E
C
NetworkModel-7
Maximal-Flow Technique
Definition:
The maximal-flow technique finds the maximum
flow of any quantity or substance through a network.
For example:
This technique can determine the maximum
number of vehicles (cars, trucks, etc.) that can go
through a network of roads from one location to
another.
12-8
Maximal-Flow Technique
• The maximal-flow technique allows us to determine the maximum
amount of a material that can flow through a network
• Waukesha Wisconsin is in the process of developing a road system
for the downtown area
• The City Planners would like to determine the maximum number of
cars that can flow through the town from west to east
• The road network is shown in Example 1.
• The numbers by the nodes indicate the number of cars that can
flow from the node
The Augmenting Path Algorithm for
the Maximum Flow Problem
1. Identify a flow augmenting path in the residual network (initially
the original network), by checking all nodes connected to the
source node with residual capacity along the arcs.
If no augmenting path exists, the current flow is optimal.
2. Identify the residual capacity c* of this augmenting path by
finding the minimum residual capacities along all arcs in the path.
Increase the flow in this path by c*.
1 4
4 2
3
5
A 3 B
3 6
2 3
1
2 5
Illustrative Example 2:
1 4
1 4 2
3
5
A 3 B
6
3 2 3
1
2 5
Illustrative Example 2:
1 4
1 3
4 2
5
A 3 B
2
2 6
2 3
3 0
1
2 5
Illustrative Example 2:
1 4
1 3
4 2
5
2 A 3 B
6
3 2
3
2
2
2 5
1
0
Illustrative Example 2:
1 4
1 3
4 2
5
2 A 3 B
3 2
6
3
2 4 0
2
0 2 5
0
1
0
Illustrative Example 2:
1 4
1 3 4 2 5
2 A 3 B
2 3
6 2
3
2 4 0
2
0 2 5
0
1
0
Illustrative Example 2:
1 4
1
2 3 4 2 5
2 0 3
2 A 1 3 B
5 3
6 2
Max
3
2 4 0
2
0 2 5
Flow 1
0
0
Exercise 01
Road network for Waukesha
2 2 6 East
Point
3
1
West 1
1 2
Point 4 6
1
10
3 5
Copyright © 2012 Pearson Education 11-35
2
Exercise 02
Capacity in Hundreds of Cars per Hour
7 5
A D Sink
2 2
4
5
Source B 1
7
1
4 3
C E
4
Copyright © 2012 Pearson Education 11-36
Shortest-Path/Routing Problem
Given a graph and a source
vertex in this graph,
Find:
shortest paths from source to
all vertices in the given graph?
Copyright © 2012 Pearson Education 11-37
Algorithm for Shortest Path Problem
• Start with the source, or origin. Label it with zero
distance from origin. It is now called a solved node.
• Find the next nearest node: do this by:
• Consider all unsolved (unlabeled) nodes that are directly connected to a
solved (labelled) node – these are the candidate nodes.
• For each candidate, calculate the distance to origin by adding the branch
distance to the labelled distance.
• Find the minimum distance, and label that node with the distance and the
preceding node. This node is now called a solved node.
• Repeatuntil the destination becomes a solved node.
The shortest route can then be traced backwards. NetworkModel-38
Dijkstra’s Shortest-Path Algorithm
• Iterative algorithm
• After k iterations, know least-cost path to k nodes
Zero
Iteration
Pick the vertex with minimum distance value and not already included in
SPT (not in sptSet). The 2nd Iteration picks Vertex 7. So sptSet now
becomes {0, 1, 7}. Update the distance values of adjacent vertices of 7. The
distance
45
value of vertex 6 and 8 becomes finite (15 and 9 respectively).
Dijkstra’s Algorithm Example 01
The Original Graph Zero Iteration
3rd Iteration
2nd Iteration
1st Iteration
Pick the vertex with minimum distance value and not already
included in SPT (not in sptSet). The 3rd Iteration picks Vertex 6. So
sptSet now becomes {0, 1, 7, 6}. Update the distance values of
adjacent vertices of 6. The distance value of vertex 5 and 8 are
updated.
46
Dijkstra’s Algorithm Example 01
The Original Graph Zero Iteration 2nd Iteration Successive Iterations
1st Iteration
3rd Iteration
3 5 3 5 3 5
1
3 4 3 6 3 6
0 0 0
5 5 8
2 3 2 3 2
6 6 6
6th Iteration 7th Iteration 8th Iteration
50
Exercise 01
• Find the shortest path between Source and Sink.
• Idea is to start with the source, or origin, and find the shortest
path to each of the nodes in the network sequentially until the
destination is reached.
7 5
A D Sink
2 2
4
5
Source B 1
7
1
3
4
C E
4 NetworkModel-51