text cover

Data Abstraction and Problem Solving with C++

Walls and Mirrors

by Frank M. Carrano

Addison Wesley Logo

isPathRecursive.cpp

Go to the documentation of this file.
00001 
00016 bool Map::isPath(int originCity, int destinationCity)
00017 {
00018    int  nextCity;
00019    bool success, done;
00020 
00021    // mark the current city as visited
00022    markVisited(originCity);
00023 
00024    // base case: the destination is reached
00025    if (originCity == destinationCity)
00026       return true;
00027 
00028    else  // try a flight to each unvisited city
00029    {  done = false;
00030       success = getNextCity(originCity, nextCity);
00031 
00032       while (success && !done)
00033       {  done = isPath(nextCity, destinationCity);
00034          if (!done)
00035             success = getNextCity(originCity, nextCity);
00036       }  // end while
00037 
00038       return done;
00039    }  // end if
00040 }  // end isPath

Generated on Sun Aug 27 16:41:03 2006 for AWLogo by  doxygen 1.4.6