Algorithm Unit 4 This Is A Study Material For Bca Students For Getting Knowledge
Algorithm Unit 4 This Is A Study Material For Bca Students For Getting Knowledge
Multistage Graphs
14 }
The pseudocode of the following program computes the length of the shortest path
from vertex v to each other vertex of the graph. This algorithm is referred to as the
Bellman and Ford algorithm.
11
12
13
15 next++; k++;
16 }
17 if ((k<= h) && ((pair[k].w ==ww)) {
18 if( pp < pair[k].p) pp =pair[k].p; k++;
19 }
20 if ( pp > pair[next - l].p) {
21 pair[next].p=pp; pair[next].w = ww; next++;
22 }
23 while ((k <= h) && (pair[k].p<= pair[nex - l].p))
24 k++;
25 }
26 // Merge in remaining terms from Si-1
27 while (k <= h) {
28 pair[next].p = pair[k].p; pair[next].w:=pair[k].w;
29 next++; k ++;
30 }
31 // Initialize for Si+1.
32 t = h + 1; h =next - 1;b[i + 1] = next;
33 }
34 TraceBack(p, w, pair, x, m, n);
35 }
14
15
16
17