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

Multistage Graphs 1

The document describes an algorithm for finding the shortest cost journey through a multistage graph from a source node to a target node. It provides an example 6-stage graph with 15 nodes and cost values between each node. The algorithm is simulated step-by-step using both backward and forward costs to calculate the minimum cost path from the source to each node at each stage. The shortest path from node 1 to node 15 had a total cost of 50.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
263 views

Multistage Graphs 1

The document describes an algorithm for finding the shortest cost journey through a multistage graph from a source node to a target node. It provides an example 6-stage graph with 15 nodes and cost values between each node. The algorithm is simulated step-by-step using both backward and forward costs to calculate the minimum cost path from the source to each node at each stage. The shortest path from node 1 to node 15 had a total cost of 50.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

MULTISTAGE GRAPHS

The shortest cost journey from the source


to a target in a graph with stages.
SAMPLE GRAPH AND SIMULATION OF THE
ALGORITHM
Stage
I

Stage
II

Stage
III

Stage
IV

Stage
V

Stage
VI

8
2

121

5
9

131

6
101

141
111

151

THE COST MATRIX IS GIVEN BELOW


I
1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

II
2
10

3
20

III
4
30

IV

10
40

20

30
50
30

40

10

11

10

20
20

30
30
30

40

VI

12

13

14

10

20
20
10
10

30
10
20
30

15

20

20
10
30

SIMULATION OF THE SOLUTION


USING BACKWARD COSTS
Format: COST(stage, node) = minimum cost of traveling to the node in stage
from the source(node 1).
STEP I
COST(I,1) = 0
STEP II
COST(II,2) = COST(I,1) + cost(1,2) = 0 + 10 = 10
COST(II,3) = COST(I,1) + cost(1,3) = 0 + 20 = 20
COST(II,4) = COST(I,1) + cost(1,4) = 0 + 30 = 30
STEP III
COST(III,5) = min{COST(II,2) + cost(2,5),
COST(II,3) + cost(3,5),
COST(II,4) + cost(4,5)}
=min{10 +10, 20+40, 30+}
= 20---via the path 1-2-5
COST(III,6) = min{COST(II,2) + cost(2,6),
COST(II,3) + cost(3,6),
COST(II,4) + cost(4,6)}

=min{10 +20, 20+, 30+40}


= 20---via the path 1-3-6
COST(III,7) = min{COST(II,2) + cost(2,7),
COST(II,3) + cost(3,7),
COST(II,4) + cost(4,7)}
=min{10 +30, 20+50, 30+30}
= 40---via the path 1-2-7
STEP IV
COST(IV,8)=min{COST(III,5) + cost(5,8),
COST(III,6) + cost(6,8),
COST(III,7) + cost(7,8)}
=min{20+10, 20+ ,40+ }
=30---via the path 1-2-5-8
COST(IV,9)=min{COST(III,5) + cost(5,9),
COST(III,6) + cost(6,9),
COST(III,7) + cost(7,9)}
=min{20+20, 20+20 ,40+ }
=40---via the path 1-2-5-9 or via the path 1-3-6-9
COST(IV,10)=min{COST(III,5) + cost(5,10),
COST(III,6) + cost(6,10),
COST(III,7) + cost(7,10)}
=min{20+10, 20+ ,40+ }
=30---via the path 1-2-5-10
COST(IV,11)=min{COST(III,5) + cost(5,11),
COST(III,6) + cost(6,11),
COST(III,7) + cost(7,11)}
=min{20+30, 20+30 ,40+30 }
=50---via the path 1-2-5-11 or via the path 1-3-6-11
STEP V
COST(V,12)=min{COST(IV,8) + cost(8,12),
COST(IV,9) + cost(9,12),
COST(IV,10) + cost(10,12),
COST(IV,11) + cost(11,12)}
=min{30+10 ,40+ ,30+,50+}

= 40via the path 1-2-5-8-12


