Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void dfs()
- {
- Stack * helper_stack = new Stack();
- vertexList[0].wasVisited = true;
- displayVertex(0);
- helper_stack->push(0);
- int v;
- while (!helper_stack->isEmpty()) //while stack is not empty
- {
- getAdjacentUnvisitedVertex(v);
- }
- if (v==(-1))
- {
- helper_stack->pop();
- }
- else
- {
- vertexList[v].wasVisited=true;
- displayVertex(v);
- helper_stack->push(v);
- }
- for(int j=0; j<n_vertices; j++)
- vertexList[j].wasVisited = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment