Skip to content

Instantly share code, notes, and snippets.

@meetzaveri
Created June 17, 2018 07:00
Show Gist options
  • Save meetzaveri/cbc0d19c424d611b24bec7b01b0400dd to your computer and use it in GitHub Desktop.
Save meetzaveri/cbc0d19c424d611b24bec7b01b0400dd to your computer and use it in GitHub Desktop.
def depth_first_search_recursive(graph, start, visited=None):
if visited is None:
visited = set()
visited.add(start)
for next in graph[start] - visited:
depth_first_search_recursive(graph, next, visited)
return visited
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment