You are on page 1of 1

visit-www.Codes2u.

com
#include<conio.h>
#include<stdio.h>
void main()
{
int d[100][100],i,j,k,n;
clrscr();
printf("enter the no. of nodes in graph");
scanf("%d",&n);
printf("\n enter the graph matrix or adjency matrix");
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
scanf("%d",&d[i][j]);
}
/* computaation*/
for(k=1;k<=n;k++)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(d[i][j]>d[i][k]+d[k][j])
{
d[i][j]=d[i][k]+d[k][j];
}
}
}
}
printf("\n the output of floyed warshell graph is\n");
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
printf("%d\t",d[i][j]);
}
}
getch();
}

You might also like