Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ from networkx.utils.backends import _dispatchable
__all__ = ["generate_edgelist", "write_edgelist", "parse_edgelist", "read_edgelist"]

@_dispatchable
def write_edgelist(G, path, comments: str = "#", delimiter: str = " ", data: bool = True, encoding: str = "utf-8") -> None: ...
def write_edgelist(
G: Graph[_Node], path, comments: str = "#", delimiter: str = " ", data: bool = True, encoding: str = "utf-8"
) -> None: ...
@_dispatchable
def generate_edgelist(G, delimiter: str = " ", data: bool = True) -> Generator[str]: ...
def generate_edgelist(G: Graph[_Node], delimiter: str = " ", data: bool = True) -> Generator[str]: ...
@_dispatchable
def parse_edgelist(
lines,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from _typeshed import Incomplete
from collections.abc import Generator

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

@_dispatchable
def flow_matrix_row(G, weight=None, dtype=..., solver: str = "lu") -> Generator[Incomplete, None, None]: ...
def flow_matrix_row(G: Graph[_Node], weight=None, dtype=..., solver: str = "lu") -> Generator[Incomplete, None, None]: ...

class InverseLaplacian:
dtype: Incomplete
Expand Down
2 changes: 1 addition & 1 deletion stubs/networkx/networkx/algorithms/chordal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ def chordal_graph_cliques(G: Graph[_Node]) -> Generator[frozenset[_Node], None,
@_dispatchable
def chordal_graph_treewidth(G: Graph[_Node]) -> int: ...
@_dispatchable
def complete_to_chordal_graph(G) -> tuple[Incomplete, dict[Incomplete, int]]: ...
def complete_to_chordal_graph(G: Graph[_Node]) -> tuple[Incomplete, dict[Incomplete, int]]: ...
4 changes: 2 additions & 2 deletions stubs/networkx/networkx/algorithms/clique.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def node_clique_number(
) -> dict[_Node, int]: ...
@overload
def node_clique_number(G: Graph[_Node], nodes=None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False) -> int: ...
def number_of_cliques(G, nodes=None, cliques=None) -> int | dict[Incomplete, Incomplete]: ...
def number_of_cliques(G: Graph[_Node], nodes=None, cliques=None) -> int | dict[Incomplete, Incomplete]: ...
@_dispatchable
def max_weight_clique(G, weight="weight") -> tuple[list[Incomplete], int]: ...
def max_weight_clique(G: Graph[_Node], weight="weight") -> tuple[list[Incomplete], int]: ...

class MaxWeightClique:
G: Graph[Incomplete]
Expand Down
20 changes: 11 additions & 9 deletions stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, Unused
from collections.abc import Callable, Generator
from typing import Final

Expand All @@ -18,21 +18,23 @@ __all__ = [
]

@_dispatchable
def strategy_largest_first(G, colors): ...
def strategy_largest_first(G: Graph[_Node], colors: Unused): ...
@_dispatchable
def strategy_random_sequential(G, colors, seed=None): ...
def strategy_random_sequential(G: Graph[_Node], colors: Unused, seed=None): ...
@_dispatchable
def strategy_smallest_last(G, colors): ...
def strategy_smallest_last(G: Graph[_Node], colors: Unused): ...
@_dispatchable
def strategy_independent_set(G, colors) -> Generator[Incomplete, Incomplete, None]: ...
def strategy_independent_set(G: Graph[_Node], colors: Unused) -> Generator[Incomplete, Incomplete, None]: ...
@_dispatchable
def strategy_connected_sequential_bfs(G, colors): ...
def strategy_connected_sequential_bfs(G: Graph[_Node], colors): ...
@_dispatchable
def strategy_connected_sequential_dfs(G, colors): ...
def strategy_connected_sequential_dfs(G: Graph[_Node], colors): ...
@_dispatchable
def strategy_connected_sequential(G, colors, traversal: str = "bfs") -> Generator[Incomplete, None, None]: ...
def strategy_connected_sequential(
G: Graph[_Node], colors: Unused, traversal: str = "bfs"
) -> Generator[Incomplete, None, None]: ...
@_dispatchable
def strategy_saturation_largest_first(G, colors) -> Generator[Incomplete, None, Incomplete]: ...
def strategy_saturation_largest_first(G: Graph[_Node], colors) -> Generator[Incomplete, None, Incomplete]: ...

STRATEGIES: Final[dict[str, Callable[..., Incomplete]]]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ from numpy.random import RandomState
__all__ = ["label_propagation_communities", "asyn_lpa_communities", "fast_label_propagation_communities"]

@_dispatchable
def fast_label_propagation_communities(G, *, weight=None, seed=None) -> Generator[Incomplete]: ...
def fast_label_propagation_communities(G: Graph[_Node], *, weight=None, seed=None) -> Generator[Incomplete]: ...
@_dispatchable
def asyn_lpa_communities(
G: Graph[_Node], weight: str | None = None, seed: int | RandomState | None = None
Expand Down
2 changes: 1 addition & 1 deletion stubs/networkx/networkx/algorithms/community/quality.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from networkx.utils.decorators import argmap
__all__ = ["modularity", "partition_quality"]

class NotAPartition(NetworkXError):
def __init__(self, G, collection) -> None: ...
def __init__(self, G: Graph[_Node], collection) -> None: ...

require_partition: argmap

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class EdgeComponentAuxGraph:
H: Incomplete

@classmethod
def construct(cls, G): ...
def construct(cls, G: Graph[_Node]): ...
def k_edge_components(self, k: int) -> Generator[Incomplete, Incomplete, None]: ...
def k_edge_subgraphs(self, k: int) -> Generator[Incomplete, Incomplete, None]: ...

Expand Down
5 changes: 3 additions & 2 deletions stubs/networkx/networkx/algorithms/connectivity/utils.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable

__all__ = ["build_auxiliary_node_connectivity", "build_auxiliary_edge_connectivity"]

@_dispatchable
def build_auxiliary_node_connectivity(G): ...
def build_auxiliary_node_connectivity(G: Graph[_Node]): ...
@_dispatchable
def build_auxiliary_edge_connectivity(G): ...
def build_auxiliary_edge_connectivity(G: Graph[_Node]): ...
2 changes: 1 addition & 1 deletion stubs/networkx/networkx/algorithms/d_separation.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ __all__ = ["is_d_separator", "is_minimal_d_separator", "find_minimal_d_separator
@_dispatchable
def is_d_separator(G: DiGraph[_Node], x: _Node | set[_Node], y: _Node | set[_Node], z: _Node | set[_Node]) -> bool: ...
@_dispatchable
def find_minimal_d_separator(G, x, y, *, included=None, restricted=None) -> set[Incomplete] | None: ...
def find_minimal_d_separator(G: DiGraph[_Node], x, y, *, included=None, restricted=None) -> set[Incomplete] | None: ...
@_dispatchable
def is_minimal_d_separator(
G: DiGraph[_Node],
Expand Down
4 changes: 2 additions & 2 deletions stubs/networkx/networkx/algorithms/dag.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ def dag_longest_path(
@_dispatchable
def dag_longest_path_length(G: DiGraph[_Node], weight: str | None = "weight", default_weight: int | None = 1) -> int: ...
@_dispatchable
def dag_to_branching(G: Graph[_Node]) -> DiGraph[_Node]: ...
def dag_to_branching(G: DiGraph[_Node]) -> DiGraph[_Node]: ...
@_dispatchable
def compute_v_structures(G) -> Generator[tuple[Incomplete, Incomplete, Incomplete]]: ...
def compute_v_structures(G: DiGraph[_Node]) -> Generator[tuple[Incomplete, Incomplete, Incomplete]]: ...
8 changes: 4 additions & 4 deletions stubs/networkx/networkx/algorithms/efficiency_measures.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from networkx.classes.graph import _Node
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable

__all__ = ["efficiency", "local_efficiency", "global_efficiency"]

@_dispatchable
def efficiency(G, u: _Node, v: _Node) -> float: ...
def efficiency(G: Graph[_Node], u: _Node, v: _Node) -> float: ...
@_dispatchable
def global_efficiency(G) -> float: ...
def global_efficiency(G: Graph[_Node]) -> float: ...
@_dispatchable
def local_efficiency(G) -> float: ...
def local_efficiency(G: Graph[_Node]) -> float: ...
4 changes: 3 additions & 1 deletion stubs/networkx/networkx/algorithms/flow/networksimplex.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class _DataEssentialsAndFunctions:
prev_node_dft: Incomplete
last_descendent_dft: Incomplete

def __init__(self, G, multigraph, demand: str = "demand", capacity: str = "capacity", weight: str = "weight") -> None: ...
def __init__(
self, G: Graph[_Node], multigraph, demand: str = "demand", capacity: str = "capacity", weight: str = "weight"
) -> None: ...
def initialize_spanning_tree(self, n, faux_inf) -> None: ...
def find_apex(self, p, q): ...
def trace_path(self, p, w): ...
Expand Down
13 changes: 10 additions & 3 deletions stubs/networkx/networkx/algorithms/flow/utils.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from _typeshed import Incomplete
from typing import NoReturn, overload
from typing_extensions import deprecated

from networkx.classes.graph import Graph, _Node
from networkx.classes.multigraph import MultiGraph
from networkx.utils.backends import _dispatchable

__all__ = ["CurrentEdge", "Level", "GlobalRelabelThreshold", "build_residual_network", "detect_unboundedness", "build_flow_dict"]
Expand All @@ -23,9 +27,12 @@ class GlobalRelabelThreshold:
def is_reached(self) -> bool: ...
def clear_work(self) -> None: ...

@_dispatchable
def build_residual_network(G, capacity): ...
@overload
@deprecated("MultiGraph and MultiDiGraph not supported (yet).")
def build_residual_network(G: MultiGraph[_Node], capacity, *, backend: str | None = None, **backend_kwargs) -> NoReturn: ...
@overload
def build_residual_network(G: Graph[_Node], capacity, *, backend: str | None = None, **backend_kwargs): ...
@_dispatchable
def detect_unboundedness(R, s, t) -> None: ...
@_dispatchable
def build_flow_dict(G, R): ...
def build_flow_dict(G: Graph[_Node], R): ...
4 changes: 3 additions & 1 deletion stubs/networkx/networkx/algorithms/hierarchy.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from networkx.classes.digraph import DiGraph
from networkx.classes.graph import _Node
from networkx.utils.backends import _dispatchable

__all__ = ["flow_hierarchy"]

@_dispatchable
def flow_hierarchy(G, weight: str | None = None) -> float: ...
def flow_hierarchy(G: DiGraph[_Node], weight: str | None = None) -> float: ...
2 changes: 1 addition & 1 deletion stubs/networkx/networkx/algorithms/operators/binary.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ _Y_co = TypeVar("_Y_co", bound=Hashable, covariant=True)
@_dispatchable
def compose(G: Graph[_X_co], H: Graph[_Y_co]) -> DiGraph[_X_co | _Y_co]: ...
@_dispatchable
def full_join(G, H, rename=(None, None)): ...
def full_join(G: Graph[_Node], H, rename=(None, None)): ...
@_dispatchable
def union(G: Graph[_X_co], H: Graph[_Y_co], rename: Iterable[Incomplete] | None = ()) -> DiGraph[_X_co | _Y_co]: ...
2 changes: 1 addition & 1 deletion stubs/networkx/networkx/algorithms/operators/product.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ def rooted_product(G: Graph[_X], H: Graph[_Y], root: _Y) -> Graph[tuple[_X, _Y]]
@_dispatchable
def corona_product(G: Graph[_X], H: Graph[_Y]) -> Graph[tuple[_X, _Y]]: ...
@_dispatchable
def modular_product(G, H) -> Graph[Incomplete]: ...
def modular_product(G: Graph[_Node], H) -> Graph[Incomplete]: ...
2 changes: 1 addition & 1 deletion stubs/networkx/networkx/algorithms/planarity.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class LRPlanarity:
right_ref: Incomplete
embedding: Incomplete

def __init__(self, G) -> None: ...
def __init__(self, G: Graph[_Node]) -> None: ...
def lr_planarity(self) -> PlanarEmbedding[Incomplete] | None: ...
def lr_planarity_recursive(self): ...
def dfs_orientation(self, v): ...
Expand Down
4 changes: 2 additions & 2 deletions stubs/networkx/networkx/algorithms/tree/branchings.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def minimum_branching(
G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str | None = None
): ...
@_dispatchable
def minimal_branching(G, /, *, attr="weight", default=1, preserve_attrs=False, partition=None): ...
def minimal_branching(G: DiGraph[_Node], /, *, attr="weight", default=1, preserve_attrs=False, partition=None): ...
@_dispatchable
def maximum_spanning_arborescence(
G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str | None = None
Expand All @@ -63,7 +63,7 @@ class ArborescenceIterator:
partition_key: str
init_partition: Incomplete

def __init__(self, G, weight: str = "weight", minimum: bool = True, init_partition=None) -> None: ...
def __init__(self, G: DiGraph[_Node], weight: str = "weight", minimum: bool = True, init_partition=None) -> None: ...
partition_queue: Incomplete

def __iter__(self) -> Self: ...
Expand Down
4 changes: 2 additions & 2 deletions stubs/networkx/networkx/algorithms/tree/decomposition.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from _typeshed import Incomplete

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

__all__ = ["junction_tree"]

@_dispatchable
def junction_tree(G) -> Graph[Incomplete]: ...
def junction_tree(G: Graph[_Node]) -> Graph[Incomplete]: ...
5 changes: 3 additions & 2 deletions stubs/networkx/networkx/algorithms/tree/mst.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ from enum import Enum
from typing import Final, Literal
from typing_extensions import Self

from networkx.classes.digraph import DiGraph
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
from numpy.random import RandomState
Expand Down Expand Up @@ -79,11 +80,11 @@ class SpanningTreeIterator:
ignore_nan: Incomplete
partition_key: str

def __init__(self, G, weight: str = "weight", minimum: bool = True, ignore_nan: bool = False) -> None: ...
def __init__(self, G: DiGraph[_Node], weight: str = "weight", minimum: bool = True, ignore_nan: bool = False) -> None: ...
partition_queue: Incomplete

def __iter__(self) -> Self: ...
def __next__(self): ...

@_dispatchable
def number_of_spanning_trees(G, *, root=None, weight=None) -> float | Literal[0]: ...
def number_of_spanning_trees(G: Graph[_Node], *, root=None, weight=None) -> float | Literal[0]: ...
4 changes: 2 additions & 2 deletions stubs/networkx/networkx/algorithms/wiener.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ __all__ = ["wiener_index", "schultz_index", "gutman_index"]
@_dispatchable
def wiener_index(G: Graph[_Node], weight: str | None = None) -> float: ...
@_dispatchable
def schultz_index(G, weight=None) -> float: ...
def schultz_index(G: Graph[_Node], weight=None) -> float: ...
@_dispatchable
def gutman_index(G, weight=None) -> float: ...
def gutman_index(G: Graph[_Node], weight=None) -> float: ...
45 changes: 26 additions & 19 deletions stubs/networkx/networkx/classes/function.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,32 @@ __all__ = [

_U = TypeVar("_U")

def nodes(G): ...
def edges(G, nbunch=None): ...
def degree(G, nbunch=None, weight=None): ...
def neighbors(G, n): ...
def number_of_nodes(G): ...
def number_of_edges(G): ...
def density(G): ...
def degree_histogram(G) -> list[int]: ...
def nodes(G: Graph[_Node]): ...
def edges(G: Graph[_Node], nbunch=None): ...
def degree(G: Graph[_Node], nbunch=None, weight=None): ...
def neighbors(G: Graph[_Node], n): ...
def number_of_nodes(G: Graph[_Node]): ...
def number_of_edges(G: Graph[_Node]): ...
def density(G: Graph[_Node]): ...
def degree_histogram(G: Graph[_Node]) -> list[int]: ...
@overload
def is_directed(G: PlanarEmbedding[Hashable]) -> Literal[False]: ... # type: ignore[misc] # Incompatible return types
@overload
def is_directed(G: DiGraph[Hashable]) -> Literal[True]: ... # type: ignore[misc] # Incompatible return types
@overload
def is_directed(G: Graph[Hashable]) -> Literal[False]: ...
def freeze(G): ...
def freeze(G: Graph[_Node]): ...
def is_frozen(G: Graph[Incomplete]) -> bool: ...
def add_star(G_to_add_to, nodes_for_star, **attr) -> None: ...
def add_path(G_to_add_to, nodes_for_path, **attr) -> None: ...
def add_cycle(G_to_add_to, nodes_for_cycle, **attr) -> None: ...
def subgraph(G, nbunch): ...
def subgraph(G: Graph[_Node], nbunch): ...
def induced_subgraph(G: Graph[_Node], nbunch: _NBunch[_Node]) -> Graph[_Node]: ...
def edge_subgraph(G, edges): ...
def restricted_view(G, nodes, edges): ...
def edge_subgraph(G: Graph[_Node], edges): ...
def restricted_view(G: Graph[_Node], nodes, edges): ...
def to_directed(graph): ...
def to_undirected(graph): ...
def create_empty_copy(G, with_data: bool = True): ...
def create_empty_copy(G: Graph[_Node], with_data: bool = True): ...

# incomplete: Can "Any scalar value" be enforced?
@overload
Expand All @@ -101,26 +101,33 @@ def set_node_attributes(
@_dispatchable
def get_node_attributes(G: Graph[_Node], name: str, default=None) -> dict[_Node, Incomplete]: ...
@_dispatchable
def remove_node_attributes(G, *attr_names, nbunch=None) -> None: ...
def remove_node_attributes(G: Graph[_Node], *attr_names, nbunch=None) -> None: ...
@overload
def set_edge_attributes(
G: Graph[_Node],
values: SupportsItems[tuple[_Node, _Node], Incomplete],
name: str,
*,
backend=None, # @_dispatchable adds these arguments, but we can't use this decorator with @overload
backend: str | None = None, # @_dispatchable adds these arguments, but we can't use this decorator with @overload
**backend_kwargs,
) -> None: ...
@overload
def set_edge_attributes(
G: MultiGraph[_Node], values: dict[tuple[_Node, _Node, Incomplete], Incomplete], name: str, *, backend=None, **backend_kwargs
G: MultiGraph[_Node],
values: dict[tuple[_Node, _Node, Incomplete], Incomplete],
name: str,
*,
backend: str | None = None,
**backend_kwargs,
) -> None: ...
@overload
def set_edge_attributes(G: Graph[Hashable], values, name: None = None, *, backend=None, **backend_kwargs) -> None: ...
def set_edge_attributes(
G: Graph[Hashable], values, name: None = None, *, backend: str | None = None, **backend_kwargs
) -> None: ...
@_dispatchable
def get_edge_attributes(G: Graph[_Node], name: str, default=None) -> dict[tuple[_Node, _Node], Incomplete]: ...
@_dispatchable
def remove_edge_attributes(G, *attr_names, ebunch=None) -> None: ...
def remove_edge_attributes(G: Graph[_Node], *attr_names, ebunch=None) -> None: ...
def all_neighbors(graph: Graph[_Node], node: _Node) -> Iterator[_Node]: ...
def non_neighbors(graph: Graph[_Node], node: _Node) -> Generator[_Node, None, None]: ...
def non_edges(graph: Graph[_Node]) -> Generator[tuple[_Node, _Node], None, None]: ...
Expand Down Expand Up @@ -163,4 +170,4 @@ def selfloop_edges(
@_dispatchable
def number_of_selfloops(G: Graph[Hashable]) -> int: ...
def is_path(G: Graph[_Node], path: Iterable[Incomplete]) -> bool: ...
def path_weight(G, path, weight) -> int: ...
def path_weight(G: Graph[_Node], path, weight) -> int: ...
2 changes: 1 addition & 1 deletion stubs/networkx/networkx/convert_matrix.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def from_pandas_edgelist(
edge_key: str | None = None,
) -> Graph[Incomplete]: ...
@_dispatchable
def to_scipy_sparse_array(G, nodelist=None, dtype=None, weight="weight", format="csr"): ...
def to_scipy_sparse_array(G: Graph[_Node], nodelist=None, dtype=None, weight="weight", format="csr"): ...
@_dispatchable
def from_scipy_sparse_array(A, parallel_edges=False, create_using=None, edge_attribute="weight"): ...
@_dispatchable
Expand Down
3 changes: 2 additions & 1 deletion stubs/networkx/networkx/generators/ego.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable

__all__ = ["ego_graph"]

@_dispatchable
def ego_graph(G, n, radius: float = 1, center: bool = True, undirected: bool = False, distance=None): ...
def ego_graph(G: Graph[_Node], n, radius: float = 1, center: bool = True, undirected: bool = False, distance=None): ...
Loading
Loading