Skip to content

Commit 14f71ed

Browse files
[networkx] Return the input graph type from transitive_closure (#16556)
Co-authored-by: Daniel Shafer <dan@danielshafer.com>
1 parent ad36363 commit 14f71ed

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

  • stubs/networkx/networkx/algorithms

‎stubs/networkx/networkx/algorithms/dag.pyi‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from _typeshed import Incomplete
22
from collections.abc import Callable, Generator, Iterable
3+
from typing import Any, TypeVar
34

45
from networkx.classes.digraph import DiGraph
56
from networkx.classes.graph import Graph, _EdgeData, _Node, _NodeData
@@ -23,6 +24,8 @@ __all__ = [
2324
"dag_to_branching",
2425
]
2526

27+
_G = TypeVar("_G", bound=Graph[Any, Any, Any])
28+
2629
@_dispatchable
2730
def descendants(G: Graph[_Node], source) -> set[_Node]: ...
2831
@_dispatchable
@@ -40,9 +43,7 @@ def all_topological_sorts(G: DiGraph[_Node]) -> Generator[list[_Node]]: ...
4043
@_dispatchable
4144
def is_aperiodic(G: DiGraph[_Node]) -> bool: ...
4245
@_dispatchable
43-
def transitive_closure(
44-
G: Graph[_Node, _NodeData, _EdgeData], reflexive: bool | None = False
45-
) -> Graph[_Node, _NodeData, _EdgeData]: ...
46+
def transitive_closure(G: _G, reflexive: bool | None = False) -> _G: ...
4647
@_dispatchable
4748
def transitive_closure_dag(
4849
G: DiGraph[_Node, _NodeData, _EdgeData], topo_order: Iterable[Incomplete] | None = None

0 commit comments

Comments
 (0)