0

I'm working on a Floyd's Algorithm type Java program.

What I have done so far is represent a directed graph in a 2d array, and I am trying to transform that into a 2d array representing the graph's paths of length 2.

I planned for it to fill the adj2[][] array to represent the graph's paths of length 2 which should be:

0 0 2 0 0

2 0 0 2 0

0 2 0 0 2

0 2 2 0 0

0 0 2 0 0

However, when I go to print out the adj2[][] array, it just comes up as containing all zeros.

Any help on why this isn't working would be greatly appreciated!

This is what I have right now:

```
int adj[][] = {{0,1,0,0,0},
{0,0,1,0,0},
{1,0,0,1,0},
{0,1,0,0,1},
{0,1,0,0,0}};
int adj2[][] = new int[5][5];
int path = 0;
for (int n = 0; n < adj2.length; n++) {
for (int m = 0; m < adj2.length; m++) {
for (int i = 0; i < adj2.length; i++) {
for (int j = 0; j < adj2.length; j++) {
path += adj[i][j]*adj[j][i];
}
if (path > 0) {
adj2[n][m] = 2;
}
}
}
}
for (int a = 0; a < adj2.length; a++) {
for (int b = 0; b < adj2.length; b++) {
System.out.print(adj2[a][b] + " ");
}
System.out.println();
}
```

*Edited
by nola_Coder*: n/a