Click to See Complete Forum and Search --> : floyd's algorithm
gammaman
March 23rd, 2009, 04:25 PM
In the Floyd’s Algorithm, how do I compute the shortest distance d(i,j) between node I and node J?
Can someone please explain this, I know the concept of floyd, and can compute floyd steps based on a digraph but I do not understand this question.
Peter_APIIT
March 23rd, 2009, 09:50 PM
The idea of floyd algorithm is using dynamic programming which consists of two concept which are Memorization and bottom up approach.
So, Floyd algorithm calculate node i to j through some intermediate node and in case there are shorter path between i, intermediate node and j, then update it.
ahoodin
March 24th, 2009, 12:05 AM
Here is the algorithm:
int i=0, j =0,k=0,n=MAX;
int path[MAX][MAX] = {...};//Initialize your matrix here.
for (k = 1; k <= n; k++)
{
for (i = 1; i <= n; i++)
for (j = 1; j <= n; j++)
path[i][j] = min ( path[i][j], path[i][k]+path[k][j] );
}
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.