Unit 5 - Multistage Graph
Unit 5 - Multistage Graph
• The multistage graph problem is to find a minimum cost from a source to a sink.
• A multistage graph is a directed graph having a number of multiple stages, where
stages element should be connected consecutively.
• In this multiple stage graph, there is a vertex whose in degree is 0 that is known
as the source. And the vertex with only one out degree is 0 is known as the
destination vertex.
• The one end of the multiple stage graphs is at i, thus the other reaching end is
on i+1 stage.
• If we denote a graph G = (V, E) in which the vertices are partitioned into K >=
2 disjoints sets, Vi, 1 <= i <=K. So that,
• if there is an edge < u, v > from u to v in E, the u £ Vi and v € v (i+1), for some i, 1
<= i <= K.
• And sets V1 and Vk are such that |V1| = |Vk| = 1.
Multistage Graph – Forward method
1. Its a directed weighted
graph
2. Vertices are divided into
multiple stages.
3. Vertices are connected
from 1 stage to next
stage only
4. Find the path that gives
minimum cost (optimum
solution)
5. Solve using dynamic
problem (solve by
making sequence of
decisions)
Multistage Graph – Forward method
1 2 3 4 5 6 7 8 9 10 11 12
cost 16 7 9 18 15 7 5 7 4 2 5 0
D (vertex) 2 or 3 7 6 8 8 10 10 10 12 12 12 12
1. Cost(V5, 12) = 0
2. Cost(V4, 9) = 4
3. Cost(V4, 10) = 2
4. Cost(V4,11) = 5
5. Cost (v3, 6)
6. Cost (v3, 6)
= min{cost (6,9)+cost(9,12),
cost (6,10)+cost(10,12)}
Space Complexity:
• The space complexity of the algorithm is O(V), where V is the number of
vertices in the graph.
• This is because we store the shortest path distances for each vertex in a list
of size V.
• Additionally, we store the graph as an adjacency list, which also requires
O(V) space.
Practice Question:
• Find the shortest path from s to t for the following multistage graph.
• Write an algorithm for the forward approach and find the time complexity.