Simplified version of sorted_components() to work with sub-graphs. This doesn't create SCC objects, and operates with raw sets. This function also allows filtering dependencies to take into account when building SCCs. This is used for heuristic ordering of modules within actual SCCs.
(
graph: Graph, vertices: AbstractSet[str], pri_max: int
)
| 5061 | |
| 5062 | |
| 5063 | def sorted_components_inner( |
| 5064 | graph: Graph, vertices: AbstractSet[str], pri_max: int |
| 5065 | ) -> list[AbstractSet[str]]: |
| 5066 | """Simplified version of sorted_components() to work with sub-graphs. |
| 5067 | |
| 5068 | This doesn't create SCC objects, and operates with raw sets. This function |
| 5069 | also allows filtering dependencies to take into account when building SCCs. |
| 5070 | This is used for heuristic ordering of modules within actual SCCs. |
| 5071 | """ |
| 5072 | edges = {id: deps_filtered(graph, vertices, id, pri_max) for id in vertices} |
| 5073 | sccs = list(strongly_connected_components(vertices, edges)) |
| 5074 | res = [] |
| 5075 | for ready in topsort(prepare_sccs(sccs, edges)): |
| 5076 | res.extend(sorted(ready, key=lambda scc: -min(graph[id].order for id in scc))) |
| 5077 | return res |
| 5078 | |
| 5079 | |
| 5080 | def deps_filtered(graph: Graph, vertices: AbstractSet[str], id: str, pri_max: int) -> list[str]: |
no test coverage detected
searching dependent graphs…