int main(void) { int relation[NUM][NUM] = {{0}}; int table[NUM][NUM]; int n; int i, j, k; int time; clock_t start, end; scanf("%d", &n); arr_input(relation, n); relation_own(relation, n); for ( i = 0; i < n; i++ ) { /* for ( k = 0; k < NUM; k++ ) { */ /* for ( j = 0; j < NUM; j++ ) { */ /* table[k][j] = 0; */ /* } */ /* } */ time = 100000; start = clock(); while (time--) { warshall(relation, table, i+1); } end = clock(); printf("%d : %f\n", i+1, (0.0+end-start)/CLOCKS_PER_SEC); } arr_output(table, n); return 0; }
int main(void) { //와셜알고리즘을 수행하기 위한 행렬을 만듬 int Matrix[4][4]={ {0, 1, 0, 0}, {1, 0, 1, 0}, {0, 0, 0, 1}, {0, 0, 0, 0} }; int i, j; //와셜알고리즘을 수행하기 전 printf("before\n"); for(i=0;i<4;i++) { for(j=0;j<4;j++) printf(" %d", Matrix[i][j]); printf("\n"); } warshall(Matrix, 4); //와셜알고리즘을 수행하고 난 후 printf("after\n"); for(i=0;i<4;i++) { for(j=0;j<4;j++) printf(" %d", Matrix[i][j]); printf("\n"); } }
void main() { int n,a[MAX][MAX],i,j; cout<<"Enter Number of nodes"<<endl; cin>>n; cout<<"Enter Adjacency Matrix"<<endl; for ( i=0;i<n;i++) { for ( j=0;j<n;j++) { cin>>a[i][j]; } cout<<endl; } warshall(a,n); getch(); }
void main(){ int n, cost[10][10], i, j; clrscr(); printf("Enter the no of vertices of graph\n"); scanf("%d",&n); printf("Enter the adjancy matrix\n"); for(i=1;i<=n;i++){ for(j=1;j<=n;j++) scanf("%d",&cost[i][j]); } warshall(cost,n); printf("The path matrix is \n"); for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ printf("%d\t",cost[i][j]); } printf("\n"); } getch(); }
int main() { printf ("Warshall Algorithm\n"); int arr[MAX_SIZE][MAX_SIZE], N; int i, j; printf ("Enter number of vertices\n"); scanf ("%d", &N); printf ("Enter %d X %d adj matrix\n", N, N); for (i = 0; i < N; i++) for (j = 0; j < N; j++) scanf ("%d", &arr[i][j]); warshall(arr, N); display(arr, N); return 0; }
main() { int ch; do { printf("enter the choice \n1.floyd \n2.warshall\n3.exit\n"); scanf("%d",&ch); switch(ch) { case 1: floyd(); break; case 2: warshall(); break; case 3: break; default: printf("invalid"); break; } }while(ch!=3); }