// All pairs shortest paths problem // Sequential version // Written by M. Eggen #include #include #include #define infinity 1000000 int GetSize(char *filename); int **Allocate(int n); void Fill(int **adjmat, int n, char *filename); void Display(int **adjmat, int n); int **Floyd(int **adjmat, int n); int min(int a, int b); main(int argc, char **argv) { int **adjmat, **shortpath, n; char filename[20]; // get the name of the file from command line or user if (argc != 2) { printf("Please enter name of file containing adjacency matrix: "); scanf("%s",filename); } else strcpy(filename, argv[1]); n = GetSize(filename); printf("%d by %d\n",n,n); adjmat = Allocate(n); Fill(adjmat,n,filename); Display(adjmat,n); getchar(); shortpath = Floyd(adjmat,n); Display(shortpath,n); } int **Floyd(int **adjmat, int n) { int **I[20]; int i,j,k; for(i=0;i<20;i++) { I[i] = Allocate(n); } /******************* for boolean matrices ************************** for(i=0;i