This commit is contained in:
John Lancaster
2026-02-21 15:09:54 -06:00
parent 88a4064a71
commit 883710ebe1

View File

@@ -1,13 +1,12 @@
from __future__ import annotations
from collections.abc import Iterable
from typing import TYPE_CHECKING, Any, TypeVar
from typing import TYPE_CHECKING, TypeVar
from .util import ensure_set
if TYPE_CHECKING:
from .dag import DAG
from .typing import dictset
T = TypeVar("T")
@@ -32,12 +31,3 @@ def transitive_closure(graph: DAG[T], sub: T | Iterable[T], *, include_self: boo
seen.update(sub)
return seen
def slice_subgraph(graph: DAG, sub: Any) -> dictset:
closure = transitive_closure(graph, sub)
return {n: d & closure for n in closure if (d := set(graph[n]))}
def topological_sort(graph: DAG, *, reverse: bool = False) -> list:
return list(graph.keys())