networkx: Most nodelist params are collections (#13945)

This commit is contained in:
Avasam
2025-05-06 02:39:14 -04:00
committed by GitHub
parent 1c08df207b
commit 41eb1a6731
11 changed files with 43 additions and 26 deletions
@@ -1,5 +1,4 @@
from _typeshed import Incomplete
from collections.abc import Iterable
from collections.abc import Collection
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
@@ -8,7 +7,7 @@ from networkx.utils.backends import _dispatchable
def laplacian_centrality(
G: Graph[_Node],
normalized: bool = True,
nodelist: Iterable[Incomplete] | None = None,
nodelist: Collection[_Node] | None = None,
weight: str | None = "weight",
walk_type: str | None = None,
alpha: float = 0.95,
@@ -1,5 +1,5 @@
from _typeshed import Incomplete, SupportsGetItem
from collections.abc import Iterable
from collections.abc import Collection
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
@@ -20,7 +20,7 @@ def google_matrix(
G: Graph[_Node],
alpha: float = 0.85,
personalization: SupportsGetItem[Incomplete, Incomplete] | None = None,
nodelist: Iterable[Incomplete] | None = None,
nodelist: Collection[_Node] | None = None,
weight: str | None = "weight",
dangling: SupportsGetItem[Incomplete, Incomplete] | None = None,
): ...
@@ -1,11 +1,11 @@
from _typeshed import Incomplete, SupportsGetItem
from collections.abc import Iterable
from collections.abc import Collection
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
@_dispatchable
def floyd_warshall_numpy(G: Graph[_Node], nodelist: Iterable[Incomplete] | None = None, weight: str | None = "weight"): ...
def floyd_warshall_numpy(G: Graph[_Node], nodelist: Collection[_Node] | None = None, weight: str | None = "weight"): ...
@_dispatchable
def floyd_warshall_predecessor_and_distance(G: Graph[_Node], weight: str | None = "weight"): ...
@_dispatchable
@@ -1,5 +1,5 @@
from _typeshed import Incomplete
from collections.abc import Generator, Iterable
from collections.abc import Collection, Generator
from networkx.classes.digraph import DiGraph
from networkx.classes.graph import Graph, _Node
@@ -7,7 +7,7 @@ from networkx.utils.backends import _dispatchable
from numpy.random import RandomState
@_dispatchable
def triadic_census(G: DiGraph[_Node], nodelist: Iterable[Incomplete] | None = None): ...
def triadic_census(G: DiGraph[_Node], nodelist: Collection[_Node] | None = None): ...
@_dispatchable
def is_triad(G: Graph[_Node]): ...
@_dispatchable
+6 -4
View File
@@ -1,5 +1,5 @@
from _typeshed import Incomplete
from collections.abc import Callable, Iterable
from collections.abc import Callable, Collection, Iterable
from networkx.classes.graph import Graph, _Data, _Node
from networkx.utils.backends import _dispatchable
@@ -18,13 +18,15 @@ def to_networkx_graph(
data: _Data[_Node], create_using: Graph[_Node] | Callable[[], Graph[_Node]] | None = None, multigraph_input: bool = False
) -> Graph[_Node]: ...
@_dispatchable
def to_dict_of_lists(G: Graph[_Node], nodelist: None | Iterable[_Node] = None) -> dict[_Node, list[_Node]]: ...
def to_dict_of_lists(G: Graph[_Node], nodelist: Collection[_Node] | None = None) -> dict[_Node, list[_Node]]: ...
@_dispatchable
def from_dict_of_lists(d: dict[_Node, Iterable[_Node]], create_using: Incomplete | None = None) -> Graph[_Node]: ...
def to_dict_of_dicts(G: Graph[_Node], nodelist=None, edge_data=None) -> dict[Incomplete, Incomplete]: ...
def to_dict_of_dicts(
G: Graph[_Node], nodelist: Collection[_Node] | None = None, edge_data=None
) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
def from_dict_of_dicts(d, create_using=None, multigraph_input=False) -> Graph[Incomplete]: ...
@_dispatchable
def to_edgelist(G: Graph[_Node], nodelist=None): ...
def to_edgelist(G: Graph[_Node], nodelist: Collection[_Node] | None = None): ...
@_dispatchable
def from_edgelist(edgelist, create_using=None) -> Graph[Incomplete]: ...
+4 -3
View File
@@ -1,4 +1,5 @@
from _typeshed import Incomplete
from collections.abc import Collection
def draw(G, pos: Incomplete | None = None, ax: Incomplete | None = None, **kwds) -> None: ...
def draw_networkx(
@@ -7,7 +8,7 @@ def draw_networkx(
def draw_networkx_nodes(
G,
pos,
nodelist: Incomplete | None = None,
nodelist: Collection[Incomplete] | None = None,
node_size: Incomplete | int = 300,
node_color: str = "#1f78b4",
node_shape: str = "o",
@@ -39,7 +40,7 @@ def draw_networkx_edges(
arrows: Incomplete | None = None,
label: Incomplete | None = None,
node_size: Incomplete | int = 300,
nodelist: Incomplete | None = None,
nodelist: list[Incomplete] | None = None,
node_shape: str = "o",
connectionstyle: str = "arc3",
min_source_margin: int = 0,
@@ -79,7 +80,7 @@ def draw_networkx_edge_labels(
rotate: bool = True,
clip_on: bool = True,
node_size: int = 300,
nodelist: Incomplete | None = None,
nodelist: list[Incomplete] | None = None,
connectionstyle: str = "arc3",
hide_ticks: bool = True,
): ...
@@ -1,4 +1,5 @@
from _typeshed import Incomplete
from collections.abc import Collection
from networkx.utils.backends import _dispatchable
@@ -22,7 +23,7 @@ def windmill_graph(n, k): ...
def stochastic_block_model(
sizes,
p,
nodelist: Incomplete | None = None,
nodelist: Collection[Incomplete] | None = None,
seed: Incomplete | None = None,
directed: bool = False,
selfloops: bool = False,
@@ -1,6 +1,7 @@
from _typeshed import Incomplete
from collections.abc import Collection
from networkx.utils.backends import _dispatchable
@_dispatchable
def bethe_hessian_matrix(G, r: Incomplete | None = None, nodelist: Incomplete | None = None): ...
def bethe_hessian_matrix(G, r: Incomplete | None = None, nodelist: Collection[Incomplete] | None = None): ...
@@ -1,14 +1,17 @@
from _typeshed import Incomplete
from collections.abc import Collection
from networkx.utils.backends import _dispatchable
@_dispatchable
def incidence_matrix(
G,
nodelist: Incomplete | None = None,
nodelist: Collection[Incomplete] | None = None,
edgelist: Incomplete | None = None,
oriented: bool = False,
weight: Incomplete | None = None,
): ...
@_dispatchable
def adjacency_matrix(G, nodelist: Incomplete | None = None, dtype: Incomplete | None = None, weight: str = "weight"): ...
def adjacency_matrix(
G, nodelist: Collection[Incomplete] | None = None, dtype: Incomplete | None = None, weight: str = "weight"
): ...
@@ -1,18 +1,27 @@
from _typeshed import Incomplete
from collections.abc import Collection
from networkx.utils.backends import _dispatchable
@_dispatchable
def laplacian_matrix(G, nodelist: Incomplete | None = None, weight: str = "weight"): ...
def laplacian_matrix(G, nodelist: Collection[Incomplete] | None = None, weight: str = "weight"): ...
@_dispatchable
def normalized_laplacian_matrix(G, nodelist: Incomplete | None = None, weight: str = "weight"): ...
def normalized_laplacian_matrix(G, nodelist: Collection[Incomplete] | None = None, weight: str = "weight"): ...
@_dispatchable
def total_spanning_tree_weight(G, weight: Incomplete | None = None): ...
@_dispatchable
def directed_laplacian_matrix(
G, nodelist: Incomplete | None = None, weight: str = "weight", walk_type: Incomplete | None = None, alpha: float = 0.95
G,
nodelist: Collection[Incomplete] | None = None,
weight: str = "weight",
walk_type: Incomplete | None = None,
alpha: float = 0.95,
): ...
@_dispatchable
def directed_combinatorial_laplacian_matrix(
G, nodelist: Incomplete | None = None, weight: str = "weight", walk_type: Incomplete | None = None, alpha: float = 0.95
G,
nodelist: Collection[Incomplete] | None = None,
weight: str = "weight",
walk_type: Incomplete | None = None,
alpha: float = 0.95,
): ...
@@ -1,8 +1,9 @@
from _typeshed import Incomplete
from collections.abc import Collection
from networkx.utils.backends import _dispatchable
@_dispatchable
def modularity_matrix(G, nodelist: Incomplete | None = None, weight: Incomplete | None = None): ...
def modularity_matrix(G, nodelist: Collection[Incomplete] | None = None, weight: Incomplete | None = None): ...
@_dispatchable
def directed_modularity_matrix(G, nodelist: Incomplete | None = None, weight: Incomplete | None = None): ...
def directed_modularity_matrix(G, nodelist: Collection[Incomplete] | None = None, weight: Incomplete | None = None): ...