[networks] Fix some functions requiring DiGraph objects (#12066)

This commit is contained in:
Peter
2024-05-30 16:34:34 -06:00
committed by GitHub
parent 321c0ce75e
commit 3dc74ddf07

View File

@@ -1,6 +1,7 @@
from _typeshed import SupportsRichComparison
from collections.abc import Callable, Generator, Iterable, Reversible
from networkx.classes.digraph import DiGraph
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatch
@@ -11,28 +12,30 @@ def ancestors(G: Graph[_Node], source: _Node) -> set[_Node]: ...
@_dispatch
def is_directed_acyclic_graph(G: Graph[_Node]) -> bool: ...
@_dispatch
def topological_generations(G: Graph[_Node]) -> Generator[list[_Node], None, None]: ...
def topological_generations(G: DiGraph[_Node]) -> Generator[list[_Node], None, None]: ...
@_dispatch
def topological_sort(G: Graph[_Node]) -> Generator[_Node, None, None]: ...
def topological_sort(G: DiGraph[_Node]) -> Generator[_Node, None, None]: ...
@_dispatch
def lexicographical_topological_sort(
G: Graph[_Node], key: Callable[[_Node], SupportsRichComparison] | None = None
G: DiGraph[_Node], key: Callable[[_Node], SupportsRichComparison] | None = None
) -> Generator[_Node, None, None]: ...
@_dispatch
def all_topological_sorts(G: Graph[_Node]) -> Generator[list[_Node], None, None]: ...
def all_topological_sorts(G: DiGraph[_Node]) -> Generator[list[_Node], None, None]: ...
@_dispatch
def is_aperiodic(G: Graph[_Node]) -> bool: ...
def is_aperiodic(G: DiGraph[_Node]) -> bool: ...
@_dispatch
def transitive_closure(G: Graph[_Node], reflexive: bool = False) -> Graph[_Node]: ...
@_dispatch
def transitive_reduction(G: Graph[_Node]) -> Graph[_Node]: ...
def transitive_closure_dag(G: DiGraph[_Node], reflexive: bool = False) -> DiGraph[_Node]: ...
@_dispatch
def antichains(G: Graph[_Node], topo_order: Reversible[_Node] | None = None) -> Generator[list[_Node], None, None]: ...
def transitive_reduction(G: DiGraph[_Node]) -> DiGraph[_Node]: ...
@_dispatch
def antichains(G: DiGraph[_Node], topo_order: Reversible[_Node] | None = None) -> Generator[list[_Node], None, None]: ...
@_dispatch
def dag_longest_path(
G: Graph[_Node], weight: str = "weight", default_weight: int = 1, topo_order: Iterable[_Node] | None = None
G: DiGraph[_Node], weight: str = "weight", default_weight: int = 1, topo_order: Iterable[_Node] | None = None
) -> list[_Node]: ...
@_dispatch
def dag_longest_path_length(G: Graph[_Node], weight: str = "weight", default_weight: int = 1) -> int: ...
def dag_longest_path_length(G: DiGraph[_Node], weight: str = "weight", default_weight: int = 1) -> int: ...
@_dispatch
def dag_to_branching(G: Graph[_Node]) -> Graph[_Node]: ...