1 /* Assume a function edgeCost(i,j) which returns the cost of the edge from i to j 2 (infinity if there is none). 3 Also assume that n is the number of vertices and edgeCost(i,i)=0 4 */ 5 6 int path[][]; 7 /* A 2-dimensional matrix. At each step in the algorithm, path[i][j] is the shortest path 8 from i to j using intermediate vertices (1..k-1). Each path[i][j] is initialized to 9 edgeCost(i,j) or infinity if there is no edge between i and j. 10 */ 11 12 procedure FloydWarshall () 13 for k: = 1 to n 14 for each (i,j) in {1,..,n}2 15 path[i][j] = min ( path[i][j], path[i][k]+path[k][j] );
Warshall algorithm
29 March,09 · Leave a Comment
Categories: Uncategorized
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.