Professional Documents
Culture Documents
Floyd Warshall's Algorithm
Floyd Warshall's Algorithm
h>
#include<stdlib.h>
return x < y ? x : y;
// Solves the all-pairs shortest path problem using Floyd Warshall algorithm
int i, j, k;
printSolution(dist,V);
int i,j;
if (dist[i][j] == INF)
printf("%7s", "INF");
else
printf("\n");
}
// driver program to test above function
int main()
int **graph;
int i,j,V,edges,snode,enode,weight;
scanf("%d",&V);
scanf("%d",&edges);
for(i=0;i<V;i++)
for(i = 0;i<V;i++){
for(j = 0;j<V;j++){
*(*(graph+i)+j) = (i==j)?0:INF;
for(i = 0;i<edges;i++)
printf("Enter the start node, end node and weight of edge no %d\n",i);
scanf("%d%d%d",&snode,&enode,&weight);
*(*(graph+snode)+enode) = weight;
floydWarshell(graph,V);
return 0;
}