SHARE
TWEET

Untitled

shikdernyc Apr 19th, 2019 129 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top