New Member FAQ | Forums | Earn Revenue


Resources Entrance Ask Experts Exam Papers Jobs English Projects Universities Colleges Courses Schools Training My India



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



Resources » Articles/Knowledge Sharing » Computer & Technology »

C Program to find path matrix by Warshall's algorithm


Posted Date: 24 Mar 2008    Resource Type: Articles/Knowledge Sharing    Category: Computer & Technology
Author: ashish singhMember Level: Gold    
Rating: 3 out of 53 out of 53 out of 5Points: 2




/* Program to find path matrix by Warshall's algorithm */
#include
#define MAX 20
main()
{
int i,j,k,n;
int w_adj[MAX][MAX],adj[MAX][MAX],path[MAX][MAX];

printf("Enter number of vertices : ");
scanf("%d",&n);

printf("Enter weighted adjacency matrix :\n");
for(i=0;i for(j=0;j scanf("%d",&w_adj[i][j]);

printf("The weighted adjacency matrix is :\n");
display(w_adj,n);

/* Make weighted adjacency matrix into boolean adjacency matrix*/
for(i=0;i for(j=0;j if(w_adj[i][j]==0)
adj[i][j]=0;
else
adj[i][j]=1;

printf("The adjacency matrix is :\n");
display(adj,n);

for(i=0;i for(j=0;j path[i][j]=adj[i][j];

for(k=0;k {
printf("P%d is :\n",k);
display(path,n);
for(i=0;i for(j=0;j path[i][j]=( path[i][j] || ( path[i][k] && path[k][j] ) );
}
printf("Path matrix P%d of the given graph is :\n",k);
display(path,n);
}/*End of main() */

display(int matrix[MAX][MAX],int n)
{
int i,j;
for(i=0;i {
for(j=0;j printf("%3d",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  
Sign In to add 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 traversing a graph through BFS and DFS
Previous Resource: C Program of circular queue using array
Return to Discussion Resource Index
Post New Resource
Category: Computer & Technology


Post resources and earn money!
 
More Resources



Advertise Here


Watch TV Channels




Contact Us   Advertise   Editors    Privacy Policy    Terms Of Use   

ISC Technologies.
2006 - 2009 All Rights Reserved.