Members BookmarksPolls Fresher Jobs Funny Photos B.Tech 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.

Advertisements


website counter



Program for implementation of DEPTH FIRST SEARCH


Posted Date: 14 Dec 2007    Resource Type: Articles/Knowledge Sharing    Category: Education

Posted By: Jagadeesan. D       Member Level: Silver
Rating:     Points: 2




#include
#include
#include
int visited[10],n;
class graph
{
int a[10][10];
public:
void initialise();
void searchform(int k);
};
void graph:: initialise()
{
cout<<"Enter the number of Nodes:";
cin>>n;
cout<<" \nEnter the adjacency Matrix:\n";
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
if(i!=j)
{
cout<< "\nEnter the value of" <<" "<< i<<" "<< j << " element:";
cin>>a[i][j];
}
}
void graph:: searchform(int k)
{
cout<< "---->"<< k;
visited[k]=1;
for(int i=1;i<=n;i++)
{
if(visited[i]==0)
{
if(a[k][i]!=0)
searchform(i);
}
}
}
void main()
{
clrscr();
graph g1;
g1.initialise();
cout<<"Nodes are visited in this order:";
for(int i=1;i<=n;i++)
if(visited[i]==0)
g1.searchform(i);
getch();
}




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: Program for implementation of AVL TREES
Previous Resource: Program for implementation of MULTI STACK
Return to Discussion Resource Index
Post New Resource
Category: Education


Post resources and earn money!
 
Related Resources


Contact Us    Privacy Policy    Terms Of Use   

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