Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool tree::distance(std::string origin, std::string sDestination, int &NumOfEdges)
- {
- Node *origination = mRoot;
- Node *destination = mRoot;
- origination = lookup(origin, origination);
- destination = lookup(sDestination, destination);
- if (!mRoot)
- return false; // No root city
- else if (!origination || !destination)
- return false; // Either origination or destination are not found
- else
- {
- // climb up the parents from the destination until origination iterating distance
- NumOfEdges = 0;
- while (destination->mString != origination->mString)
- {
- destination = destination->mParent;
- NumOfEdges++;
- }
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment