Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

# Write a routine to reconstruct the shortest paths from the algorithm i.docx

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité

## Consultez-les par la suite

1 sur 2 Publicité

# Write a routine to reconstruct the shortest paths from the algorithm i.docx

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++
}
}
}
.

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++
}
}
}
.

Publicité
Publicité

## Plus De Contenu Connexe

Publicité

### Write a routine to reconstruct the shortest paths from the algorithm i.docx

1. 1. 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++; }
2. 2. index++; } r++ } } }