Created
May 30, 2022 02:00
-
-
Save jiachen247/92e6475a01cc7e153c0010acaeeda8ad to your computer and use it in GitHub Desktop.
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
graph = { | |
'a' : ['b','c'], | |
'b' : ['d'], | |
'c' : ['e'], | |
'd' : ['f'], | |
'e' : [], | |
'f' : [], | |
'e': [] | |
} | |
visited = {} | |
def dfs(at): | |
if at in visited: return | |
visited[at] = True | |
print(f'at: {at}') | |
neighbors = graph[at] | |
for next_node in neighbors: | |
dfs(next_node) | |
def containsX(at, target): | |
pass | |
print(containsX('a', 'e')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment