Created
June 5, 2020 07:47
-
-
Save wilderfield/5793e33e0c919111c6edbcee4800b5d2 to your computer and use it in GitHub Desktop.
DFS Recursive
This file contains 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 dfsRecursive(node,visited=set()): | |
visited.add(node) | |
# Process this node here | |
for neighbor in getNeighbors(node): | |
if neighbor not in visited: | |
dfsRecursive(neighbor,visited) | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment