My Profile
Active Members
TodayLast 7 Days
more...
Awards & Gifts
Online Exams
Fresher Jobs
Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian
cities including Bangalore, Chennai, Hyderabad, Pune or Kochi
Resources
Find educational articles, blogs, discussion threads and other resources.
Colleges
Find details about any college in India or search for courses.
|
C Program for Modified Warshall's algorithm to find shoretst path matrix
Posted Date: 24 Mar 2008 Resource Type: Articles/Knowledge Sharing Category: Computer & Technology
|
Posted By: ashish singh Member Level: Diamond Rating: Points: 2
|
/*Program for Modified Warshall's algorithm to find shoretst path matrix */
#include #define infinity 9999 #define MAX 20
main() { int i,j,k,n; int adj[MAX][MAX],path[MAX][MAX];
printf("Enter number of vertices : "); scanf("%d",&n);
printf("Enter weighted matrix :\n"); for(i=0;i for(j=0;j scanf("%d",&adj[i][j]);
printf("Weighted matrix is :\n"); display(adj,n);
/*Replace all zero entries of adjacency matrix with infinity*/ for(i=0;i for(j=0;j if(adj[i][j]==0) path[i][j]=infinity; else path[i][j]=adj[i][j];
for(k=0;k { printf("Q%d is :\n",k); display(path,n); for(i=0;i for(j=0;j path[i][j]=minimum( path[i][j] , path[i][k]+path[k][j] ); } printf("Shortest path matrix Q%d is :\n",k); display(path,n); }/*End of main() */
minimum(int a,int b) { if(a<=b) return a; else return b; }/*End of minimum()*/
display(int matrix[MAX][MAX],int n ) { int i,j; for(i=0;i { for(j=0;j printf("%7d",matrix[i][j]); printf("\n"); } }/*End of display()*/
|
Responses
|
No responses found. Be the first to respond and make money from revenue sharing program.
|
|
Watch TV Channels
|