Skip to content

Commit 2c10360

Browse files
authored
networkx: improve the cycles module (#14459)
1 parent 1bd3020 commit 2c10360

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed
Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from _typeshed import Incomplete
21
from collections.abc import Generator
2+
from typing import Literal
33

44
from networkx.classes.digraph import DiGraph
5-
from networkx.classes.graph import Graph, _Node
5+
from networkx.classes.graph import Graph, _NBunch, _Node
66
from networkx.utils.backends import _dispatchable
77

88
__all__ = [
@@ -16,23 +16,18 @@ __all__ = [
1616
]
1717

1818
@_dispatchable
19-
def cycle_basis(G: Graph[_Node], root: _Node | None = None): ...
19+
def cycle_basis(G: Graph[_Node], root: _Node | None = None) -> list[list[_Node]]: ...
2020
@_dispatchable
21-
def simple_cycles(G: Graph[_Node], length_bound: int | None = None) -> Generator[Incomplete, Incomplete, None]: ...
22-
23-
class _NeighborhoodCache(dict[Incomplete, Incomplete]):
24-
G: Incomplete
25-
26-
def __init__(self, G) -> None: ...
27-
def __missing__(self, v): ...
28-
21+
def simple_cycles(G: Graph[_Node], length_bound: int | None = None) -> Generator[list[_Node]]: ...
2922
@_dispatchable
30-
def chordless_cycles(G: DiGraph[_Node], length_bound: int | None = None) -> Generator[Incomplete, Incomplete, None]: ...
23+
def chordless_cycles(G: DiGraph[_Node], length_bound: int | None = None) -> Generator[list[_Node]]: ...
3124
@_dispatchable
32-
def recursive_simple_cycles(G: DiGraph[_Node]): ...
25+
def recursive_simple_cycles(G: DiGraph[_Node]) -> list[list[_Node]]: ...
3326
@_dispatchable
34-
def find_cycle(G: Graph[_Node], source=None, orientation=None): ...
27+
def find_cycle(
28+
G: Graph[_Node], source: _NBunch[_Node] = None, orientation: Literal["original", "reverse", "ignore"] | None = None
29+
): ...
3530
@_dispatchable
36-
def minimum_cycle_basis(G: Graph[_Node], weight: str | None = None): ...
31+
def minimum_cycle_basis(G: Graph[_Node], weight: str | None = None) -> list[list[_Node]]: ...
3732
@_dispatchable
38-
def girth(G) -> float | int: ...
33+
def girth(G: Graph[_Node]) -> float | int: ... # accepts any graph type

0 commit comments

Comments
 (0)