Notice: While JavaScript is not essential for this website, your interaction with the content will be limited. Please turn JavaScript on for the full experience.
...Breadth First Search]. Furthermore a linear BFS is simpler:" # Code by Eryk KopczyĆski def find_shortest_path(graph, start, end): dist = {start: [start]} q = deque(start) while len(q): at = q.popleft() for next in graph[at]: if next not in dist: dist[next] = [dist[at], next] q.append(next) return dist.get(end) Note that this returns the path in a weird form...
If you didn't find what you need, try your search in the Python language documentation.