0

Here is a chunk of my program... without the class and header file...

I am wanting to take that little graph thats in the middle of the code and have the user input a starting point and an ending point...

the class is a stack class with all the functions pop, push, peak...

it is already created...

the problem is where i go from one point to the other... someone help me if you feel like it :)

right now my while loop is infinite.. and i cant think how to take my struct and have it point to the starting block then on to the next few til it is at the end...

```
struct graph {
char from;
char to;
bool searched;
}edges[13];
int main () {
char start;
char end;
char point;
char nextpoint;
char visited[12];
int depth;
int x;
search_stack wait;
search_stack path;
cout << endl;
cout << " A B" << endl;
cout << " / / | " << endl;
cout << " C D E" << endl;
cout << " / | / /" << endl;
cout << " F G H I" << endl;
cout << " | / | / | /" << endl;
cout << " J K L" << endl;
edges[0].from = 'a' ; edges[0].to = 'c'; edges[0].searched = false;
edges[1].from = 'b' ; edges[1].to = 'd'; edges[1].searched = false;
edges[2].from = 'b' ; edges[2].to = 'e'; edges[2].searched = false;
edges[3].from = 'c' ; edges[3].to = 'f'; edges[3].searched = false;
edges[4].from = 'c' ; edges[4].to = 'g'; edges[4].searched = false;
edges[5].from = 'd' ; edges[5].to = 'g'; edges[5].searched = false;
edges[6].from = 'e' ; edges[6].to = 'h'; edges[6].searched = false;
edges[7].from = 'f' ; edges[7].to = 'j'; edges[7].searched = false;
edges[8].from = 'g' ; edges[8].to = 'j'; edges[8].searched = false;
edges[9].from = 'g' ; edges[9].to = 'k'; edges[9].searched = false;
edges[10].from = 'h' ; edges[10].to = 'k'; edges[10].searched = false;
edges[11].from = 'h' ; edges[11].to = 'l'; edges[11].searched = false;
edges[12].from = 'l' ; edges[12].to = 'i'; edges[12].searched = false;
cout << endl << "Please input the point you would like to begin from. ";
cin >> start;
cout << endl << "At what point would you like to end? ";
cin >> end;
point = start;
depth = 0;
if (point == end) {
cout << "The only point visited was: " << point << endl << endl;
}
while (point != end) {
wait.push(point, depth);
cout << "The following points are waiting: " << wait.peek() << endl;
wait.pop();
path.push(point, depth);
depth++;
for (x = 0; x < 13; x++){
if (point = edges[x].from) {
edges[x].searched = true;
point = edges[x].to;
}
}
if (point == end) {
cout << "The path taken is: ";
/* for (int x = depth; x >= 0; x--){
visited[x] = path.peek();
cout << visited[x];
path.pop();
} */
break;
}
}
cin >> start;
return 0;
}
```