#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include"graph01.cpp" /* Refer this Source Code */
#define max 50
struct stack
{
int top;
struct node *ver[max];
}stk;
void DFS()
{
printf("\n Enter the starting Node : ");
cin>>item;
stk.top = 1;
find_node();
if(loc != NULL)
{
loc->status = 2;
stk.ver[stk.top] = loc;
}
else
printf("\n\n Node not found !!\n\n");
printf("\n\n The DFS Traversal Is : ");
while(stk.top != 0)
{
loc = stk.ver[stk.top--];
printf(" %c",loc->info);
loc->status = 3;
//qu.front++;
ptre = loc->adj;
while(ptre!=NULL)
{
if(ptre->dest->status == 1)
{
ptre->dest->status = 2;
stk.ver[++stk.top] = ptre->dest;
}
ptre = ptre->link;
}
}
}
void main()
{
clrscr();
create_node();
create_vertices();
DFS();
getch();
}
#include<conio.h>
#include<iostream.h>
#include"graph01.cpp" /* Refer this Source Code */
#define max 50
struct stack
{
int top;
struct node *ver[max];
}stk;
void DFS()
{
printf("\n Enter the starting Node : ");
cin>>item;
stk.top = 1;
find_node();
if(loc != NULL)
{
loc->status = 2;
stk.ver[stk.top] = loc;
}
else
printf("\n\n Node not found !!\n\n");
printf("\n\n The DFS Traversal Is : ");
while(stk.top != 0)
{
loc = stk.ver[stk.top--];
printf(" %c",loc->info);
loc->status = 3;
//qu.front++;
ptre = loc->adj;
while(ptre!=NULL)
{
if(ptre->dest->status == 1)
{
ptre->dest->status = 2;
stk.ver[++stk.top] = ptre->dest;
}
ptre = ptre->link;
}
}
}
void main()
{
clrscr();
create_node();
create_vertices();
DFS();
getch();
}
No comments:
Post a Comment