COST(V,13)=min{COST(IV,8) + cost(8,13),
COST(IV,9) + cost(9,13),
COST(IV,10) + cost(10,13),
COST(IV,11) + cost(11,13)}
=min{30+20 ,40+20 ,30+10,50+10}
= 40via the path 1-2-5-8-13
COST(V,14)=min{COST(IV,8) + cost(8,14),
COST(IV,9) + cost(9,14),
COST(IV,10) + cost(10,14),
COST(IV,11) + cost(11,14)}
=min{30+30 ,40+10 ,30+20,50+30}
=50---via the path 1-2-5-10-14 or via 1-2-5-9-14 or 1-3-6-9-14
STEP VI
COST(VI,15)=min{COST(V,12)+cost(12,15),
COST(V,13)+cost(13,15),
COST(V,14)+cost(14,15)}
=min{40+20 ,40+10 ,50+30}
=50---via the path 1-2-5-8-13-15

SIMULATION OF THE SOLUTION


USING FORWARD COSTS
FORMAT: COST(stage, node)=minimum cost of travel from the node in stage
to the target.

SAMPLE GRAPH AND SIMULATION OF THE


ALGORITHM

Stage
I

Stage
II

Stage
III

Stage
IV

Stage
V

Stage
VI

8
2

121

5
9

131

151

101
7

141
111

THE COST MATRIX IS GIVEN BELOW


I
1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

II
2
10

3
20

STEP I
COST(V,12)=20
COST(V,13)=10
COST(V,14)=30
STEP II

III
4
30

IV

10
40

20

30
50
30

40

10

11

10

20
20

30
30
30

40

VI

12

13

14

10

20
20
10
10

30
10
20
30

15

20

20
10
30

COST(IV,8) = min{ 10 + COST(V,12), 20 + COST(V,13), 30 + COST(V,14)}


= min{10 + 20, 20 + 10, 30 + 30}
= 30via the path 8-12-15 or via the path 8-13-15
COST(IV,9) = min{ 20 + COST(V,13), 10 + COST(V,14)}
= min{20 +10, 10 + 30}
= 30---via the path 9-13-15
COST(IV,10)=min{ 10 + COST(V,13), 20 + COST(V,14)}
=min{ 10 + 10, 20 + 30}
= 20---via the path 10-13-15
COST(IV,11)=min{ 10 + COST(V,13), 30 + COST(V,14)}
=min{ 10 + 10. 30 + 30}
= 20---via the path 11-13-15
STEP III
COST(III,5)=min{ 10 + COST(IV,8), 20 + COST(IV,9), 30 + COST(IV,10), 40 +
COST(IV,11)}
= min{ 10 + 30, 20 + 30, 30 + 20, 40 + 20}
= 40---via the path 5-8-12-15 or 5-8-13-15
COST(III,6) = min{ 20 + COST(IV,9), 30 + COST(IV,10)}
=min{ 20 + 30, 30 + 20}
= 50---via the path 6-9-13-15 or 6-10-13-15
COST(III,7) = min{ 30 + COST(IV,10), 20 + COST(IV,11)}
= min{ 30 + 20, 20 + 20}
= 40---via the path 7-11-13-15
STEP Iv
COST(II,2)=min{10 + COST(III,5), 20 + COST(III,6), 30 + COST(III,7)}
=min{10 + 40, 20 + 50, 30 + 40}
=50----via the path 2-5-8-12-15 or 2-5-8-13-15
COST(II,3)=min{ 40 + COST(III,5), 50 + COST(III,7)}
=min{ 40 + 40, 50 + 40}
= 80---via the path 3-5-8-12-15 or 3-5-8-13-15
COST(II,4)=min{ 40 + COST(III,6), 30 + COST(III,7)}
=min{ 40 + 50, 30 + 40}
= 70---via the path 4-7-11-13-15
STEP V
COST(I,1)=min{ 10 + COST(II,2), 20 + COST(II,3), 30 + COST(II,4)}
=min{ 10 + 50, 20 + 80, 30 + 70}
=50---via the path 1-2-5-8-12-15 or via the path 1-2-5-8-13-15

You might also like