Skip to content

Instantly share code, notes, and snippets.

Created February 7, 2017 10:05
Show Gist options
  • Save anonymous/a7ca96ff5b0a2d6e8f6f3a7992901d8d to your computer and use it in GitHub Desktop.
Save anonymous/a7ca96ff5b0a2d6e8f6f3a7992901d8d to your computer and use it in GitHub Desktop.
BFS(source, goal):
queue = empty new queue
queue.add(source)
if current == goal:
return path
if current in visited:
continue
visited.add(current)
for direction, neighbour in graph[current]:
queue.append((path + direction, neighbour))
return "NO WAY!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment