Created
June 17, 2018 07:00
-
-
Save meetzaveri/cbc0d19c424d611b24bec7b01b0400dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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