Skip to content

Instantly share code, notes, and snippets.

@vichu
Created February 21, 2019 16:37
Show Gist options
  • Save vichu/d9df8e572d5f9ee93a0e991680fcce17 to your computer and use it in GitHub Desktop.
Save vichu/d9df8e572d5f9ee93a0e991680fcce17 to your computer and use it in GitHub Desktop.
Else part of bfs we discussed yesterday
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