-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfloid_warsal.c
More file actions
69 lines (65 loc) · 1.33 KB
/
floid_warsal.c
File metadata and controls
69 lines (65 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define SWAP(A,B) (A)=((A)+(B))-((B)=(A))
#define PI 3.141
#define DEBUG printf("lolwa\n")
#define inpd(x) scanf("%d",&x)
int pre[100][100];
int nxt[100][100];
void floid(int n)
{
int i,j,k,min,m,o;
for(k=0;k<n;k++)
{
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(pre[i][j]<(pre[i][k]+pre[k][j]))
{
min=pre[i][j];
}
else
{
min=(pre[i][k]+pre[k][j]);
}
nxt[i][j]=min;
}
}
for(m=0;m<n;m++)
{
for(o=0;o<n;o++)
{
pre[m][o]=nxt[m][o];
nxt[m][o]=0;
}
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("%d\t",pre[i][j]);
}
printf("\n");
}
}
int main()
{
int n,i,j;
printf("enter no of vertex\n");
scanf("%d",&n);
printf("enter adjascentcy matrix\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&pre[i][j]);
nxt[i][j]=0;
}
}
floid(n);
return 0;
}