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

Function prepare_sccs

mypy/graph_utils.py:57–72  ·  view source on GitHub ↗

Use original edges to organize SCCs in a graph by dependencies between them.

(
    sccs: list[set[T]], edges: dict[T, list[T]]
)

Source from the content-addressed store, hash-verified

55
56
57def prepare_sccs(
58 sccs: list[set[T]], edges: dict[T, list[T]]
59) -> dict[AbstractSet[T], set[AbstractSet[T]]]:
60 """Use original edges to organize SCCs in a graph by dependencies between them."""
61 sccsmap = {}
62 for scc in sccs:
63 scc_frozen = frozenset(scc)
64 for v in scc:
65 sccsmap[v] = scc_frozen
66 data: dict[AbstractSet[T], set[AbstractSet[T]]] = {}
67 for scc in sccs:
68 deps: set[AbstractSet[T]] = set()
69 for v in scc:
70 deps.update(sccsmap[x] for x in edges[v])
71 data[frozenset(scc)] = deps
72 return data
73
74
75class topsort(Iterator[set[T]]): # noqa: N801

Callers 2

solve_with_dependentFunction · 0.90
sorted_components_innerFunction · 0.90

Calls 3

frozensetClass · 0.85
setClass · 0.85
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…