Hollowfires

Untitled

May 9th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. void dfs()
  2. {
  3. Stack * helper_stack = new Stack();
  4. vertexList[0].wasVisited = true;
  5. displayVertex(0);
  6. helper_stack->push(0);
  7.  
  8. int v;
  9. while (!helper_stack->isEmpty()) //while stack is not empty
  10. {
  11. getAdjacentUnvisitedVertex(v);
  12. }
  13. if (v==(-1))
  14. {
  15. helper_stack->pop();
  16. }
  17. else
  18. {
  19. vertexList[v].wasVisited=true;
  20. displayVertex(v);
  21. helper_stack->push(v);
  22. }
  23. for(int j=0; j<n_vertices; j++)
  24. vertexList[j].wasVisited = false;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment