Warshall Algorithm
Warshall Algorithm
all the pairs of vertices in a weighted graph. This algorithm works for both the
directed and undirected weighted graphs. But, it does not work for the graphs
with negative cycles (where the sum of the edges in a cycle is negative).This
paths.
CODE:
#include <stdio.h>
#include <stdlib.h>
int i, j, k;
{
if (graph[i][j] > graph[i][k] + graph[k][j])
int main(void)
int n, i, j;
scanf("%d", &n);
{
if (i == j)
graph[i][j] = 0;
else
graph[i][j] = 100;
scanf("%d", &graph[i][j]);
printf("\n");
floydWarshall(graph, n);
printf("\n");
return 0;
}
Example From Slide: