Skip to content

Commit 41eb1a6

Browse files
authored
networkx: Most nodelist params are collections (#13945)
1 parent 1c08df2 commit 41eb1a6

File tree

11 files changed

+43
-26
lines changed

11 files changed

+43
-26
lines changed

stubs/networkx/networkx/algorithms/centrality/laplacian.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from _typeshed import Incomplete
2-
from collections.abc import Iterable
1+
from collections.abc import Collection
32

43
from networkx.classes.graph import Graph, _Node
54
from networkx.utils.backends import _dispatchable
@@ -8,7 +7,7 @@ from networkx.utils.backends import _dispatchable
87
def laplacian_centrality(
98
G: Graph[_Node],
109
normalized: bool = True,
11-
nodelist: Iterable[Incomplete] | None = None,
10+
nodelist: Collection[_Node] | None = None,
1211
weight: str | None = "weight",
1312
walk_type: str | None = None,
1413
alpha: float = 0.95,

stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from _typeshed import Incomplete, SupportsGetItem
2-
from collections.abc import Iterable
2+
from collections.abc import Collection
33

44
from networkx.classes.graph import Graph, _Node
55
from networkx.utils.backends import _dispatchable
@@ -20,7 +20,7 @@ def google_matrix(
2020
G: Graph[_Node],
2121
alpha: float = 0.85,
2222
personalization: SupportsGetItem[Incomplete, Incomplete] | None = None,
23-
nodelist: Iterable[Incomplete] | None = None,
23+
nodelist: Collection[_Node] | None = None,
2424
weight: str | None = "weight",
2525
dangling: SupportsGetItem[Incomplete, Incomplete] | None = None,
2626
): ...

stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from _typeshed import Incomplete, SupportsGetItem
2-
from collections.abc import Iterable
2+
from collections.abc import Collection
33

44
from networkx.classes.graph import Graph, _Node
55
from networkx.utils.backends import _dispatchable
66

77
@_dispatchable
8-
def floyd_warshall_numpy(G: Graph[_Node], nodelist: Iterable[Incomplete] | None = None, weight: str | None = "weight"): ...
8+
def floyd_warshall_numpy(G: Graph[_Node], nodelist: Collection[_Node] | None = None, weight: str | None = "weight"): ...
99
@_dispatchable
1010
def floyd_warshall_predecessor_and_distance(G: Graph[_Node], weight: str | None = "weight"): ...
1111
@_dispatchable

stubs/networkx/networkx/algorithms/triads.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from _typeshed import Incomplete
2-
from collections.abc import Generator, Iterable
2+
from collections.abc import Collection, Generator
33

44
from networkx.classes.digraph import DiGraph
55
from networkx.classes.graph import Graph, _Node
66
from networkx.utils.backends import _dispatchable
77
from numpy.random import RandomState
88

99
@_dispatchable
10-
def triadic_census(G: DiGraph[_Node], nodelist: Iterable[Incomplete] | None = None): ...
10+
def triadic_census(G: DiGraph[_Node], nodelist: Collection[_Node] | None = None): ...
1111
@_dispatchable
1212
def is_triad(G: Graph[_Node]): ...
1313
@_dispatchable

stubs/networkx/networkx/convert.pyi

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from _typeshed import Incomplete
2-
from collections.abc import Callable, Iterable
2+
from collections.abc import Callable, Collection, Iterable
33

44
from networkx.classes.graph import Graph, _Data, _Node
55
from networkx.utils.backends import _dispatchable
@@ -18,13 +18,15 @@ def to_networkx_graph(
1818
data: _Data[_Node], create_using: Graph[_Node] | Callable[[], Graph[_Node]] | None = None, multigraph_input: bool = False
1919
) -> Graph[_Node]: ...
2020
@_dispatchable
21-
def to_dict_of_lists(G: Graph[_Node], nodelist: None | Iterable[_Node] = None) -> dict[_Node, list[_Node]]: ...
21+
def to_dict_of_lists(G: Graph[_Node], nodelist: Collection[_Node] | None = None) -> dict[_Node, list[_Node]]: ...
2222
@_dispatchable
2323
def from_dict_of_lists(d: dict[_Node, Iterable[_Node]], create_using: Incomplete | None = None) -> Graph[_Node]: ...
24-
def to_dict_of_dicts(G: Graph[_Node], nodelist=None, edge_data=None) -> dict[Incomplete, Incomplete]: ...
24+
def to_dict_of_dicts(
25+
G: Graph[_Node], nodelist: Collection[_Node] | None = None, edge_data=None
26+
) -> dict[Incomplete, Incomplete]: ...
2527
@_dispatchable
2628
def from_dict_of_dicts(d, create_using=None, multigraph_input=False) -> Graph[Incomplete]: ...
2729
@_dispatchable
28-
def to_edgelist(G: Graph[_Node], nodelist=None): ...
30+
def to_edgelist(G: Graph[_Node], nodelist: Collection[_Node] | None = None): ...
2931
@_dispatchable
3032
def from_edgelist(edgelist, create_using=None) -> Graph[Incomplete]: ...

stubs/networkx/networkx/drawing/nx_pylab.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Collection
23

34
def draw(G, pos: Incomplete | None = None, ax: Incomplete | None = None, **kwds) -> None: ...
45
def draw_networkx(
@@ -7,7 +8,7 @@ def draw_networkx(
78
def draw_networkx_nodes(
89
G,
910
pos,
10-
nodelist: Incomplete | None = None,
11+
nodelist: Collection[Incomplete] | None = None,
1112
node_size: Incomplete | int = 300,
1213
node_color: str = "#1f78b4",
1314
node_shape: str = "o",
@@ -39,7 +40,7 @@ def draw_networkx_edges(
3940
arrows: Incomplete | None = None,
4041
label: Incomplete | None = None,
4142
node_size: Incomplete | int = 300,
42-
nodelist: Incomplete | None = None,
43+
nodelist: list[Incomplete] | None = None,
4344
node_shape: str = "o",
4445
connectionstyle: str = "arc3",
4546
min_source_margin: int = 0,
@@ -79,7 +80,7 @@ def draw_networkx_edge_labels(
7980
rotate: bool = True,
8081
clip_on: bool = True,
8182
node_size: int = 300,
82-
nodelist: Incomplete | None = None,
83+
nodelist: list[Incomplete] | None = None,
8384
connectionstyle: str = "arc3",
8485
hide_ticks: bool = True,
8586
): ...

stubs/networkx/networkx/generators/community.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Collection
23

34
from networkx.utils.backends import _dispatchable
45

@@ -22,7 +23,7 @@ def windmill_graph(n, k): ...
2223
def stochastic_block_model(
2324
sizes,
2425
p,
25-
nodelist: Incomplete | None = None,
26+
nodelist: Collection[Incomplete] | None = None,
2627
seed: Incomplete | None = None,
2728
directed: bool = False,
2829
selfloops: bool = False,
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Collection
23

34
from networkx.utils.backends import _dispatchable
45

56
@_dispatchable
6-
def bethe_hessian_matrix(G, r: Incomplete | None = None, nodelist: Incomplete | None = None): ...
7+
def bethe_hessian_matrix(G, r: Incomplete | None = None, nodelist: Collection[Incomplete] | None = None): ...
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Collection
23

34
from networkx.utils.backends import _dispatchable
45

56
@_dispatchable
67
def incidence_matrix(
78
G,
8-
nodelist: Incomplete | None = None,
9+
nodelist: Collection[Incomplete] | None = None,
910
edgelist: Incomplete | None = None,
1011
oriented: bool = False,
1112
weight: Incomplete | None = None,
1213
): ...
1314
@_dispatchable
14-
def adjacency_matrix(G, nodelist: Incomplete | None = None, dtype: Incomplete | None = None, weight: str = "weight"): ...
15+
def adjacency_matrix(
16+
G, nodelist: Collection[Incomplete] | None = None, dtype: Incomplete | None = None, weight: str = "weight"
17+
): ...
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Collection
23

34
from networkx.utils.backends import _dispatchable
45

56
@_dispatchable
6-
def laplacian_matrix(G, nodelist: Incomplete | None = None, weight: str = "weight"): ...
7+
def laplacian_matrix(G, nodelist: Collection[Incomplete] | None = None, weight: str = "weight"): ...
78
@_dispatchable
8-
def normalized_laplacian_matrix(G, nodelist: Incomplete | None = None, weight: str = "weight"): ...
9+
def normalized_laplacian_matrix(G, nodelist: Collection[Incomplete] | None = None, weight: str = "weight"): ...
910
@_dispatchable
1011
def total_spanning_tree_weight(G, weight: Incomplete | None = None): ...
1112
@_dispatchable
1213
def directed_laplacian_matrix(
13-
G, nodelist: Incomplete | None = None, weight: str = "weight", walk_type: Incomplete | None = None, alpha: float = 0.95
14+
G,
15+
nodelist: Collection[Incomplete] | None = None,
16+
weight: str = "weight",
17+
walk_type: Incomplete | None = None,
18+
alpha: float = 0.95,
1419
): ...
1520
@_dispatchable
1621
def directed_combinatorial_laplacian_matrix(
17-
G, nodelist: Incomplete | None = None, weight: str = "weight", walk_type: Incomplete | None = None, alpha: float = 0.95
22+
G,
23+
nodelist: Collection[Incomplete] | None = None,
24+
weight: str = "weight",
25+
walk_type: Incomplete | None = None,
26+
alpha: float = 0.95,
1827
): ...

0 commit comments

Comments
 (0)