Skip to content

Instantly share code, notes, and snippets.

@wilderfield
Created June 5, 2020 07:47
Show Gist options
  • Save wilderfield/5793e33e0c919111c6edbcee4800b5d2 to your computer and use it in GitHub Desktop.
Save wilderfield/5793e33e0c919111c6edbcee4800b5d2 to your computer and use it in GitHub Desktop.
DFS Recursive
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