المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Wrong Output, Cant catch the mistake (DFS)



C++ Programming
10-05-2009, 09:01 PM
Hi I made the following program for depth first search but I am having wrong path. Can anyone catch or tell me what I am doing wrong here. I dont know much how to use the debugger in turbo c professional.

Thanks and regards, Mike.

#include
#include
#define MAX 6 // Node/Vertex count
int adj[MAX][MAX]={ // Adjacency Matrix 2x2
{0,1,1,1,0,0},
{1,0,0,0,1,1},
{1,0,0,0,0,0},
{1,0,0,0,0,0},
{0,1,0,0,0,0},
{0,1,1,0,0,0}
};

int visited[MAX]; // Visited array

void bfs(int goal); // bfs function

int main ()
{
int g=5; //set Goal node
clrscr();
printf("The nodes order is ");
bfs(g);
return 0;


}

void bfs(int goal)
{

int queue[MAX];
int i,front,rear,root;
front=rear=0;

for (i=1;i