0% found this document useful (0 votes)
3 views

Unit 5 - Multistage Graph

Uploaded by

w8nng9rhhf
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Unit 5 - Multistage Graph

Uploaded by

w8nng9rhhf
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

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)}

The cost of (v3,6) is updated in the table


at 6.
The same process would be repeated till
node (V1,1) and the cost will be updated
in the table accordingly
Algorithm: forward approach
Complexity Analysis
• The time complexity of the multistage graph shortest path algorithm
depends on the number of vertices and the number of stages in the graph. If
we traverse this graph using nested loop then:
• The outer loop iterates over the stages, which takes O(K) time.
• The inner loop iterates over the vertices in each stage, and for each vertex, it
examines its adjacent vertices.
• Since the graph is represented as an adjacency list / matrix, this takes O(E)
time, where E is the number of edges in the graph. Therefore, the total time
complexity of the algorithm is O(KE).

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.

You might also like