Code
Hub
Workspaces
Connect
Indexed graphs
Engine
MCP
copy
Index your code
hub
/
github.com/subbarayudu-j/TheAlgorithms-Python
/ dfs
Function
dfs
Graphs/basic_graphs.py:61–74 ·
view source on GitHub ↗
(G, s)
Source
from the content-addressed store, hash-verified
59
60
61
def
dfs(G, s):
62
vis, S = set([s]), [s]
63
print(s)
64
while
S:
65
flag = 0
66
for
i in G[S[-1]]:
67
if
i not in vis:
68
S.append(i)
69
vis.add(i)
70
flag = 1
71
print(i)
72
break
73
if
not flag:
74
S.pop()
75
76
77
""
"
Callers
nothing calls this directly
Calls
2
add
Method · 0.80
pop
Method · 0.45
Tested by
no test coverage detected