From 26e77cbf67ee0e224808a85b18c08c1dda63aaec Mon Sep 17 00:00:00 2001 From: Wade Carpenter <2576056+wwade@users.noreply.github.com> Date: Mon, 15 Jan 2024 09:52:57 -0800 Subject: [PATCH] Add more networkx annotations for networkx.algorithms.dag (#11224) --- stubs/networkx/networkx/algorithms/dag.pyi | 29 +++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/dag.pyi b/stubs/networkx/networkx/algorithms/dag.pyi index 0ad382b98..47a677009 100644 --- a/stubs/networkx/networkx/algorithms/dag.pyi +++ b/stubs/networkx/networkx/algorithms/dag.pyi @@ -1,17 +1,22 @@ -from _typeshed import Incomplete +from _typeshed import SupportsRichComparison +from collections.abc import Callable, Generator, Iterable, Reversible from networkx.classes.graph import Graph, _Node def descendants(G: Graph[_Node], source: _Node) -> set[_Node]: ... def ancestors(G: Graph[_Node], source: _Node) -> set[_Node]: ... -def is_directed_acyclic_graph(G): ... -def topological_sort(G) -> None: ... -def lexicographical_topological_sort(G, key: Incomplete | None = None): ... -def all_topological_sorts(G) -> None: ... -def is_aperiodic(G): ... -def transitive_closure(G, reflexive: bool = False): ... -def transitive_reduction(G): ... -def antichains(G, topo_order: Incomplete | None = None) -> None: ... -def dag_longest_path(G, weight: str = "weight", default_weight: int = 1, topo_order: Incomplete | None = None): ... -def dag_longest_path_length(G, weight: str = "weight", default_weight: int = 1): ... -def dag_to_branching(G): ... +def is_directed_acyclic_graph(G: Graph[_Node]) -> bool: ... +def topological_sort(G: Graph[_Node]) -> Generator[_Node, None, None]: ... +def lexicographical_topological_sort( + G: Graph[_Node], key: Callable[[_Node], SupportsRichComparison] | None = None +) -> Generator[_Node, None, None]: ... +def all_topological_sorts(G: Graph[_Node]) -> Generator[list[_Node], None, None]: ... +def is_aperiodic(G: Graph[_Node]) -> bool: ... +def transitive_closure(G: Graph[_Node], reflexive: bool = False) -> Graph[_Node]: ... +def transitive_reduction(G: Graph[_Node]) -> Graph[_Node]: ... +def antichains(G: Graph[_Node], topo_order: Reversible[_Node] | None = None) -> Generator[list[_Node], None, None]: ... +def dag_longest_path( + G: Graph[_Node], weight: str = "weight", default_weight: int = 1, topo_order: Iterable[_Node] | None = None +) -> list[_Node]: ... +def dag_longest_path_length(G: Graph[_Node], weight: str = "weight", default_weight: int = 1) -> int: ... +def dag_to_branching(G: Graph[_Node]) -> Graph[_Node]: ...