MCPcopy Index your code
hub / github.com/python/mypy / dfs

Function dfs

mypy/graph_utils.py:33–50  ·  view source on GitHub ↗
(v: T)

Source from the content-addressed store, hash-verified

31 boundaries: list[int] = []
32
33 def dfs(v: T) -> Iterator[set[T]]:
34 index[v] = len(stack)
35 stack.append(v)
36 boundaries.append(index[v])
37
38 for w in edges[v]:
39 if w not in index:
40 yield from dfs(w)
41 elif w not in identified:
42 while index[w] < boundaries[-1]:
43 boundaries.pop()
44
45 if boundaries[-1] == index[v]:
46 boundaries.pop()
47 scc = set(stack[index[v] :])
48 del stack[index[v] :]
49 identified.update(scc)
50 yield scc
51
52 for v in vertices:
53 if v not in index:

Callers 1

Calls 5

lenFunction · 0.85
setClass · 0.85
appendMethod · 0.80
popMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected