'How to implement floyds Algorythm and get the nodes in between
I am trying to get the shortes routes and the nodes in between given a graph. My graph represented using adjacency matrix is this one Adjacency Matrix. Now I need to get the shortest routes to get from a node to another and the nodes I need to go through to get my destination, the implementation of the floyd algorithm is this:
public float[][] FloydAlgo (float[][] Graph){
float[][] matrix = Graph;
int i,j,k;
for(k=0;k< Graph.length;k++){
for(i=0;i<Graph.length;i++){
for(j=0;j< Graph.length;j++){
if(matrix[i][k] + matrix[k][j] < matrix[i][j]){
matrix[i][j] = matrix[i][k] + matrix[k][j];
}
}
}
}
return matrix;
}
But, when I get the matrix of the algorythm, all positions are 0.0, is this correct? What am I doing wrong? please help!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
