Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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