File size: 226 Bytes
ec93d6d
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
dfs_code = r"""
def dfs(visited, graph, node):  #function for dfs 
    if node not in visited:
        print (node)
        visited.add(node)
        for neighbour in graph[node]:
            dfs(visited, graph, neighbour)
"""