Advertisement
shikdernyc

Untitled

Apr 19th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. bool RouteMap::isRoute(City *origin, City *destionation)
  2. {
  3. std::stack<City *> cities;
  4. cities.push(origin);
  5. while (!cities.empty())
  6. {
  7. City *current = cities.top();
  8. cities.pop();
  9.  
  10. if (current == destionation)
  11. {
  12. return true;
  13. }
  14.  
  15. if (!current->hasBeenVisited())
  16. {
  17. current->setHasBeenVisited(true);
  18. }
  19.  
  20. for (City *city : current->getNeighbors())
  21. {
  22. if (!city->hasBeenVisited())
  23. {
  24. cities.push(city);
  25. }
  26. }
  27. }
  28.  
  29. return false;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement