Write a routine to reconstruct the shortest paths from the algorithm in the Textbook, Section 10.3.4.
Solution
public static void allPair(in[][] a, int[][] d, int[][] paths)
{
int len = a.length;
int index = 0,q=0,r;
while(index<len)
{
while(q<len)
{
d[index][q] = a[index][q];
paths[index][q] = NOT_A_VERTEX;
q++;;
}
index++;
}
while(r<len)
{
while(index<len)
{
while(q<len)
{
if(d[index][r] + d[r][q] < d[index][q] )
{
d[index][q] = d[index][r] + d[r][q];
paths[index][q] = r;
q++;
}
index++;
}
r++
}
}
}
.