Skip to content

Instantly share code, notes, and snippets.

@jiachen247
Created May 30, 2022 02:00
Show Gist options
  • Save jiachen247/92e6475a01cc7e153c0010acaeeda8ad to your computer and use it in GitHub Desktop.
Save jiachen247/92e6475a01cc7e153c0010acaeeda8ad to your computer and use it in GitHub Desktop.
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