diff --git a/stubs/networkx/networkx/algorithms/approximation/clique.pyi b/stubs/networkx/networkx/algorithms/approximation/clique.pyi index 4587354a1c07..b906c7a95bcd 100644 --- a/stubs/networkx/networkx/algorithms/approximation/clique.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/clique.pyi @@ -1,12 +1,14 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["clique_removal", "max_clique", "large_clique_size", "maximum_independent_set"] @_dispatchable -def maximum_independent_set(G: Graph[_Node]): ... +def maximum_independent_set(G: Graph[_Node]) -> set[Incomplete]: ... @_dispatchable -def max_clique(G: Graph[_Node]): ... +def max_clique(G: Graph[_Node]) -> set[Incomplete]: ... @_dispatchable def clique_removal(G: Graph[_Node]): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi b/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi index 4c1a7d55c117..cff53629ceb7 100644 --- a/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi @@ -5,4 +5,4 @@ from numpy.random import RandomState __all__ = ["average_clustering"] @_dispatchable -def average_clustering(G: Graph[_Node], trials: int = 1000, seed: int | RandomState | None = None): ... +def average_clustering(G: Graph[_Node], trials: int = 1000, seed: int | RandomState | None = None) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi b/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi index 7adcdcb978f2..2e1986d6806e 100644 --- a/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi @@ -11,4 +11,6 @@ def local_node_connectivity(G: Graph[_Node], source: _Node, target: _Node, cutof @_dispatchable def node_connectivity(G: Graph[_Node], s: _Node | None = None, t: _Node | None = None): ... @_dispatchable -def all_pairs_node_connectivity(G: Graph[_Node], nbunch: Iterable[Incomplete] | None = None, cutoff: int | None = None): ... +def all_pairs_node_connectivity( + G: Graph[_Node], nbunch: Iterable[Incomplete] | None = None, cutoff: int | None = None +) -> dict[Incomplete, dict[Incomplete, Incomplete]]: ... diff --git a/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi b/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi index a24428f63b8e..e37d3713ce42 100644 --- a/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi @@ -1,9 +1,11 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["min_weighted_dominating_set", "min_edge_dominating_set"] @_dispatchable -def min_weighted_dominating_set(G: Graph[_Node], weight: str | None = None): ... +def min_weighted_dominating_set(G: Graph[_Node], weight: str | None = None) -> set[Incomplete]: ... @_dispatchable -def min_edge_dominating_set(G: Graph[_Node]): ... +def min_edge_dominating_set(G: Graph[_Node]) -> set[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi index b1965791435a..e0fe94385cd5 100644 --- a/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi @@ -1,7 +1,10 @@ +from _typeshed import Incomplete +from collections import defaultdict + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["k_components"] @_dispatchable -def k_components(G: Graph[_Node], min_density: float = 0.95): ... +def k_components(G: Graph[_Node], min_density: float = 0.95) -> defaultdict[Incomplete, list[Incomplete]]: ... diff --git a/stubs/networkx/networkx/algorithms/approximation/matching.pyi b/stubs/networkx/networkx/algorithms/approximation/matching.pyi index 799818b498f2..7b5f723d44d0 100644 --- a/stubs/networkx/networkx/algorithms/approximation/matching.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/matching.pyi @@ -1,7 +1,9 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["min_maximal_matching"] @_dispatchable -def min_maximal_matching(G: Graph[_Node]): ... +def min_maximal_matching(G: Graph[_Node]) -> set[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi index acf37c745376..98f19221d9e7 100644 --- a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi @@ -21,7 +21,7 @@ _SupportsLenAndGetItemT = TypeVar("_SupportsLenAndGetItemT", bound=SupportsLenAn def swap_two_nodes(soln: _SupportsLenAndGetItemT, seed) -> _SupportsLenAndGetItemT: ... def move_one_node(soln: _SupportsLenAndGetItemT, seed) -> _SupportsLenAndGetItemT: ... @_dispatchable -def christofides(G: Graph[_Node], weight: str | None = "weight", tree: Graph[_Node] | None = None): ... +def christofides(G: Graph[_Node], weight: str | None = "weight", tree: Graph[_Node] | None = None) -> list[Incomplete]: ... @_dispatchable def traveling_salesman_problem( G: Graph[_Node], diff --git a/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi b/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi index ffd5206df85d..abec263a7bd0 100644 --- a/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi @@ -1,7 +1,9 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["min_weighted_vertex_cover"] @_dispatchable -def min_weighted_vertex_cover(G: Graph[_Node], weight: str | None = None): ... +def min_weighted_vertex_cover(G: Graph[_Node], weight: str | None = None) -> set[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi b/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi index a4782a825d00..c8dc80853ce9 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi @@ -9,4 +9,4 @@ __all__ = ["average_degree_connectivity"] @_dispatchable def average_degree_connectivity( G: Graph[_Node], source="in+out", target="in+out", nodes: Iterable[Incomplete] | None = None, weight: str | None = None -): ... +) -> dict[Incomplete, int | float]: ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi index 2789386434d7..78f36749726d 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi @@ -14,12 +14,12 @@ __all__ = [ @_dispatchable def degree_assortativity_coefficient( G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable[Incomplete] | None = None -): ... +) -> float: ... @_dispatchable def degree_pearson_correlation_coefficient( G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable[Incomplete] | None = None -): ... +) -> float: ... @_dispatchable -def attribute_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None): ... +def attribute_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None) -> float: ... @_dispatchable -def numeric_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None): ... +def numeric_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi index 4c5ced294890..84168115f9db 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi @@ -9,7 +9,7 @@ __all__ = ["attribute_mixing_matrix", "attribute_mixing_dict", "degree_mixing_ma @_dispatchable def attribute_mixing_dict( G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None, normalized: bool = False -): ... +) -> dict[Incomplete, Incomplete]: ... @_dispatchable def attribute_mixing_matrix( G: Graph[_Node], @@ -21,7 +21,7 @@ def attribute_mixing_matrix( @_dispatchable def degree_mixing_dict( G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes=None, normalized: bool = False -): ... +) -> dict[Incomplete, Incomplete]: ... @_dispatchable def degree_mixing_matrix( G: Graph[_Node], @@ -33,4 +33,4 @@ def degree_mixing_matrix( mapping: SupportsGetItem[Incomplete, Incomplete] | None = None, ): ... @_dispatchable -def mixing_dict(xy, normalized: bool = False): ... +def mixing_dict(xy, normalized: bool = False) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi b/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi index d86ce3da8211..231c1966d0eb 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi @@ -13,4 +13,4 @@ def average_neighbor_degree( target: str | None = "out", nodes: Iterable[Incomplete] | None = None, weight: str | None = None, -): ... +) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/asteroidal.pyi b/stubs/networkx/networkx/algorithms/asteroidal.pyi index 8745fe1accbf..9e4dbd34028f 100644 --- a/stubs/networkx/networkx/algorithms/asteroidal.pyi +++ b/stubs/networkx/networkx/algorithms/asteroidal.pyi @@ -6,7 +6,7 @@ from networkx.utils.backends import _dispatchable __all__ = ["is_at_free", "find_asteroidal_triple"] @_dispatchable -def find_asteroidal_triple(G: Graph[_Node]): ... +def find_asteroidal_triple(G: Graph[_Node]) -> list[Incomplete] | None: ... @_dispatchable def is_at_free(G: Graph[_Node]) -> bool: ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/bipartite/basic.pyi b/stubs/networkx/networkx/algorithms/bipartite/basic.pyi index fcf13edb9dac..afba78f9fdfc 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/basic.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/basic.pyi @@ -7,14 +7,14 @@ from networkx.utils.backends import _dispatchable __all__ = ["is_bipartite", "is_bipartite_node_set", "color", "sets", "density", "degrees"] @_dispatchable -def color(G: Graph[_Node]): ... +def color(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ... @_dispatchable def is_bipartite(G: Graph[_Node]) -> bool: ... @_dispatchable def is_bipartite_node_set(G: Graph[_Node], nodes: Iterable[Incomplete]) -> bool: ... @_dispatchable -def sets(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None): ... +def sets(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None) -> tuple[set[Incomplete], set[Incomplete]]: ... @_dispatchable -def density(B: Graph[_Node], nodes): ... +def density(B: Graph[_Node], nodes) -> float: ... @_dispatchable -def degrees(B: Graph[_Node], nodes, weight: str | None = None): ... +def degrees(B: Graph[_Node], nodes, weight: str | None = None) -> tuple[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi b/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi index 976948059f2b..529287ee87d7 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi @@ -1,11 +1,13 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["degree_centrality", "betweenness_centrality", "closeness_centrality"] @_dispatchable -def degree_centrality(G: Graph[_Node], nodes): ... +def degree_centrality(G: Graph[_Node], nodes) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def betweenness_centrality(G: Graph[_Node], nodes): ... +def betweenness_centrality(G: Graph[_Node], nodes) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def closeness_centrality(G: Graph[_Node], nodes, normalized: bool | None = True): ... +def closeness_centrality(G: Graph[_Node], nodes, normalized: bool | None = True) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi b/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi index 0931bb9f735d..1a341ef85e92 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi @@ -13,11 +13,13 @@ def cc_min(nu, nv) -> float: ... modes: dict[str, Callable[[Incomplete, Incomplete], float]] @_dispatchable -def latapy_clustering(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, mode: str = "dot"): ... +def latapy_clustering( + G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, mode: str = "dot" +) -> dict[Incomplete, Incomplete]: ... clustering = latapy_clustering @_dispatchable -def average_clustering(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, mode: str = "dot"): ... +def average_clustering(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, mode: str = "dot") -> float: ... @_dispatchable -def robins_alexander_clustering(G: Graph[_Node]): ... +def robins_alexander_clustering(G: Graph[_Node]) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/covering.pyi b/stubs/networkx/networkx/algorithms/bipartite/covering.pyi index c915c19c00f0..ab33bcecf487 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/covering.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/covering.pyi @@ -7,4 +7,4 @@ from networkx.utils.backends import _dispatchable __all__ = ["min_edge_cover"] @_dispatchable -def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable[..., Incomplete] | None = None): ... +def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable[..., Incomplete] | None = None) -> set[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi b/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi index 18fb7d40473f..67c6c530e889 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi @@ -1,4 +1,3 @@ -from _typeshed import Incomplete from collections.abc import Generator from networkx.classes.graph import Graph, _Node @@ -9,7 +8,7 @@ __all__ = ["generate_edgelist", "write_edgelist", "parse_edgelist", "read_edgeli @_dispatchable def write_edgelist(G, path, comments: str = "#", delimiter: str = " ", data: bool = True, encoding: str = "utf-8") -> None: ... @_dispatchable -def generate_edgelist(G, delimiter: str = " ", data: bool = True) -> Generator[Incomplete, None, None]: ... +def generate_edgelist(G, delimiter: str = " ", data: bool = True) -> Generator[str, None, None]: ... @_dispatchable def parse_edgelist( lines, diff --git a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi index 91ef136107e4..cdf9dddbbbf1 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi @@ -7,9 +7,9 @@ from networkx.utils.backends import _dispatchable __all__ = ["maximum_matching", "hopcroft_karp_matching", "eppstein_matching", "to_vertex_cover", "minimum_weight_full_matching"] @_dispatchable -def hopcroft_karp_matching(G: Graph[_Node], top_nodes: Iterable[_Node] | None = None): ... +def hopcroft_karp_matching(G: Graph[_Node], top_nodes: Iterable[_Node] | None = None) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def eppstein_matching(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None): ... +def eppstein_matching(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None) -> dict[Incomplete, Incomplete]: ... @_dispatchable def to_vertex_cover( G: Graph[_Node], matching: SupportsGetItem[Incomplete, Incomplete], top_nodes: Iterable[Incomplete] | None = None @@ -20,4 +20,4 @@ maximum_matching = hopcroft_karp_matching @_dispatchable def minimum_weight_full_matching( G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None, weight: str | None = "weight" -): ... +) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi index 2e484482aa8d..b33fed570b98 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi @@ -14,6 +14,6 @@ def biadjacency_matrix( dtype=None, weight: str | None = "weight", format="csr", -): ... +): ... # Return is a complex union of scipy classes depending on the format param @_dispatchable def from_biadjacency_matrix(A, create_using: Graph[_Node] | None = None, edge_attribute: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi b/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi index cb7233ef90ab..539e8012ad11 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi @@ -7,4 +7,4 @@ from networkx.utils.backends import _dispatchable __all__ = ["node_redundancy"] @_dispatchable -def node_redundancy(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None): ... +def node_redundancy(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None) -> dict[Incomplete, float]: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi b/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi index 1778bd31cf5a..462e8fef2d73 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi @@ -1,7 +1,9 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["spectral_bipartivity"] @_dispatchable -def spectral_bipartivity(G: Graph[_Node], nodes=None, weight: str = "weight"): ... +def spectral_bipartivity(G: Graph[_Node], nodes=None, weight: str = "weight") -> float | dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi index 7d39f64677cf..c22f749306eb 100644 --- a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState @@ -18,12 +20,12 @@ def approximate_current_flow_betweenness_centrality( epsilon: float = 0.5, kmax: int = 10000, seed: int | RandomState | None = None, -): ... +) -> dict[Incomplete, float]: ... @_dispatchable def current_flow_betweenness_centrality( G: Graph[_Node], normalized: bool | None = True, weight: str | None = None, dtype: type = ..., solver: str = "full" -): ... +) -> dict[Incomplete, Incomplete]: ... @_dispatchable def edge_current_flow_betweenness_centrality( G: Graph[_Node], normalized: bool | None = True, weight: str | None = None, dtype: type = ..., solver: str = "full" -): ... +) -> dict[tuple[Incomplete, Incomplete], float]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi index 9fe21cad877d..b7f38a4c9b31 100644 --- a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -14,7 +15,7 @@ def current_flow_betweenness_centrality_subset( weight: str | None = None, dtype: type = ..., solver: str = "lu", -): ... +) -> dict[Incomplete, float]: ... @_dispatchable def edge_current_flow_betweenness_centrality_subset( G: Graph[_Node], @@ -24,4 +25,4 @@ def edge_current_flow_betweenness_centrality_subset( weight: str | None = None, dtype: type = ..., solver: str = "lu", -): ... +) -> dict[tuple[Incomplete, Incomplete], float]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi b/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi index 00ff9c43f1b1..d7b95eeea326 100644 --- a/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi @@ -1,9 +1,13 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["current_flow_closeness_centrality", "information_centrality"] @_dispatchable -def current_flow_closeness_centrality(G: Graph[_Node], weight: str | None = None, dtype: type = ..., solver: str = "lu"): ... +def current_flow_closeness_centrality( + G: Graph[_Node], weight: str | None = None, dtype: type = ..., solver: str = "lu" +) -> dict[Incomplete, float]: ... information_centrality = current_flow_closeness_centrality diff --git a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi index 5e1af9216cf8..d0e6f96b92cb 100644 --- a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi @@ -12,8 +12,8 @@ def eigenvector_centrality( tol: float | None = 1e-06, nstart: SupportsGetItem[Incomplete, Incomplete] | None = None, weight: str | None = None, -): ... +) -> dict[Incomplete, float]: ... @_dispatchable def eigenvector_centrality_numpy( G: Graph[_Node], weight: str | None = None, max_iter: int | None = 50, tol: float | None = 0 -): ... +) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/group.pyi b/stubs/networkx/networkx/algorithms/centrality/group.pyi index 0efcdbbe4dcf..1e0c00b226c5 100644 --- a/stubs/networkx/networkx/algorithms/centrality/group.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/group.pyi @@ -26,12 +26,12 @@ def prominent_group( endpoints: bool | None = False, normalized: bool | None = True, greedy: bool | None = False, -): ... +) -> tuple[float, list[Incomplete]]: ... @_dispatchable -def group_closeness_centrality(G: Graph[_Node], S: Iterable[Incomplete], weight: str | None = None): ... +def group_closeness_centrality(G: Graph[_Node], S: Iterable[Incomplete], weight: str | None = None) -> float: ... @_dispatchable -def group_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]): ... +def group_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]) -> float: ... @_dispatchable -def group_in_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]): ... +def group_in_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]) -> float: ... @_dispatchable -def group_out_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]): ... +def group_out_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi b/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi index 7b75d7ee75ee..4b00562653f8 100644 --- a/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi @@ -9,4 +9,4 @@ __all__ = ["harmonic_centrality"] @_dispatchable def harmonic_centrality( G: Graph[_Node], nbunch: Iterable[Incomplete] | None = None, distance=None, sources: Iterable[Incomplete] | None = None -): ... +) -> dict[Incomplete, int]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/katz.pyi b/stubs/networkx/networkx/algorithms/centrality/katz.pyi index 6f0f4f3bae8b..ca867e0d624a 100644 --- a/stubs/networkx/networkx/algorithms/centrality/katz.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/katz.pyi @@ -15,7 +15,7 @@ def katz_centrality( nstart: SupportsGetItem[Incomplete, Incomplete] | None = None, normalized: bool | None = True, weight: str | None = None, -): ... +) -> dict[Incomplete, Incomplete]: ... @_dispatchable def katz_centrality_numpy( G: Graph[_Node], @@ -23,4 +23,4 @@ def katz_centrality_numpy( beta: float | SupportsGetItem[Incomplete, Incomplete] | None = 1.0, normalized: bool = True, weight: str | None = None, -): ... +) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/load.pyi b/stubs/networkx/networkx/algorithms/centrality/load.pyi index cdec3b843e77..d59db805b08f 100644 --- a/stubs/networkx/networkx/algorithms/centrality/load.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/load.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -6,7 +8,7 @@ __all__ = ["load_centrality", "edge_load_centrality"] @_dispatchable def newman_betweenness_centrality( G: Graph[_Node], v=None, cutoff: bool | None = None, normalized: bool | None = True, weight: str | None = None -): ... +) -> float | dict[Incomplete, float]: ... load_centrality = newman_betweenness_centrality diff --git a/stubs/networkx/networkx/algorithms/centrality/percolation.pyi b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi index f6bee5c6bd05..cc5faab10f72 100644 --- a/stubs/networkx/networkx/algorithms/centrality/percolation.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi @@ -11,4 +11,4 @@ def percolation_centrality( attribute: str | None = "percolation", states: SupportsGetItem[Incomplete, Incomplete] | None = None, weight: str | None = None, -): ... +) -> dict[Incomplete, float]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/reaching.pyi b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi index f99040b4f6ef..d5a6e1479aca 100644 --- a/stubs/networkx/networkx/algorithms/centrality/reaching.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi @@ -7,7 +7,7 @@ from networkx.utils.backends import _dispatchable __all__ = ["global_reaching_centrality", "local_reaching_centrality"] @_dispatchable -def global_reaching_centrality(G: DiGraph[_Node], weight: str | None = None, normalized: bool | None = True): ... +def global_reaching_centrality(G: DiGraph[_Node], weight: str | None = None, normalized: bool | None = True) -> float: ... @_dispatchable def local_reaching_centrality( G: DiGraph[_Node], @@ -15,4 +15,4 @@ def local_reaching_centrality( paths: SupportsGetItem[Incomplete, Incomplete] | None = None, weight: str | None = None, normalized: bool | None = True, -): ... +) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/second_order.pyi b/stubs/networkx/networkx/algorithms/centrality/second_order.pyi index cda7cac85c00..d6f64bcd4bda 100644 --- a/stubs/networkx/networkx/algorithms/centrality/second_order.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/second_order.pyi @@ -1,7 +1,9 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["second_order_centrality"] @_dispatchable -def second_order_centrality(G: Graph[_Node], weight: str | None = "weight"): ... +def second_order_centrality(G: Graph[_Node], weight: str | None = "weight") -> dict[Incomplete, float]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi b/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi index 94075f2541b7..21671ced7d77 100644 --- a/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi @@ -1,13 +1,15 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["subgraph_centrality_exp", "subgraph_centrality", "communicability_betweenness_centrality", "estrada_index"] @_dispatchable -def subgraph_centrality_exp(G: Graph[_Node]): ... +def subgraph_centrality_exp(G: Graph[_Node]) -> dict[Incomplete, float]: ... @_dispatchable -def subgraph_centrality(G: Graph[_Node]): ... +def subgraph_centrality(G: Graph[_Node]) -> dict[Incomplete, float]: ... @_dispatchable -def communicability_betweenness_centrality(G: Graph[_Node]): ... +def communicability_betweenness_centrality(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def estrada_index(G: Graph[_Node]): ... +def estrada_index(G: Graph[_Node]) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/trophic.pyi b/stubs/networkx/networkx/algorithms/centrality/trophic.pyi index f0ae0a5b53f1..4215c89b46d1 100644 --- a/stubs/networkx/networkx/algorithms/centrality/trophic.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/trophic.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.digraph import DiGraph from networkx.classes.graph import _Node from networkx.utils.backends import _dispatchable @@ -5,8 +7,8 @@ from networkx.utils.backends import _dispatchable __all__ = ["trophic_levels", "trophic_differences", "trophic_incoherence_parameter"] @_dispatchable -def trophic_levels(G: DiGraph[_Node], weight="weight"): ... +def trophic_levels(G: DiGraph[_Node], weight="weight") -> dict[Incomplete, Incomplete]: ... @_dispatchable -def trophic_differences(G: DiGraph[_Node], weight="weight"): ... +def trophic_differences(G: DiGraph[_Node], weight="weight") -> dict[Incomplete, Incomplete]: ... @_dispatchable -def trophic_incoherence_parameter(G: DiGraph[_Node], weight="weight", cannibalism: bool = False): ... +def trophic_incoherence_parameter(G: DiGraph[_Node], weight="weight", cannibalism: bool = False) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi b/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi index bf5969f63ea0..4dc2bb55728d 100644 --- a/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi @@ -1,7 +1,9 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["voterank"] @_dispatchable -def voterank(G: Graph[_Node], number_of_nodes: int | None = None): ... +def voterank(G: Graph[_Node], number_of_nodes: int | None = None) -> list[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi index 06405d42c2bf..c11b7d77d791 100644 --- a/stubs/networkx/networkx/algorithms/clique.pyi +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -36,7 +36,7 @@ def node_clique_number( 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]: ... @_dispatchable -def max_weight_clique(G, weight="weight") -> tuple[Incomplete, Incomplete]: ... +def max_weight_clique(G, weight="weight") -> tuple[list[Incomplete], int]: ... class MaxWeightClique: G: Graph[Incomplete] diff --git a/stubs/networkx/networkx/algorithms/cluster.pyi b/stubs/networkx/networkx/algorithms/cluster.pyi index dfa594aca74b..15a497ec870d 100644 --- a/stubs/networkx/networkx/algorithms/cluster.pyi +++ b/stubs/networkx/networkx/algorithms/cluster.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -6,16 +7,16 @@ from networkx.utils.backends import _dispatchable __all__ = ["triangles", "average_clustering", "clustering", "transitivity", "square_clustering", "generalized_degree"] @_dispatchable -def triangles(G: Graph[_Node], nodes=None): ... +def triangles(G: Graph[_Node], nodes=None) -> int | dict[Incomplete, int]: ... @_dispatchable def average_clustering( G: Graph[_Node], nodes: Iterable[_Node] | None = None, weight: str | None = None, count_zeros: bool = True -): ... +) -> float: ... @_dispatchable -def clustering(G: Graph[_Node], nodes=None, weight: str | None = None): ... +def clustering(G: Graph[_Node], nodes=None, weight: str | None = None) -> float | int | dict[Incomplete, float | int]: ... @_dispatchable -def transitivity(G: Graph[_Node]): ... +def transitivity(G: Graph[_Node]) -> float: ... @_dispatchable -def square_clustering(G: Graph[_Node], nodes: Iterable[_Node] | None = None): ... +def square_clustering(G: Graph[_Node], nodes: Iterable[_Node] | None = None) -> float | int | dict[Incomplete, float | int]: ... @_dispatchable def generalized_degree(G: Graph[_Node], nodes: Iterable[_Node] | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/communicability_alg.pyi b/stubs/networkx/networkx/algorithms/communicability_alg.pyi index 4cbbc0adb2e4..93ab59130d37 100644 --- a/stubs/networkx/networkx/algorithms/communicability_alg.pyi +++ b/stubs/networkx/networkx/algorithms/communicability_alg.pyi @@ -1,9 +1,11 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["communicability", "communicability_exp"] @_dispatchable -def communicability(G: Graph[_Node]): ... +def communicability(G: Graph[_Node]) -> dict[dict[Incomplete, Incomplete], dict[Incomplete, float]]: ... @_dispatchable -def communicability_exp(G: Graph[_Node]): ... +def communicability_exp(G: Graph[_Node]) -> dict[dict[Incomplete, Incomplete], dict[Incomplete, float]]: ... diff --git a/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi b/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi index 5729204d3b82..2b3d11cc5a51 100644 --- a/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi +++ b/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi @@ -1,3 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Iterator + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState @@ -5,4 +8,4 @@ from numpy.random import RandomState __all__ = ["asyn_fluidc"] @_dispatchable -def asyn_fluidc(G: Graph[_Node], k: int, max_iter: int = 100, seed: int | RandomState | None = None): ... +def asyn_fluidc(G: Graph[_Node], k: int, max_iter: int = 100, seed: int | RandomState | None = None) -> Iterator[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/community/label_propagation.pyi b/stubs/networkx/networkx/algorithms/community/label_propagation.pyi index 23840b8cbde7..6d0148179871 100644 --- a/stubs/networkx/networkx/algorithms/community/label_propagation.pyi +++ b/stubs/networkx/networkx/algorithms/community/label_propagation.pyi @@ -1,3 +1,4 @@ +from _collections_abc import dict_values from _typeshed import Incomplete from collections.abc import Generator @@ -14,4 +15,4 @@ def asyn_lpa_communities( G: Graph[_Node], weight: str | None = None, seed: int | RandomState | None = None ) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable -def label_propagation_communities(G: Graph[_Node]): ... +def label_propagation_communities(G: Graph[_Node]) -> dict_values[Incomplete, set[Incomplete]]: ... diff --git a/stubs/networkx/networkx/algorithms/community/louvain.pyi b/stubs/networkx/networkx/algorithms/community/louvain.pyi index 40cf510a5845..103d4bf6e7d8 100644 --- a/stubs/networkx/networkx/algorithms/community/louvain.pyi +++ b/stubs/networkx/networkx/algorithms/community/louvain.pyi @@ -15,7 +15,7 @@ def louvain_communities( threshold: float | None = 1e-07, max_level: int | None = None, seed: int | RandomState | None = None, -): ... +) -> list[set[Incomplete]]: ... @_dispatchable def louvain_partitions( G: Graph[_Node], @@ -23,4 +23,4 @@ def louvain_partitions( resolution: float | None = 1, threshold: float | None = 1e-07, seed: int | RandomState | None = None, -) -> Generator[Incomplete, None, None]: ... +) -> Generator[list[set[Incomplete]], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/community/modularity_max.pyi b/stubs/networkx/networkx/algorithms/community/modularity_max.pyi index 5cfedb7d5271..701054c23e97 100644 --- a/stubs/networkx/networkx/algorithms/community/modularity_max.pyi +++ b/stubs/networkx/networkx/algorithms/community/modularity_max.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -6,6 +8,6 @@ __all__ = ["greedy_modularity_communities", "naive_greedy_modularity_communities @_dispatchable def greedy_modularity_communities( G: Graph[_Node], weight: str | None = None, resolution: float | None = 1, cutoff: int | None = 1, best_n: int | None = None -): ... +) -> list[set[Incomplete]] | list[frozenset[Incomplete]]: ... @_dispatchable def naive_greedy_modularity_communities(G: Graph[_Node], resolution: float = 1, weight: str | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/components/attracting.pyi b/stubs/networkx/networkx/algorithms/components/attracting.pyi index 655b7d32f7b3..2085ce168349 100644 --- a/stubs/networkx/networkx/algorithms/components/attracting.pyi +++ b/stubs/networkx/networkx/algorithms/components/attracting.pyi @@ -11,6 +11,6 @@ __all__ = ["number_attracting_components", "attracting_components", "is_attracti @_dispatchable def attracting_components(G) -> Generator[Incomplete, None, None]: ... @_dispatchable -def number_attracting_components(G): ... +def number_attracting_components(G) -> int: ... @_dispatchable def is_attracting_component(G: DiGraph[_Node] | MultiDiGraph[_Node]) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/components/connected.pyi b/stubs/networkx/networkx/algorithms/components/connected.pyi index 09256c0b6256..ba7fae6bd169 100644 --- a/stubs/networkx/networkx/algorithms/components/connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/connected.pyi @@ -13,4 +13,4 @@ def number_connected_components(G: Graph[_Node]): ... @_dispatchable def is_connected(G: Graph[_Node]) -> bool: ... @_dispatchable -def node_connected_component(G: Graph[_Node], n: _Node): ... +def node_connected_component(G: Graph[_Node], n: _Node) -> set[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi index 8060b1e332c0..ca37ffb15d70 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi @@ -31,11 +31,11 @@ def node_connectivity( G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable[..., Incomplete] | None = None ): ... @_dispatchable -def average_node_connectivity(G: Graph[_Node], flow_func: Callable[..., Incomplete] | None = None): ... +def average_node_connectivity(G: Graph[_Node], flow_func: Callable[..., Incomplete] | None = None) -> float: ... @_dispatchable def all_pairs_node_connectivity( G: Graph[_Node], nbunch: Iterable[Incomplete] | None = None, flow_func: Callable[..., Incomplete] | None = None -): ... +) -> dict[Incomplete, dict[Incomplete, Incomplete]]: ... @_dispatchable def local_edge_connectivity( G: Graph[_Node], diff --git a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi index d9c41c57195d..4170cc9d37cf 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete from collections.abc import Callable +from typing_extensions import Never from networkx.algorithms.flow import edmonds_karp from networkx.classes.digraph import DiGraph @@ -17,7 +18,7 @@ def minimum_st_edge_cut( flow_func: Callable[..., Incomplete] | None = None, auxiliary: DiGraph[_Node] | None = None, residual: DiGraph[_Node] | None = None, -): ... +) -> set[tuple[Incomplete, Incomplete]]: ... @_dispatchable def minimum_st_node_cut( G: Graph[_Node], @@ -26,12 +27,12 @@ def minimum_st_node_cut( flow_func: Callable[..., Incomplete] | None = None, auxiliary: DiGraph[_Node] | None = None, residual: DiGraph[_Node] | None = None, -): ... +) -> dict[Never, Never] | set[Incomplete]: ... @_dispatchable def minimum_node_cut( G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable[..., Incomplete] | None = None -): ... +) -> dict[Never, Never] | set[Incomplete]: ... @_dispatchable def minimum_edge_cut( G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable[..., Incomplete] | None = None -): ... +) -> set[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi index e4363950aadf..6b7c1e1a3b2a 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi @@ -9,5 +9,5 @@ __all__ = ["k_components"] default_flow_func = edmonds_karp @_dispatchable -def k_components(G: Graph[_Node], flow_func: Callable[..., Incomplete] | None = None): ... +def k_components(G: Graph[_Node], flow_func: Callable[..., Incomplete] | None = None) -> dict[Incomplete, Incomplete]: ... def build_k_number_dict(kcomps) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/core.pyi b/stubs/networkx/networkx/algorithms/core.pyi index acd4b9b7a2f0..386a3c65b0cf 100644 --- a/stubs/networkx/networkx/algorithms/core.pyi +++ b/stubs/networkx/networkx/algorithms/core.pyi @@ -6,7 +6,7 @@ from networkx.utils.backends import _dispatchable __all__ = ["core_number", "k_core", "k_shell", "k_crust", "k_corona", "k_truss", "onion_layers"] @_dispatchable -def core_number(G: Graph[_Node]): ... +def core_number(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ... @_dispatchable def k_core(G: Graph[_Node], k: int | None = None, core_number: SupportsGetItem[Incomplete, Incomplete] | None = None): ... @_dispatchable @@ -18,4 +18,4 @@ def k_corona(G: Graph[_Node], k: int, core_number: SupportsGetItem[Incomplete, I @_dispatchable def k_truss(G: Graph[_Node], k: int): ... @_dispatchable -def onion_layers(G: Graph[_Node]): ... +def onion_layers(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/covering.pyi b/stubs/networkx/networkx/algorithms/covering.pyi index 2bbc194af9d7..e10e1967bb6f 100644 --- a/stubs/networkx/networkx/algorithms/covering.pyi +++ b/stubs/networkx/networkx/algorithms/covering.pyi @@ -7,6 +7,6 @@ from networkx.utils.backends import _dispatchable __all__ = ["min_edge_cover", "is_edge_cover"] @_dispatchable -def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable[..., Incomplete] | None = None): ... +def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable[..., Incomplete] | None = None) -> set[Incomplete]: ... @_dispatchable def is_edge_cover(G: Graph[_Node], cover: Iterable[Iterable[Incomplete]]) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/dag.pyi b/stubs/networkx/networkx/algorithms/dag.pyi index b44d34db3690..ba6625a8fcc3 100644 --- a/stubs/networkx/networkx/algorithms/dag.pyi +++ b/stubs/networkx/networkx/algorithms/dag.pyi @@ -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]) -> Graph[_Node]: ... +def dag_to_branching(G: Graph[_Node]) -> DiGraph[_Node]: ... @_dispatchable def compute_v_structures(G) -> Generator[tuple[Incomplete, Incomplete, Incomplete]]: ... diff --git a/stubs/networkx/networkx/algorithms/distance_measures.pyi b/stubs/networkx/networkx/algorithms/distance_measures.pyi index 26f5a618fdd9..6d711d767808 100644 --- a/stubs/networkx/networkx/algorithms/distance_measures.pyi +++ b/stubs/networkx/networkx/algorithms/distance_measures.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Callable from typing_extensions import TypeAlias @@ -20,21 +21,27 @@ __all__ = [ ] @_dispatchable -def eccentricity(G: Graph[_Node], v: _Node | None = None, sp=None, weight: str | _WeightFunction | None = None): ... +def eccentricity( + G: Graph[_Node], v: _Node | None = None, sp=None, weight: str | _WeightFunction | None = None +) -> Incomplete | dict[Incomplete, Incomplete]: ... @_dispatchable def diameter(G: Graph[_Node], e=None, usebounds: bool = False, weight: str | _WeightFunction | None = None): ... @_dispatchable def harmonic_diameter(G, sp=None, *, weight: str | _WeightFunction | None = None) -> float: ... @_dispatchable -def periphery(G: Graph[_Node], e=None, usebounds: bool = False, weight: str | _WeightFunction | None = None): ... +def periphery( + G: Graph[_Node], e=None, usebounds: bool = False, weight: str | _WeightFunction | None = None +) -> list[Incomplete]: ... @_dispatchable def radius(G: Graph[_Node], e=None, usebounds: bool = False, weight: str | _WeightFunction | None = None): ... @_dispatchable -def center(G: Graph[_Node], e=None, usebounds: bool = False, weight: str | _WeightFunction | None = None): ... +def center(G: Graph[_Node], e=None, usebounds: bool = False, weight: str | _WeightFunction | None = None) -> list[Incomplete]: ... @_dispatchable -def barycenter(G, weight: str | _WeightFunction | None = None, attr=None, sp=None): ... +def barycenter(G, weight: str | _WeightFunction | None = None, attr=None, sp=None) -> list[Incomplete]: ... @_dispatchable -def resistance_distance(G: Graph[_Node], nodeA=None, nodeB=None, weight: str | None = None, invert_weight: bool = True): ... +def resistance_distance( + G: Graph[_Node], nodeA=None, nodeB=None, weight: str | None = None, invert_weight: bool = True +) -> float | dict[Incomplete, float]: ... @_dispatchable def effective_graph_resistance(G, weight: str | None = None, invert_weight: bool = True) -> float: ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/distance_regular.pyi b/stubs/networkx/networkx/algorithms/distance_regular.pyi index 4fd942c5f6d9..9061e2e596ce 100644 --- a/stubs/networkx/networkx/algorithms/distance_regular.pyi +++ b/stubs/networkx/networkx/algorithms/distance_regular.pyi @@ -1,3 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Generator + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -6,7 +9,7 @@ __all__ = ["is_distance_regular", "is_strongly_regular", "intersection_array", " @_dispatchable def is_distance_regular(G: Graph[_Node]) -> bool: ... @_dispatchable -def global_parameters(b, c): ... +def global_parameters(b, c) -> Generator[tuple[Incomplete, Incomplete, Incomplete]]: ... @_dispatchable def intersection_array(G: Graph[_Node]): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/efficiency_measures.pyi b/stubs/networkx/networkx/algorithms/efficiency_measures.pyi index 13369a99ef06..8c2205b20e5f 100644 --- a/stubs/networkx/networkx/algorithms/efficiency_measures.pyi +++ b/stubs/networkx/networkx/algorithms/efficiency_measures.pyi @@ -4,8 +4,8 @@ from networkx.utils.backends import _dispatchable __all__ = ["efficiency", "local_efficiency", "global_efficiency"] @_dispatchable -def efficiency(G, u: _Node, v: _Node): ... +def efficiency(G, u: _Node, v: _Node) -> float: ... @_dispatchable -def global_efficiency(G): ... +def global_efficiency(G) -> float: ... @_dispatchable -def local_efficiency(G): ... +def local_efficiency(G) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/flow/mincost.pyi b/stubs/networkx/networkx/algorithms/flow/mincost.pyi index 86c8e66dcd6c..ee2cfc8cc1c5 100644 --- a/stubs/networkx/networkx/algorithms/flow/mincost.pyi +++ b/stubs/networkx/networkx/algorithms/flow/mincost.pyi @@ -8,8 +8,12 @@ __all__ = ["min_cost_flow_cost", "min_cost_flow", "cost_of_flow", "max_flow_min_ @_dispatchable def min_cost_flow_cost(G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... @_dispatchable -def min_cost_flow(G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... +def min_cost_flow( + G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight" +) -> tuple[int | Incomplete, dict[Incomplete, dict[Incomplete, Incomplete]]]: ... @_dispatchable def cost_of_flow(G: Graph[_Node], flowDict: SupportsGetItem[Incomplete, Incomplete], weight: str = "weight"): ... @_dispatchable -def max_flow_min_cost(G: Graph[_Node], s: str, t: str, capacity: str = "capacity", weight: str = "weight"): ... +def max_flow_min_cost( + G: Graph[_Node], s: str, t: str, capacity: str = "capacity", weight: str = "weight" +) -> tuple[int | Incomplete, dict[Incomplete, dict[Incomplete, Incomplete]]]: ... diff --git a/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi b/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi index c6028757f936..788176935ea5 100644 --- a/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi +++ b/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi @@ -43,4 +43,6 @@ class _DataEssentialsAndFunctions: def find_leaving_edge(self, Wn, We): ... @_dispatchable -def network_simplex(G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... +def network_simplex( + G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight" +) -> tuple[int | Incomplete, dict[Incomplete, dict[Incomplete, Incomplete]]]: ... diff --git a/stubs/networkx/networkx/algorithms/graph_hashing.pyi b/stubs/networkx/networkx/algorithms/graph_hashing.pyi index 7232060d585f..9829cc627f79 100644 --- a/stubs/networkx/networkx/algorithms/graph_hashing.pyi +++ b/stubs/networkx/networkx/algorithms/graph_hashing.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -10,7 +12,7 @@ def weisfeiler_lehman_graph_hash( node_attr: str | None = None, iterations: int | None = 3, digest_size: int | None = 16, -): ... +) -> str: ... @_dispatchable def weisfeiler_lehman_subgraph_hashes( G: Graph[_Node], @@ -19,4 +21,4 @@ def weisfeiler_lehman_subgraph_hashes( iterations: int | None = 3, digest_size: int | None = 16, include_initial_labels: bool | None = False, -): ... +) -> dict[Incomplete, list[str]]: ... diff --git a/stubs/networkx/networkx/algorithms/hierarchy.pyi b/stubs/networkx/networkx/algorithms/hierarchy.pyi index e982bfa88a4f..745e0bd1d921 100644 --- a/stubs/networkx/networkx/algorithms/hierarchy.pyi +++ b/stubs/networkx/networkx/algorithms/hierarchy.pyi @@ -3,4 +3,4 @@ from networkx.utils.backends import _dispatchable __all__ = ["flow_hierarchy"] @_dispatchable -def flow_hierarchy(G, weight: str | None = None): ... +def flow_hierarchy(G, weight: str | None = None) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/isolate.pyi b/stubs/networkx/networkx/algorithms/isolate.pyi index afcd43f5f879..95a78fa04f4d 100644 --- a/stubs/networkx/networkx/algorithms/isolate.pyi +++ b/stubs/networkx/networkx/algorithms/isolate.pyi @@ -8,4 +8,4 @@ def is_isolate(G: Graph[_Node], n: _Node) -> bool: ... @_dispatchable def isolates(G: Graph[_Node]): ... @_dispatchable -def number_of_isolates(G: Graph[_Node]): ... +def number_of_isolates(G: Graph[_Node]) -> int: ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi index a16ea3e8ba11..76b00f5fd01c 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi @@ -14,6 +14,6 @@ class ISMAGS: def largest_common_subgraph(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, None]: ... def analyze_symmetry(self, graph, node_partitions, edge_colors): ... def is_isomorphic(self, symmetry: bool = False) -> bool: ... - def subgraph_is_isomorphic(self, symmetry: bool = False): ... + def subgraph_is_isomorphic(self, symmetry: bool = False) -> bool: ... def isomorphisms_iter(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, None]: ... def subgraph_isomorphisms_iter(self, symmetry: bool = True): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi b/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi index 7a193aa7fdd8..858ac56d06e8 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -6,6 +8,6 @@ __all__ = ["rooted_tree_isomorphism", "tree_isomorphism"] @_dispatchable def root_trees(t1, root1, t2, root2): ... @_dispatchable -def rooted_tree_isomorphism(t1, root1, t2, root2): ... +def rooted_tree_isomorphism(t1, root1, t2, root2) -> list[tuple[Incomplete, Incomplete]]: ... @_dispatchable -def tree_isomorphism(t1: Graph[_Node], t2: Graph[_Node]): ... +def tree_isomorphism(t1: Graph[_Node], t2: Graph[_Node]) -> list[tuple[Incomplete, Incomplete]]: ... diff --git a/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi b/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi index 93a97d20ea4b..fca4adccedf9 100644 --- a/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi +++ b/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi @@ -16,7 +16,7 @@ def pagerank( nstart: SupportsGetItem[Incomplete, Incomplete] | None = None, weight: str | None = "weight", dangling: SupportsGetItem[Incomplete, Incomplete] | None = None, -): ... +) -> dict[Incomplete, float]: ... @_dispatchable def google_matrix( G: Graph[_Node], diff --git a/stubs/networkx/networkx/algorithms/matching.pyi b/stubs/networkx/networkx/algorithms/matching.pyi index ee66595d0542..e55e966ed3ca 100644 --- a/stubs/networkx/networkx/algorithms/matching.pyi +++ b/stubs/networkx/networkx/algorithms/matching.pyi @@ -14,7 +14,7 @@ __all__ = [ ] @_dispatchable -def maximal_matching(G: Graph[_Node]): ... +def maximal_matching(G: Graph[_Node]) -> set[Incomplete]: ... def matching_dict_to_set(matching: Mapping[Incomplete, Incomplete]) -> set[Incomplete]: ... @_dispatchable def is_matching(G: Graph[_Node], matching: dict[Incomplete, Incomplete] | Iterable[Iterable[Incomplete]]) -> bool: ... @@ -23,6 +23,8 @@ def is_maximal_matching(G: Graph[_Node], matching: dict[Incomplete, Incomplete] @_dispatchable def is_perfect_matching(G: Graph[_Node], matching: dict[Incomplete, Incomplete] | Iterable[Iterable[Incomplete]]) -> bool: ... @_dispatchable -def min_weight_matching(G: Graph[_Node], weight: str | None = "weight"): ... +def min_weight_matching(G: Graph[_Node], weight: str | None = "weight") -> set[Incomplete]: ... @_dispatchable -def max_weight_matching(G: Graph[_Node], maxcardinality: bool | None = False, weight: str | None = "weight"): ... +def max_weight_matching( + G: Graph[_Node], maxcardinality: bool | None = False, weight: str | None = "weight" +) -> set[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/mis.pyi b/stubs/networkx/networkx/algorithms/mis.pyi index bbe4abaeb266..b0b6a9914384 100644 --- a/stubs/networkx/networkx/algorithms/mis.pyi +++ b/stubs/networkx/networkx/algorithms/mis.pyi @@ -10,4 +10,4 @@ __all__ = ["maximal_independent_set"] @_dispatchable def maximal_independent_set( G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, seed: int | RandomState | None = None -): ... +) -> list[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/planar_drawing.pyi b/stubs/networkx/networkx/algorithms/planar_drawing.pyi index 5bf598392b16..d4c6164ed122 100644 --- a/stubs/networkx/networkx/algorithms/planar_drawing.pyi +++ b/stubs/networkx/networkx/algorithms/planar_drawing.pyi @@ -6,7 +6,7 @@ from networkx.utils.backends import _dispatchable __all__ = ["combinatorial_embedding_to_pos"] @_dispatchable -def combinatorial_embedding_to_pos(embedding, fully_triangulate: bool = False): ... +def combinatorial_embedding_to_pos(embedding, fully_triangulate: bool = False) -> dict[Incomplete, Incomplete]: ... def set_position(parent, tree, remaining_nodes, delta_x, y_coordinate, pos): ... def get_canonical_ordering(embedding, outer_face: Sequence[Incomplete]) -> list[Incomplete]: ... def triangulate_face(embedding, v1, v2): ... diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index f444db48762a..f8f0f621ff89 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -54,7 +54,7 @@ class LRPlanarity: embedding: Incomplete def __init__(self, G) -> None: ... - def lr_planarity(self): ... + def lr_planarity(self) -> PlanarEmbedding[Incomplete] | None: ... def lr_planarity_recursive(self): ... def dfs_orientation(self, v): ... def dfs_orientation_recursive(self, v) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/reciprocity.pyi b/stubs/networkx/networkx/algorithms/reciprocity.pyi index 2208e9e00507..de7191d31c0e 100644 --- a/stubs/networkx/networkx/algorithms/reciprocity.pyi +++ b/stubs/networkx/networkx/algorithms/reciprocity.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -6,6 +7,6 @@ from networkx.utils.backends import _dispatchable __all__ = ["reciprocity", "overall_reciprocity"] @_dispatchable -def reciprocity(G: Graph[_Node], nodes: Iterable[_Node] | None = None): ... +def reciprocity(G: Graph[_Node], nodes: Iterable[_Node] | None = None) -> float | dict[Incomplete, float | None]: ... @_dispatchable def overall_reciprocity(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/richclub.pyi b/stubs/networkx/networkx/algorithms/richclub.pyi index abf5cd680b9a..2f2b25d7b987 100644 --- a/stubs/networkx/networkx/algorithms/richclub.pyi +++ b/stubs/networkx/networkx/algorithms/richclub.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState @@ -5,4 +7,6 @@ from numpy.random import RandomState __all__ = ["rich_club_coefficient"] @_dispatchable -def rich_club_coefficient(G: Graph[_Node], normalized: bool = True, Q: float = 100, seed: int | RandomState | None = None): ... +def rich_club_coefficient( + G: Graph[_Node], normalized: bool = True, Q: float = 100, seed: int | RandomState | None = None +) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi index ce36193312ab..96c6399f63cb 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete, SupportsGetItem +from collections import defaultdict from collections.abc import Collection from networkx.classes.graph import Graph, _Node @@ -9,8 +10,10 @@ __all__ = ["floyd_warshall", "floyd_warshall_predecessor_and_distance", "reconst @_dispatchable 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"): ... +def floyd_warshall_predecessor_and_distance( + G: Graph[_Node], weight: str | None = "weight" +) -> tuple[dict[Incomplete, dict[Incomplete, Incomplete]], dict[Incomplete, dict[Incomplete, float]]]: ... @_dispatchable -def reconstruct_path(source: _Node, target: _Node, predecessors: SupportsGetItem[Incomplete, Incomplete]): ... +def reconstruct_path(source: _Node, target: _Node, predecessors: SupportsGetItem[Incomplete, Incomplete]) -> list[Incomplete]: ... @_dispatchable -def floyd_warshall(G: Graph[_Node], weight: str | None = "weight"): ... +def floyd_warshall(G: Graph[_Node], weight: str | None = "weight") -> dict[Incomplete, defaultdict[Incomplete, float]]: ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi index 7b5248b19985..e7008bdc9b2b 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi @@ -16,19 +16,25 @@ __all__ = [ ] @_dispatchable -def single_source_shortest_path_length(G: Graph[_Node], source: _Node, cutoff: int | None = None): ... +def single_source_shortest_path_length(G: Graph[_Node], source: _Node, cutoff: int | None = None) -> dict[Incomplete, int]: ... @_dispatchable def single_target_shortest_path_length(G: Graph[_Node], target: _Node, cutoff: int | None = None): ... @_dispatchable def all_pairs_shortest_path_length(G: Graph[_Node], cutoff: int | None = None) -> Generator[Incomplete, None, None]: ... @_dispatchable -def bidirectional_shortest_path(G: Graph[_Node], source: _Node, target: _Node): ... +def bidirectional_shortest_path(G: Graph[_Node], source: _Node, target: _Node) -> list[Incomplete]: ... @_dispatchable -def single_source_shortest_path(G: Graph[_Node], source: _Node, cutoff: int | None = None): ... +def single_source_shortest_path( + G: Graph[_Node], source: _Node, cutoff: int | None = None +) -> dict[Incomplete, list[Incomplete]]: ... @_dispatchable -def single_target_shortest_path(G: Graph[_Node], target: _Node, cutoff: int | None = None): ... +def single_target_shortest_path( + G: Graph[_Node], target: _Node, cutoff: int | None = None +) -> dict[Incomplete, list[Incomplete]]: ... @_dispatchable -def all_pairs_shortest_path(G: Graph[_Node], cutoff: int | None = None) -> Generator[Incomplete, None, None]: ... +def all_pairs_shortest_path( + G: Graph[_Node], cutoff: int | None = None +) -> Generator[tuple[Incomplete, dict[Incomplete, list[Incomplete]]]]: ... @_dispatchable def predecessor( G: Graph[_Node], source: _Node, target: _Node | None = None, cutoff: int | None = None, return_seen: bool | None = None diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi index 28fb31c561ec..39284b9cce64 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi @@ -39,7 +39,7 @@ def dijkstra_path( source: _Node, target: _Node, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> dict[Incomplete, list[Incomplete]] | list[Incomplete]: ... @_dispatchable def dijkstra_path_length( G: Graph[_Node], @@ -53,14 +53,14 @@ def single_source_dijkstra_path( source: _Node, cutoff: float | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> dict[Incomplete, list[Incomplete]] | list[Incomplete]: ... @_dispatchable def single_source_dijkstra_path_length( G: Graph[_Node], source: _Node, cutoff: float | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> dict[Incomplete, Incomplete]: ... @_dispatchable def single_source_dijkstra( G: Graph[_Node], @@ -68,21 +68,21 @@ def single_source_dijkstra( target: _Node | None = None, cutoff: float | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> tuple[Incomplete, Incomplete]: ... @_dispatchable def multi_source_dijkstra_path( G: Graph[_Node], sources, cutoff: float | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> dict[Incomplete, list[Incomplete]] | list[Incomplete]: ... @_dispatchable def multi_source_dijkstra_path_length( G: Graph[_Node], sources, cutoff: float | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> dict[Incomplete, Incomplete]: ... @_dispatchable def multi_source_dijkstra( G: Graph[_Node], @@ -90,14 +90,14 @@ def multi_source_dijkstra( target: _Node | None = None, cutoff: float | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> tuple[Incomplete, Incomplete]: ... @_dispatchable def dijkstra_predecessor_and_distance( G: Graph[_Node], source: _Node, cutoff: float | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> tuple[dict[Incomplete, list[Incomplete]], dict[Incomplete, Incomplete]]: ... @_dispatchable def all_pairs_dijkstra( G: Graph[_Node], @@ -115,7 +115,7 @@ def all_pairs_dijkstra_path( G: Graph[_Node], cutoff: float | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -) -> Generator[Incomplete, None, None]: ... +) -> Generator[tuple[Incomplete, Incomplete], None, None]: ... @_dispatchable def bellman_ford_predecessor_and_distance( G: Graph[_Node], @@ -123,14 +123,14 @@ def bellman_ford_predecessor_and_distance( target: _Node | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", heuristic: bool = False, -): ... +) -> tuple[Incomplete, Incomplete]: ... @_dispatchable def bellman_ford_path( G: Graph[_Node], source: _Node, target: _Node, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> list[Incomplete] | dict[Incomplete, list[Incomplete]]: ... @_dispatchable def bellman_ford_path_length( G: Graph[_Node], @@ -141,11 +141,11 @@ def bellman_ford_path_length( @_dispatchable def single_source_bellman_ford_path( G: Graph[_Node], source: _Node, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight" -): ... +) -> list[Incomplete] | dict[Incomplete, list[Incomplete]]: ... @_dispatchable def single_source_bellman_ford_path_length( G: Graph[_Node], source: _Node, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight" -): ... +) -> dict[Incomplete, int]: ... @_dispatchable def single_source_bellman_ford( G: Graph[_Node], @@ -160,11 +160,11 @@ def all_pairs_bellman_ford_path_length( @_dispatchable def all_pairs_bellman_ford_path( G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight" -) -> Generator[Incomplete, None, None]: ... +) -> Generator[tuple[Incomplete, Incomplete], None, None]: ... @_dispatchable def goldberg_radzik( G: Graph[_Node], source: _Node, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight" -): ... +) -> tuple[dict[Incomplete, None], dict[Incomplete, int | float]]: ... @_dispatchable def negative_edge_cycle( G: Graph[_Node], @@ -183,4 +183,6 @@ def bidirectional_dijkstra( weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ): ... @_dispatchable -def johnson(G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight"): ... +def johnson( + G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight" +) -> dict[Any, dict[Any, list[Any]]]: ... diff --git a/stubs/networkx/networkx/algorithms/similarity.pyi b/stubs/networkx/networkx/algorithms/similarity.pyi index d50ded1280eb..e2fd83794a6e 100644 --- a/stubs/networkx/networkx/algorithms/similarity.pyi +++ b/stubs/networkx/networkx/algorithms/similarity.pyi @@ -84,7 +84,7 @@ def simrank_similarity( importance_factor: float = 0.9, max_iterations: int = 1000, tolerance: float = 0.0001, -): ... +) -> float | dict[Incomplete, Incomplete]: ... @_dispatchable def panther_similarity( G: Graph[_Node], @@ -95,7 +95,7 @@ def panther_similarity( delta: float = 0.1, eps=None, weight: str | None = "weight", -): ... +) -> dict[bytes, bytes]: ... @_dispatchable def generate_random_paths( G: Graph[_Node], diff --git a/stubs/networkx/networkx/algorithms/smallworld.pyi b/stubs/networkx/networkx/algorithms/smallworld.pyi index 665226a3d6ee..3e163c121c7c 100644 --- a/stubs/networkx/networkx/algorithms/smallworld.pyi +++ b/stubs/networkx/networkx/algorithms/smallworld.pyi @@ -11,6 +11,6 @@ def lattice_reference( G: Graph[_Node], niter: int = 5, D=None, connectivity: bool = True, seed: int | RandomState | None = None ): ... @_dispatchable -def sigma(G: Graph[_Node], niter: int = 100, nrand: int = 10, seed: int | RandomState | None = None): ... +def sigma(G: Graph[_Node], niter: int = 100, nrand: int = 10, seed: int | RandomState | None = None) -> float: ... @_dispatchable -def omega(G: Graph[_Node], niter: int = 5, nrand: int = 10, seed: int | RandomState | None = None): ... +def omega(G: Graph[_Node], niter: int = 5, nrand: int = 10, seed: int | RandomState | None = None) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/smetric.pyi b/stubs/networkx/networkx/algorithms/smetric.pyi index e1cf4fd2563f..60f6d0ab5d25 100644 --- a/stubs/networkx/networkx/algorithms/smetric.pyi +++ b/stubs/networkx/networkx/algorithms/smetric.pyi @@ -4,4 +4,4 @@ from networkx.utils.backends import _dispatchable __all__ = ["s_metric"] @_dispatchable -def s_metric(G: Graph[_Node]): ... +def s_metric(G: Graph[_Node]) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/structuralholes.pyi b/stubs/networkx/networkx/algorithms/structuralholes.pyi index 15060cd5752d..e869afe75614 100644 --- a/stubs/networkx/networkx/algorithms/structuralholes.pyi +++ b/stubs/networkx/networkx/algorithms/structuralholes.pyi @@ -11,8 +11,12 @@ def mutual_weight(G: Graph[_Node], u, v, weight=None) -> Incomplete | int: ... @_dispatchable def normalized_mutual_weight(G: Graph[_Node], u, v, norm=..., weight=None) -> float: ... @_dispatchable -def effective_size(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, weight: str | None = None): ... +def effective_size( + G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, weight: str | None = None +) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def constraint(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, weight: str | None = None): ... +def constraint( + G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, weight: str | None = None +) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def local_constraint(G: Graph[_Node], u: _Node, v: _Node, weight: str | None = None): ... +def local_constraint(G: Graph[_Node], u: _Node, v: _Node, weight: str | None = None) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/swap.pyi b/stubs/networkx/networkx/algorithms/swap.pyi index 529b895d61c0..7378a13a814e 100644 --- a/stubs/networkx/networkx/algorithms/swap.pyi +++ b/stubs/networkx/networkx/algorithms/swap.pyi @@ -12,4 +12,4 @@ def double_edge_swap(G: Graph[_Node], nswap: int = 1, max_tries: int = 100, seed @_dispatchable def connected_double_edge_swap( G: Graph[_Node], nswap: int = 1, _window_threshold: int = 3, seed: int | RandomState | None = None -): ... +) -> int: ... diff --git a/stubs/networkx/networkx/algorithms/tournament.pyi b/stubs/networkx/networkx/algorithms/tournament.pyi index 5b6046f5c806..0fff43290acb 100644 --- a/stubs/networkx/networkx/algorithms/tournament.pyi +++ b/stubs/networkx/networkx/algorithms/tournament.pyi @@ -1,3 +1,6 @@ +from _typeshed import Incomplete + +from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState @@ -15,13 +18,13 @@ __all__ = [ @_dispatchable def is_tournament(G: Graph[_Node]) -> bool: ... @_dispatchable -def hamiltonian_path(G: Graph[_Node]): ... +def hamiltonian_path(G: Graph[_Node]) -> list[Incomplete]: ... @_dispatchable -def random_tournament(n: int, seed: int | RandomState | None = None): ... +def random_tournament(n: int, seed: int | RandomState | None = None) -> DiGraph[Incomplete]: ... @_dispatchable def tournament_matrix(G: Graph[_Node]): ... @_dispatchable -def score_sequence(G: Graph[_Node]): ... +def score_sequence(G: Graph[_Node]) -> list[Incomplete]: ... @_dispatchable def is_reachable(G: Graph[_Node], s: _Node, t: _Node) -> bool: ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi index f66eee33c824..4f69602e218a 100644 --- a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi @@ -25,11 +25,11 @@ def dfs_tree( @_dispatchable def dfs_predecessors( G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable[..., Incomplete] | None = None -): ... +) -> dict[Incomplete, Incomplete]: ... @_dispatchable def dfs_successors( G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable[..., Incomplete] | None = None -): ... +) -> dict[Incomplete, list[Incomplete]]: ... @_dispatchable def dfs_postorder_nodes( G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable[..., Incomplete] | None = None diff --git a/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi b/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi index 60bc903c320c..fbdb17d5f8b4 100644 --- a/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi @@ -11,4 +11,4 @@ FORWARD: Final = "forward" REVERSE: Final = "reverse" @_dispatchable -def edge_bfs(G: Graph[_Node], source=None, orientation=None) -> Generator[Incomplete, None, Incomplete]: ... +def edge_bfs(G: Graph[_Node], source=None, orientation=None) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi b/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi index a511cd2df35b..1da9da724a2b 100644 --- a/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi @@ -11,4 +11,4 @@ FORWARD: Final = "forward" REVERSE: Final = "reverse" @_dispatchable -def edge_dfs(G: Graph[_Node], source=None, orientation=None) -> Generator[Incomplete, None, Incomplete]: ... +def edge_dfs(G: Graph[_Node], source=None, orientation=None) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi index 6b08ec183376..f8e76325f13f 100644 --- a/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete -from collections.abc import Iterator from dataclasses import dataclass from typing import Final +from typing_extensions import Self from networkx.classes.digraph import DiGraph from networkx.classes.graph import _Node @@ -66,5 +66,5 @@ class ArborescenceIterator: def __init__(self, G, weight: str = "weight", minimum: bool = True, init_partition=None) -> None: ... partition_queue: Incomplete - def __iter__(self) -> Iterator[Incomplete]: ... + def __iter__(self) -> Self: ... def __next__(self): ... diff --git a/stubs/networkx/networkx/algorithms/tree/coding.pyi b/stubs/networkx/networkx/algorithms/tree/coding.pyi index afd2ee79e2a1..1a99ba4b4432 100644 --- a/stubs/networkx/networkx/algorithms/tree/coding.pyi +++ b/stubs/networkx/networkx/algorithms/tree/coding.pyi @@ -14,6 +14,6 @@ def to_nested_tuple(T: Graph[_Node], root: _Node, canonical_form: bool = False): @_dispatchable def from_nested_tuple(sequence: tuple[Incomplete], sensible_relabeling: bool = False): ... @_dispatchable -def to_prufer_sequence(T: Graph[_Node]): ... +def to_prufer_sequence(T: Graph[_Node]) -> list[Incomplete]: ... @_dispatchable def from_prufer_sequence(sequence: Iterable[Incomplete]): ... diff --git a/stubs/networkx/networkx/algorithms/tree/decomposition.pyi b/stubs/networkx/networkx/algorithms/tree/decomposition.pyi index 79889442969e..6d60295ca588 100644 --- a/stubs/networkx/networkx/algorithms/tree/decomposition.pyi +++ b/stubs/networkx/networkx/algorithms/tree/decomposition.pyi @@ -1,6 +1,9 @@ +from _typeshed import Incomplete + +from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable __all__ = ["junction_tree"] @_dispatchable -def junction_tree(G): ... +def junction_tree(G) -> Graph[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/tree/mst.pyi b/stubs/networkx/networkx/algorithms/tree/mst.pyi index f53727cbf46a..2dddfb05e7f2 100644 --- a/stubs/networkx/networkx/algorithms/tree/mst.pyi +++ b/stubs/networkx/networkx/algorithms/tree/mst.pyi @@ -1,8 +1,9 @@ from _typeshed import Incomplete -from collections.abc import Callable, Generator, Iterator +from collections.abc import Callable, Generator from dataclasses import dataclass from enum import Enum from typing import Final, Literal +from typing_extensions import Self from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -81,7 +82,7 @@ class SpanningTreeIterator: def __init__(self, G, weight: str = "weight", minimum: bool = True, ignore_nan: bool = False) -> None: ... partition_queue: Incomplete - def __iter__(self) -> Iterator[Incomplete]: ... + def __iter__(self) -> Self: ... def __next__(self): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/triads.pyi b/stubs/networkx/networkx/algorithms/triads.pyi index f155a93de025..7bd9b3334fe8 100644 --- a/stubs/networkx/networkx/algorithms/triads.pyi +++ b/stubs/networkx/networkx/algorithms/triads.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections import defaultdict from collections.abc import Collection, Generator from typing import Final @@ -13,12 +14,12 @@ TRIAD_NAMES: Final[tuple[str, ...]] TRICODE_TO_NAME: Final[dict[int, str]] @_dispatchable -def triadic_census(G: DiGraph[_Node], nodelist: Collection[_Node] | None = None): ... +def triadic_census(G: DiGraph[_Node], nodelist: Collection[_Node] | None = None) -> dict[str, int]: ... @_dispatchable def is_triad(G: Graph[_Node]) -> bool: ... @_dispatchable def all_triads(G: DiGraph[_Node]) -> Generator[Incomplete, None, None]: ... @_dispatchable -def triads_by_type(G: DiGraph[_Node]): ... +def triads_by_type(G: DiGraph[_Node]) -> defaultdict[Incomplete, list[Incomplete]]: ... @_dispatchable -def triad_type(G: DiGraph[_Node]): ... +def triad_type(G: DiGraph[_Node]) -> str | None: ... diff --git a/stubs/networkx/networkx/algorithms/vitality.pyi b/stubs/networkx/networkx/algorithms/vitality.pyi index 1d5af2c9935a..3fd2cfe0e482 100644 --- a/stubs/networkx/networkx/algorithms/vitality.pyi +++ b/stubs/networkx/networkx/algorithms/vitality.pyi @@ -1,7 +1,11 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["closeness_vitality"] @_dispatchable -def closeness_vitality(G: Graph[_Node], node=None, weight: str | None = None, wiener_index: float | None = None): ... +def closeness_vitality( + G: Graph[_Node], node=None, weight: str | None = None, wiener_index: float | None = None +) -> float | dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/voronoi.pyi b/stubs/networkx/networkx/algorithms/voronoi.pyi index cd21b3d0c246..63f890bf2591 100644 --- a/stubs/networkx/networkx/algorithms/voronoi.pyi +++ b/stubs/networkx/networkx/algorithms/voronoi.pyi @@ -12,4 +12,4 @@ def voronoi_cells( G: Graph[_Node], center_nodes: set[Incomplete], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> dict[Incomplete, set[Incomplete]]: ... diff --git a/stubs/networkx/networkx/algorithms/wiener.pyi b/stubs/networkx/networkx/algorithms/wiener.pyi index 87e87f305c3a..27130c3a4389 100644 --- a/stubs/networkx/networkx/algorithms/wiener.pyi +++ b/stubs/networkx/networkx/algorithms/wiener.pyi @@ -4,7 +4,7 @@ from networkx.utils.backends import _dispatchable __all__ = ["wiener_index", "schultz_index", "gutman_index"] @_dispatchable -def wiener_index(G: Graph[_Node], weight: str | None = None): ... +def wiener_index(G: Graph[_Node], weight: str | None = None) -> float: ... @_dispatchable def schultz_index(G, weight=None) -> float: ... @_dispatchable diff --git a/stubs/networkx/networkx/classes/digraph.pyi b/stubs/networkx/networkx/classes/digraph.pyi index 90b403fe4b99..dacf44f8d48c 100644 --- a/stubs/networkx/networkx/classes/digraph.pyi +++ b/stubs/networkx/networkx/classes/digraph.pyi @@ -1,10 +1,11 @@ from _typeshed import Incomplete from collections.abc import Iterator from functools import cached_property +from typing_extensions import Self from networkx.classes.coreviews import AdjacencyView from networkx.classes.graph import Graph, _Node -from networkx.classes.reportviews import DiDegreeView, OutEdgeView +from networkx.classes.reportviews import InDegreeView, InMultiDegreeView, OutDegreeView, OutEdgeView, OutMultiDegreeView __all__ = ["DiGraph"] @@ -23,9 +24,9 @@ class DiGraph(Graph[_Node]): @cached_property def in_edges(self) -> OutEdgeView[_Node]: ... @cached_property - def in_degree(self) -> DiDegreeView[_Node]: ... + def in_degree(self) -> InDegreeView[_Node] | InMultiDegreeView[_Node]: ... # Include subtypes' possible return types @cached_property - def out_degree(self) -> DiDegreeView[_Node]: ... - def to_undirected(self, reciprocal: bool = False, as_view: bool = False): ... # type: ignore[override] # Has an additional `reciprocal` keyword argument - def reverse(self, copy: bool = True) -> DiGraph[_Node]: ... + def out_degree(self) -> OutDegreeView[_Node] | OutMultiDegreeView[_Node]: ... # Include subtypes' possible return types + def to_undirected(self, reciprocal: bool = False, as_view: bool = False) -> Graph[_Node]: ... # type: ignore[override] # Has an additional `reciprocal` keyword argument + def reverse(self, copy: bool = True) -> Self: ... def copy(self, as_view: bool = False) -> DiGraph[_Node]: ... diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index a200536cf9fb..952bfd4b5a8e 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -59,7 +59,7 @@ def neighbors(G, n): ... def number_of_nodes(G): ... def number_of_edges(G): ... def density(G): ... -def degree_histogram(G): ... +def degree_histogram(G) -> list[int]: ... @overload def is_directed(G: PlanarEmbedding[Hashable]) -> Literal[False]: ... # type: ignore[misc] # Incompatible return types @overload diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi index 557448a229ab..ec771d64ece9 100644 --- a/stubs/networkx/networkx/classes/graph.pyi +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -7,7 +7,7 @@ from typing_extensions import Self, TypeAlias import numpy from networkx.classes.coreviews import AdjacencyView, AtlasView from networkx.classes.digraph import DiGraph -from networkx.classes.reportviews import DiDegreeView, NodeView, OutEdgeView +from networkx.classes.reportviews import DegreeView, DiDegreeView, NodeView, OutEdgeView _Node = TypeVar("_Node", bound=Hashable) _NodeWithData: TypeAlias = tuple[_Node, dict[str, Any]] @@ -82,7 +82,7 @@ class Graph(Collection[_Node]): def get_edge_data(self, u: _Node, v: _Node, default=None) -> Mapping[str, Incomplete]: ... def adjacency(self) -> Iterator[tuple[_Node, Mapping[_Node, Mapping[str, Incomplete]]]]: ... @cached_property - def degree(self) -> DiDegreeView[_Node]: ... + def degree(self) -> DegreeView[_Node] | DiDegreeView[_Node]: ... # Include subtypes' possible return types def clear(self) -> None: ... def clear_edges(self) -> None: ... def is_multigraph(self) -> bool: ... diff --git a/stubs/networkx/networkx/classes/multigraph.pyi b/stubs/networkx/networkx/classes/multigraph.pyi index 58406cbc3c4b..a35727bdf7e0 100644 --- a/stubs/networkx/networkx/classes/multigraph.pyi +++ b/stubs/networkx/networkx/classes/multigraph.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Mapping from functools import cached_property from typing import ClassVar from typing_extensions import TypeAlias @@ -23,7 +24,7 @@ class MultiGraph(Graph[_Node]): def has_edge(self, u: _Node, v: _Node, key=None) -> bool: ... def get_edge_data( # type: ignore[override] # Has an additional `key` keyword argument self, u, v, key=None, default=None - ): ... + ) -> Mapping[str, Incomplete]: ... def copy(self, as_view: bool = False) -> MultiGraph[_Node]: ... def to_directed(self, as_view: bool = False) -> MultiDiGraph[_Node]: ... def to_undirected(self, as_view: bool = False) -> MultiGraph[_Node]: ... diff --git a/stubs/networkx/networkx/drawing/layout.pyi b/stubs/networkx/networkx/drawing/layout.pyi index d25734345473..1a9a753af881 100644 --- a/stubs/networkx/networkx/drawing/layout.pyi +++ b/stubs/networkx/networkx/drawing/layout.pyi @@ -22,9 +22,15 @@ __all__ = [ "arf_layout", ] -def random_layout(G, center=None, dim: int = 2, seed: int | RandomState | None = None, store_pos_as: str | None = None): ... -def circular_layout(G, scale: float = 1, center=None, dim: int = 2, store_pos_as: str | None = None): ... -def shell_layout(G, nlist=None, rotate=None, scale: float = 1, center=None, dim: int = 2, store_pos_as: str | None = None): ... +def random_layout( + G, center=None, dim: int = 2, seed: int | RandomState | None = None, store_pos_as: str | None = None +) -> dict[Incomplete, Incomplete]: ... +def circular_layout( + G, scale: float = 1, center=None, dim: int = 2, store_pos_as: str | None = None +) -> dict[Incomplete, Incomplete]: ... +def shell_layout( + G, nlist=None, rotate=None, scale: float = 1, center=None, dim: int = 2, store_pos_as: str | None = None +) -> dict[Incomplete, Incomplete]: ... def bipartite_layout( G, nodes=None, @@ -33,7 +39,7 @@ def bipartite_layout( center=None, aspect_ratio: float = ..., store_pos_as: str | None = None, -): ... +) -> dict[Incomplete, Incomplete]: ... def spring_layout( G, k=None, @@ -50,15 +56,19 @@ def spring_layout( *, method: str = "auto", gravity: float = 1.0, -): ... +) -> dict[Incomplete, Incomplete]: ... fruchterman_reingold_layout = spring_layout def kamada_kawai_layout( G, dist=None, pos=None, weight: str = "weight", scale: float = 1, center=None, dim: int = 2, store_pos_as: str | None = None -): ... -def spectral_layout(G, weight: str = "weight", scale: float = 1, center=None, dim: int = 2, store_pos_as: str | None = None): ... -def planar_layout(G, scale: float = 1, center=None, dim: int = 2, store_pos_as: str | None = None): ... +) -> dict[Incomplete, Incomplete]: ... +def spectral_layout( + G, weight: str = "weight", scale: float = 1, center=None, dim: int = 2, store_pos_as: str | None = None +) -> dict[Incomplete, Incomplete]: ... +def planar_layout( + G, scale: float = 1, center=None, dim: int = 2, store_pos_as: str | None = None +) -> dict[Incomplete, Incomplete]: ... def spiral_layout( G, scale: float = 1, @@ -67,10 +77,10 @@ def spiral_layout( resolution: float = 0.35, equidistant: bool = False, store_pos_as: str | None = None, -): ... +) -> dict[Incomplete, Incomplete]: ... def multipartite_layout( G, subset_key: str = "subset", align: str = "vertical", scale: float = 1, center=None, store_pos_as: str | None = None -): ... +) -> dict[Incomplete, Incomplete]: ... def arf_layout( G, pos=None, diff --git a/stubs/networkx/networkx/drawing/nx_pydot.pyi b/stubs/networkx/networkx/drawing/nx_pydot.pyi index 1a84f8d510f0..34f6d29afdec 100644 --- a/stubs/networkx/networkx/drawing/nx_pydot.pyi +++ b/stubs/networkx/networkx/drawing/nx_pydot.pyi @@ -1,10 +1,14 @@ +from _typeshed import Incomplete + from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["write_dot", "read_dot", "graphviz_layout", "pydot_layout", "to_pydot", "from_pydot"] def write_dot(G, path) -> None: ... @_dispatchable -def read_dot(path): ... +def read_dot(path) -> Graph[Incomplete]: ... @_dispatchable def from_pydot(P): ... def to_pydot(N): ... diff --git a/stubs/networkx/networkx/generators/atlas.pyi b/stubs/networkx/networkx/generators/atlas.pyi index d90e9a73844e..7b89477ab253 100644 --- a/stubs/networkx/networkx/generators/atlas.pyi +++ b/stubs/networkx/networkx/generators/atlas.pyi @@ -1,8 +1,11 @@ import sys +from _typeshed import Incomplete from typing import Final from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + if sys.version_info >= (3, 11): from importlib.resources.abc import Traversable else: @@ -14,6 +17,6 @@ NUM_GRAPHS: Final = 1253 ATLAS_FILE: Final[Traversable] @_dispatchable -def graph_atlas(i): ... +def graph_atlas(i) -> Graph[Incomplete]: ... @_dispatchable -def graph_atlas_g(): ... +def graph_atlas_g() -> list[Graph[Incomplete]]: ... diff --git a/stubs/networkx/networkx/generators/degree_seq.pyi b/stubs/networkx/networkx/generators/degree_seq.pyi index 325b6d911e6a..0378d273caaf 100644 --- a/stubs/networkx/networkx/generators/degree_seq.pyi +++ b/stubs/networkx/networkx/generators/degree_seq.pyi @@ -2,6 +2,11 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable +from ..classes.digraph import DiGraph +from ..classes.graph import Graph +from ..classes.multidigraph import MultiDiGraph +from ..classes.multigraph import MultiGraph + __all__ = [ "configuration_model", "directed_configuration_model", @@ -13,19 +18,21 @@ __all__ = [ ] @_dispatchable -def configuration_model(deg_sequence, create_using=None, seed=None): ... +def configuration_model(deg_sequence, create_using=None, seed=None) -> MultiGraph[Incomplete]: ... @_dispatchable -def directed_configuration_model(in_degree_sequence, out_degree_sequence, create_using=None, seed=None): ... +def directed_configuration_model( + in_degree_sequence, out_degree_sequence, create_using=None, seed=None +) -> MultiDiGraph[Incomplete]: ... @_dispatchable -def expected_degree_graph(w, seed=None, selfloops: bool = True): ... +def expected_degree_graph(w, seed=None, selfloops: bool = True) -> Graph[Incomplete]: ... @_dispatchable def havel_hakimi_graph(deg_sequence, create_using=None): ... @_dispatchable -def directed_havel_hakimi_graph(in_deg_sequence, out_deg_sequence, create_using=None): ... +def directed_havel_hakimi_graph(in_deg_sequence, out_deg_sequence, create_using=None) -> DiGraph[Incomplete]: ... @_dispatchable def degree_sequence_tree(deg_sequence, create_using=None): ... @_dispatchable -def random_degree_sequence_graph(sequence, seed=None, tries: int = 10): ... +def random_degree_sequence_graph(sequence, seed=None, tries: int = 10) -> Graph[Incomplete]: ... class DegreeSequenceRandomGraph: rng: Incomplete diff --git a/stubs/networkx/networkx/generators/directed.pyi b/stubs/networkx/networkx/generators/directed.pyi index d1a121c985da..dbddbecf23c0 100644 --- a/stubs/networkx/networkx/generators/directed.pyi +++ b/stubs/networkx/networkx/generators/directed.pyi @@ -1,5 +1,9 @@ +from _typeshed import Incomplete + from networkx.utils.backends import _dispatchable +from ..classes import MultiDiGraph + __all__ = ["gn_graph", "gnc_graph", "gnr_graph", "random_k_out_graph", "scale_free_graph"] @_dispatchable @@ -23,4 +27,4 @@ def scale_free_graph( @_dispatchable def random_uniform_k_out_graph(n: int, k: int, self_loops: bool = True, with_replacement: bool = True, seed=None): ... @_dispatchable -def random_k_out_graph(n, k, alpha, self_loops: bool = True, seed=None): ... +def random_k_out_graph(n, k, alpha, self_loops: bool = True, seed=None) -> MultiDiGraph[Incomplete]: ... diff --git a/stubs/networkx/networkx/generators/duplication.pyi b/stubs/networkx/networkx/generators/duplication.pyi index 7371b6dc5ffd..387f761bea60 100644 --- a/stubs/networkx/networkx/generators/duplication.pyi +++ b/stubs/networkx/networkx/generators/duplication.pyi @@ -1,8 +1,12 @@ +from _typeshed import Incomplete + from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["partial_duplication_graph", "duplication_divergence_graph"] @_dispatchable def partial_duplication_graph(N, n, p, q, seed=None): ... @_dispatchable -def duplication_divergence_graph(n, p, seed=None): ... +def duplication_divergence_graph(n, p, seed=None) -> Graph[Incomplete]: ... diff --git a/stubs/networkx/networkx/generators/geometric.pyi b/stubs/networkx/networkx/generators/geometric.pyi index 2147ac1b0104..d6493e7f6275 100644 --- a/stubs/networkx/networkx/generators/geometric.pyi +++ b/stubs/networkx/networkx/generators/geometric.pyi @@ -23,7 +23,9 @@ def soft_random_geometric_graph(n, radius, dim: int = 2, pos=None, p: float = 2, @_dispatchable def geographical_threshold_graph(n, theta, dim: int = 2, pos=None, weight=None, metric=None, p_dist=None, seed=None): ... @_dispatchable -def waxman_graph(n, beta: float = 0.4, alpha: float = 0.1, L=None, domain=(0, 0, 1, 1), metric=None, seed=None): ... +def waxman_graph( + n, beta: float = 0.4, alpha: float = 0.1, L=None, domain=(0, 0, 1, 1), metric=None, seed=None +) -> Graph[Incomplete]: ... # docstring marks p as int, but it still works with floats. So I think it's better for consistency @_dispatchable diff --git a/stubs/networkx/networkx/generators/internet_as_graphs.pyi b/stubs/networkx/networkx/generators/internet_as_graphs.pyi index a6bd04e98414..05932bf9e32d 100644 --- a/stubs/networkx/networkx/generators/internet_as_graphs.pyi +++ b/stubs/networkx/networkx/generators/internet_as_graphs.pyi @@ -31,8 +31,8 @@ class AS_graph_generator: def choose_node_pref_attach(self, node_list): ... def add_customer(self, i, j) -> None: ... def add_node(self, i, kind, reg2prob, avg_deg, t_edge_prob): ... - def add_m_peering_link(self, m, to_kind): ... - def add_cp_peering_link(self, cp, to_kind): ... + def add_m_peering_link(self, m, to_kind) -> bool: ... + def add_cp_peering_link(self, cp, to_kind) -> bool: ... regions: Incomplete def graph_regions(self, rn) -> None: ... def add_peering_links(self, from_kind, to_kind) -> None: ... diff --git a/stubs/networkx/networkx/generators/joint_degree_seq.pyi b/stubs/networkx/networkx/generators/joint_degree_seq.pyi index 2407905149d3..2814dd544138 100644 --- a/stubs/networkx/networkx/generators/joint_degree_seq.pyi +++ b/stubs/networkx/networkx/generators/joint_degree_seq.pyi @@ -1,14 +1,19 @@ +from _typeshed import Incomplete from collections.abc import Mapping, Sequence from networkx.utils.backends import _dispatchable from numpy.random import RandomState +from ..classes.graph import Graph + __all__ = ["is_valid_joint_degree", "is_valid_directed_joint_degree", "joint_degree_graph", "directed_joint_degree_graph"] @_dispatchable def is_valid_joint_degree(joint_degrees: Mapping[int, Mapping[int, int]]) -> bool: ... @_dispatchable -def joint_degree_graph(joint_degrees: Mapping[int, Mapping[int, int]], seed: int | RandomState | None = None): ... +def joint_degree_graph( + joint_degrees: Mapping[int, Mapping[int, int]], seed: int | RandomState | None = None +) -> Graph[Incomplete]: ... @_dispatchable def is_valid_directed_joint_degree( in_degrees: Sequence[int], out_degrees: Sequence[int], nkk: Mapping[int, Mapping[int, int]] @@ -19,4 +24,4 @@ def directed_joint_degree_graph( out_degrees: Sequence[int], nkk: Mapping[int, Mapping[int, int]], seed: int | RandomState | None = None, -): ... +) -> Graph[Incomplete]: ... diff --git a/stubs/networkx/networkx/generators/random_graphs.pyi b/stubs/networkx/networkx/generators/random_graphs.pyi index 958a5028e064..10a3b070fead 100644 --- a/stubs/networkx/networkx/generators/random_graphs.pyi +++ b/stubs/networkx/networkx/generators/random_graphs.pyi @@ -1,5 +1,9 @@ +from _typeshed import Incomplete + from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = [ "fast_gnp_random_graph", "gnp_random_graph", @@ -43,11 +47,11 @@ def connected_watts_strogatz_graph(n, k, p, tries: int = 100, seed=None): ... @_dispatchable def random_regular_graph(d, n, seed=None): ... @_dispatchable -def barabasi_albert_graph(n, m, seed=None, initial_graph=None): ... +def barabasi_albert_graph(n, m, seed=None, initial_graph=None) -> Graph[Incomplete]: ... @_dispatchable -def dual_barabasi_albert_graph(n, m1, m2, p, seed=None, initial_graph=None): ... +def dual_barabasi_albert_graph(n, m1, m2, p, seed=None, initial_graph=None) -> Graph[Incomplete]: ... @_dispatchable -def extended_barabasi_albert_graph(n, m, p, q, seed=None): ... +def extended_barabasi_albert_graph(n, m, p, q, seed=None) -> Graph[Incomplete]: ... @_dispatchable def powerlaw_cluster_graph(n, m, p, seed=None): ... @_dispatchable diff --git a/stubs/networkx/networkx/generators/spectral_graph_forge.pyi b/stubs/networkx/networkx/generators/spectral_graph_forge.pyi index a4af66065a7b..f96534191207 100644 --- a/stubs/networkx/networkx/generators/spectral_graph_forge.pyi +++ b/stubs/networkx/networkx/generators/spectral_graph_forge.pyi @@ -1,6 +1,10 @@ +from _typeshed import Incomplete + from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["spectral_graph_forge"] @_dispatchable -def spectral_graph_forge(G, alpha, transformation: str = "identity", seed=None): ... +def spectral_graph_forge(G, alpha, transformation: str = "identity", seed=None) -> Graph[Incomplete]: ... diff --git a/stubs/networkx/networkx/generators/trees.pyi b/stubs/networkx/networkx/generators/trees.pyi index 8652af12a6a7..9ebd32f0d81f 100644 --- a/stubs/networkx/networkx/generators/trees.pyi +++ b/stubs/networkx/networkx/generators/trees.pyi @@ -2,6 +2,8 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable +from ..classes.digraph import DiGraph + __all__ = [ "prefix_tree", "prefix_tree_recursive", @@ -14,9 +16,9 @@ __all__ = [ ] @_dispatchable -def prefix_tree(paths): ... +def prefix_tree(paths) -> DiGraph[Incomplete]: ... @_dispatchable -def prefix_tree_recursive(paths): ... +def prefix_tree_recursive(paths) -> DiGraph[Incomplete]: ... @_dispatchable def random_labeled_tree(n, *, seed=None): ... @_dispatchable diff --git a/stubs/networkx/networkx/generators/triads.pyi b/stubs/networkx/networkx/generators/triads.pyi index 1e536b89355c..4e85d0677afa 100644 --- a/stubs/networkx/networkx/generators/triads.pyi +++ b/stubs/networkx/networkx/generators/triads.pyi @@ -1,5 +1,7 @@ +from _typeshed import Incomplete from typing import Final +from networkx import DiGraph from networkx.utils.backends import _dispatchable __all__ = ["triad_graph"] @@ -7,4 +9,4 @@ __all__ = ["triad_graph"] TRIAD_EDGES: Final[dict[str, list[str]]] @_dispatchable -def triad_graph(triad_name): ... +def triad_graph(triad_name) -> DiGraph[Incomplete]: ... diff --git a/stubs/networkx/networkx/readwrite/adjlist.pyi b/stubs/networkx/networkx/readwrite/adjlist.pyi index 2f482e88bef1..db9cc2c44455 100644 --- a/stubs/networkx/networkx/readwrite/adjlist.pyi +++ b/stubs/networkx/networkx/readwrite/adjlist.pyi @@ -1,11 +1,10 @@ -from _typeshed import Incomplete from collections.abc import Generator from networkx.utils.backends import _dispatchable __all__ = ["generate_adjlist", "write_adjlist", "parse_adjlist", "read_adjlist"] -def generate_adjlist(G, delimiter: str = " ") -> Generator[Incomplete, None, None]: ... +def generate_adjlist(G, delimiter: str = " ") -> Generator[str, None, None]: ... def write_adjlist(G, path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8") -> None: ... @_dispatchable def parse_adjlist(lines, comments: str = "#", delimiter=None, create_using=None, nodetype=None): ... diff --git a/stubs/networkx/networkx/readwrite/graph6.pyi b/stubs/networkx/networkx/readwrite/graph6.pyi index 3dd12da9f429..5e743d598191 100644 --- a/stubs/networkx/networkx/readwrite/graph6.pyi +++ b/stubs/networkx/networkx/readwrite/graph6.pyi @@ -7,7 +7,7 @@ from networkx.utils.backends import _dispatchable __all__ = ["from_graph6_bytes", "read_graph6", "to_graph6_bytes", "write_graph6"] @_dispatchable -def from_graph6_bytes(bytes_in): ... +def from_graph6_bytes(bytes_in) -> Graph[Incomplete]: ... def to_graph6_bytes(G, nodes=None, header: bool = True): ... @_dispatchable def read_graph6(path): ... diff --git a/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi b/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi index f1745015fad3..28cd6225a41b 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi @@ -1,8 +1,10 @@ +from typing import Any + from networkx.utils.backends import _dispatchable __all__ = ["adjacency_data", "adjacency_graph"] -@_dispatchable -def adjacency_data(G, attrs={"id": "id", "key": "key"}): ... +# Any: Complex type union +def adjacency_data(G, attrs={"id": "id", "key": "key"}) -> dict[str, Any]: ... @_dispatchable def adjacency_graph(data, directed: bool = False, multigraph: bool = True, attrs={"id": "id", "key": "key"}): ... diff --git a/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi b/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi index 6b5155209711..663a83c01e33 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi @@ -1,7 +1,10 @@ +from typing import Any + from networkx.utils.backends import _dispatchable __all__ = ["cytoscape_data", "cytoscape_graph"] -def cytoscape_data(G, name: str = "name", ident: str = "id"): ... +# Any: Complex type union +def cytoscape_data(G, name: str = "name", ident: str = "id") -> dict[str, Any]: ... @_dispatchable def cytoscape_graph(data, name: str = "name", ident: str = "id"): ... diff --git a/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi b/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi index a75f916bb626..a27130c8f3de 100644 --- a/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi +++ b/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi @@ -1,12 +1,11 @@ -from _typeshed import Incomplete from collections.abc import Generator from networkx.utils.backends import _dispatchable __all__ = ["generate_multiline_adjlist", "write_multiline_adjlist", "parse_multiline_adjlist", "read_multiline_adjlist"] -def generate_multiline_adjlist(G, delimiter: str = " ") -> Generator[Incomplete, None, None]: ... -def write_multiline_adjlist(G, path, delimiter: str = " ", comments: str = "#", encoding: str = "utf-8") -> None: ... +def generate_multiline_adjlist(G, delimiter: str = " ") -> Generator[str, None, None]: ... +def write_multiline_adjlist(G, path, delimiter=" ", comments="#", encoding="utf-8") -> None: ... @_dispatchable def parse_multiline_adjlist(lines, comments: str = "#", delimiter=None, create_using=None, nodetype=None, edgetype=None): ... @_dispatchable diff --git a/stubs/networkx/networkx/readwrite/p2g.pyi b/stubs/networkx/networkx/readwrite/p2g.pyi index f9da22dd2611..ba1c1b2def09 100644 --- a/stubs/networkx/networkx/readwrite/p2g.pyi +++ b/stubs/networkx/networkx/readwrite/p2g.pyi @@ -1,7 +1,11 @@ +from _typeshed import Incomplete + from networkx.utils.backends import _dispatchable +from ..classes.multidigraph import MultiDiGraph + def write_p2g(G, path, encoding: str = "utf-8") -> None: ... @_dispatchable -def read_p2g(path, encoding: str = "utf-8"): ... +def read_p2g(path, encoding: str = "utf-8") -> MultiDiGraph[Incomplete]: ... @_dispatchable -def parse_p2g(lines): ... +def parse_p2g(lines) -> MultiDiGraph[Incomplete]: ... diff --git a/stubs/networkx/networkx/readwrite/sparse6.pyi b/stubs/networkx/networkx/readwrite/sparse6.pyi index b1e6e56a50d3..2e2b96fea664 100644 --- a/stubs/networkx/networkx/readwrite/sparse6.pyi +++ b/stubs/networkx/networkx/readwrite/sparse6.pyi @@ -1,9 +1,13 @@ +from _typeshed import Incomplete + from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["from_sparse6_bytes", "read_sparse6", "to_sparse6_bytes", "write_sparse6"] @_dispatchable -def from_sparse6_bytes(string): ... +def from_sparse6_bytes(string) -> Graph[Incomplete]: ... def to_sparse6_bytes(G, nodes=None, header: bool = True): ... @_dispatchable def read_sparse6(path): ... diff --git a/stubs/networkx/networkx/utils/decorators.pyi b/stubs/networkx/networkx/utils/decorators.pyi index af8b401c8600..c12cc5421171 100644 --- a/stubs/networkx/networkx/utils/decorators.pyi +++ b/stubs/networkx/networkx/utils/decorators.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Callable from typing import NamedTuple __all__ = ["not_implemented_for", "open_file", "nodes_or_number", "np_random_state", "py_random_state", "argmap"] @@ -11,8 +12,8 @@ def py_random_state(random_state_argument): ... class argmap: def __init__(self, func, *args, try_finally: bool = False) -> None: ... - def __call__(self, f): ... - def compile(self, f): ... + def __call__(self, f) -> Callable[..., Incomplete]: ... + def compile(self, f) -> Callable[..., Incomplete]: ... def assemble(self, f): ... @classmethod def signature(cls, f): ... diff --git a/stubs/networkx/networkx/utils/heaps.pyi b/stubs/networkx/networkx/utils/heaps.pyi index 95862f2da880..92b3832cfa4e 100644 --- a/stubs/networkx/networkx/utils/heaps.pyi +++ b/stubs/networkx/networkx/utils/heaps.pyi @@ -9,10 +9,10 @@ class MinHeap: def __init__(self, key, value) -> None: ... def __init__(self) -> None: ... - def min(self) -> None: ... - def pop(self) -> None: ... - def get(self, key, default=None) -> None: ... - def insert(self, key, value, allow_increase: bool = False) -> None: ... + def min(self) -> tuple[Incomplete, Incomplete]: ... + def pop(self) -> tuple[Incomplete, Incomplete]: ... + def get(self, key, default=None): ... + def insert(self, key, value, allow_increase: bool = False) -> bool: ... def __nonzero__(self): ... def __bool__(self) -> bool: ... def __len__(self) -> int: ... @@ -27,14 +27,14 @@ class PairingHeap(MinHeap): def __init__(self, key, value) -> None: ... def __init__(self) -> None: ... - def min(self): ... - def pop(self): ... + def min(self) -> tuple[Incomplete, Incomplete]: ... + def pop(self) -> tuple[Incomplete, Incomplete]: ... def get(self, key, default=None): ... - def insert(self, key, value, allow_increase: bool = False): ... + def insert(self, key, value, allow_increase: bool = False) -> bool: ... class BinaryHeap(MinHeap): def __init__(self) -> None: ... - def min(self): ... - def pop(self): ... + def min(self) -> tuple[Incomplete, Incomplete]: ... + def pop(self) -> tuple[Incomplete, Incomplete]: ... def get(self, key, default=None): ... - def insert(self, key, value, allow_increase: bool = False): ... + def insert(self, key, value, allow_increase: bool = False) -> bool: ... diff --git a/stubs/networkx/networkx/utils/misc.pyi b/stubs/networkx/networkx/utils/misc.pyi index 62fb3c6b3b94..0df8f1814066 100644 --- a/stubs/networkx/networkx/utils/misc.pyi +++ b/stubs/networkx/networkx/utils/misc.pyi @@ -52,7 +52,7 @@ class PythonRandomInterface: def paretovariate(self, shape): ... def create_py_random_state(random_state: _RandomState = None): ... -def nodes_equal(nodes1, nodes2): ... -def edges_equal(edges1, edges2): ... -def graphs_equal(graph1, graph2): ... +def nodes_equal(nodes1, nodes2) -> bool: ... +def edges_equal(edges1, edges2) -> bool: ... +def graphs_equal(graph1, graph2) -> bool: ... def _clear_cache(G) -> None: ... diff --git a/stubs/networkx/networkx/utils/random_sequence.pyi b/stubs/networkx/networkx/utils/random_sequence.pyi index 101004bba6ba..e2985019248d 100644 --- a/stubs/networkx/networkx/utils/random_sequence.pyi +++ b/stubs/networkx/networkx/utils/random_sequence.pyi @@ -8,7 +8,7 @@ __all__ = [ ] def powerlaw_sequence(n, exponent: float = 2.0, seed=None): ... -def zipf_rv(alpha, xmin: int = 1, seed=None): ... +def zipf_rv(alpha, xmin: int = 1, seed=None) -> int: ... def cumulative_distribution(distribution): ... def discrete_sequence(n, distribution=None, cdistribution=None, seed=None): ... def random_weighted_sample(mapping, k, seed=None): ...