MCPcopy 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
61def 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

addMethod · 0.80
popMethod · 0.45

Tested by

no test coverage detected