Community Sites
Create your own community website and start earning today !
It's Free !
 
Communities Members BookmarksPolls Fresher Jobs Funny Pictures MCA Projects New Member FAQ  



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.

website counter




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.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: C Program for creating a minimum spanning tree from Kruskal'salgorithm
Previous Resource: C Program to find out the path matrix by powers of adjacency matrix
Return to Discussion Resource Index
Post New Resource
Category: Computer & Technology


Post resources and earn money!
 
Related Resources

Watch TV Channels



Contact Us    Editors    Privacy Policy    Terms Of Use   

SpiderWorks Technologies Pvt Ltd. 2006 - 2007 All Rights Reserved.