A Multistage graph is a directed, weighted graph in which the nodes are divided into stages, and all edges are from one stage to the next (In other words, there is no edge between vertices of the same stage and from a vertex of the current stage to the previous stage).
This problem can be solved by dynamic programming.
Multi-staged graph means the vertices are arranged and connected with directed edges with weight.
This is specially used for representing resource allocation
For this graph, we will try to find out the shortest or minimum cost path. This graph is a multi-staged graph. There are 5 stages in the graph. Our starting node is 1, and the terminal or destination is 12.
For the calculation of the cost of this graph, we will use the following equation,
Cost(i, j)= min{c(j, l)+ Cost(i+1, l)}
Here,
i = the stage number of the vertex
j = the vertex number
l= if there is any vertex in between the final vertex then that vertex number.
Cost(i, j)= min{c(j, l)+ Cost(i+1, l)}
Cost(5, 12)= 0
Cost(4, 9)= 4
Cost(4, 10)= 2
Cost(4, 11)= 5
Cost(3, 6)= min{c(6, 9)+ Cost(4, 9), c(6, 10)+ Cost(4, 10) }
= min (10, 7)= So, the min cost is 7, and the vertex is 10
Cost(3, 7)= min{c(7, 9)+ Cost(4, 9), c(7, 10)+ Cost(4, 10) }
= min (8, 7)= So, the min cost is 7, and the vertex is 10
Cost(3, 8)= min{c(8, 10)+ Cost(4, 10), c(8, 11)+ Cost(4, 11) }
= min (7, 11)= So, the min cost is 7, and the vertex is 10
Cost(2, 2)= min{c(2, 6)+ Cost(3, 6), c(2, 7)+ Cost(3, 7), c(2, 8)+ Cost(3, 8) }
= min (11, 7, 8)= So, the min cost is 7, and the vertex is 7
Cost(2, 3)= min{c(3, 6)+ Cost(3, 6), c(3, 7)+ Cost(3, 7)}
= min (9, 12)= So, the min cost is 9, and the vertex is 6
Cost(2, 4)= min{c(4, 8)+ Cost(3, 8)}
= 18 = So, the min cost is 18, and the vertex is 8
Cost(2, 5)= min{c(5, 7)+ Cost(3, 7), c(5, 8)+ Cost(3, 8)}
= min (16, 15)= So, the min cost is 16, and the vertex is 8
Cost(1, 1)= min{c(1, 2)+ Cost(2, 2), c(1, 3)+ Cost(2, 3), c(1, 4)+ Cost(2, 4), c(1, 5)+ Cost(2, 5)}
= min (16, 16, 21, 16)= So, the min cost is 16, and the vertex is 2 or 3 or 5
d(i, j) = d [ v ]
We have three approaches which give us a minimum cost of 1 to 12.
So, if we select 2 from vertex 1
d (1, 1) = 2
d (2, 2) = 7
d (3, 7) = 10
d (4, 10) = 12
if we select 3 from vertex 1
d (1, 1) = 3
d (2, 3) = 6
d (3, 6) = 10
d (4, 10) = 12
if we select 5 from vertex 1
d (1, 1) = 5
d (2, 5) =8
d (3, 8) = 10
d (4, 10) = 12