Created
February 21, 2019 16:37
-
-
Save vichu/d9df8e572d5f9ee93a0e991680fcce17 to your computer and use it in GitHub Desktop.
Else part of bfs we discussed yesterday
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
else{ | |
while(!queue.empty()){ | |
currentPoint = queue.front(); | |
queue.pop(); | |
for(int j=0;j<dir.length;j++){ | |
if(validDir && notVisited){ | |
Point nextPoint = currentPoint; | |
switch (case){ | |
... | |
default: | |
break; | |
} | |
// before we add the neighbour to the queue, we need to append | |
// the path we followd until now to the neighbour's path attribute | |
neighbourPoint = maze.get(nextPoint.x, nextPoint.y); | |
neighbourPoint.path.push_back(currentPoint.path); | |
neighborPoint.path.push_back(neighbourPoint); | |
// add the neighbour to the queue now | |
queue.push_back(neighbourPoint); | |
visitedPointSet.add(neighbourPoint); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment