diff --git a/stubs/networkx/@tests/stubtest_allowlist.txt b/stubs/networkx/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000..263c21909 --- /dev/null +++ b/stubs/networkx/@tests/stubtest_allowlist.txt @@ -0,0 +1,23 @@ +# overloaded class-decorators are not properly supported in type-checkers: +# - mypy: https://github.com/python/mypy/issues/16840 +# - pyright: https://github.com/microsoft/pyright/issues/7167 +networkx\.(algorithms\.)?(boundary\.)?edge_boundary +networkx\.(algorithms\.)?(bridges\.)?local_bridges +networkx\.(algorithms\.)?(clique\.)?node_clique_number +networkx\.(algorithms\.)?(shortest_paths\.)?(generic\.)?shortest_path +networkx\.(convert_matrix\.)?from_numpy_array +networkx\.(convert_matrix\.)?from_pandas_adjacency +networkx\.(convert_matrix\.)?from_pandas_edgelist +networkx\.(generators\.)?(random_clustered\.)?random_clustered_graph +networkx\.(relabel\.)?relabel_nodes + +# Stubtest doesn't understand aliases of class-decorated methods (possibly https://github.com/python/mypy/issues/6700 ) +networkx\.(algorithms\.)?(centrality\.)?(current_flow_closeness\.)?information_centrality +networkx\.(generators\.)?(random_graphs\.)?binomial_graph +networkx\.(generators\.)?(random_graphs\.)?erdos_renyi_graph + +# Stubtest says: "runtime argument "backend" has a default value of type None, which is +# incompatible with stub argument type builtins.str. This is often caused by overloads +# failing to account for explicitly passing in the default value." +# Which is true, but would require some way of concatenating `backend` to ParamSpec.kwargs +networkx\.(utils\.backends\.)?_dispatch\.__call__ diff --git a/stubs/networkx/@tests/test_cases/check_dispatch_decorator.py b/stubs/networkx/@tests/test_cases/check_dispatch_decorator.py new file mode 100644 index 000000000..a408396ec --- /dev/null +++ b/stubs/networkx/@tests/test_cases/check_dispatch_decorator.py @@ -0,0 +1,23 @@ +from typing_extensions import assert_type + +from networkx.utils.backends import _dispatch + + +@_dispatch +def some_method(int_p: int, str_p: str) -> float: + return 0.0 + + +# Wrong param / order +some_method("", 0) # type: ignore +# backend is kw-only +some_method(0, "", None) # type: ignore +# No backend means no **backend_kwargs allowed +some_method(0, "", backend_specific_kwarg="") # type: ignore +some_method(0, "", backend=None, backend_specific_kwarg="") # type: ignore + +# Correct usage +assert_type(some_method(0, ""), float) +# type system doesn't allow this yet (see comment in networkx/utils/backends.pyi) +# assert_type(some_method(0, "", backend=None), float) +assert_type(some_method(0, "", backend="custom backend", backend_specific_kwarg=""), float) diff --git a/stubs/networkx/METADATA.toml b/stubs/networkx/METADATA.toml index 270518a11..d572cfc2e 100644 --- a/stubs/networkx/METADATA.toml +++ b/stubs/networkx/METADATA.toml @@ -1,4 +1,4 @@ -version = "3.1" +version = "3.2.1" upstream_repository = "https://github.com/networkx/networkx" requires = ["numpy"] partial_stub = true diff --git a/stubs/networkx/networkx/__init__.pyi b/stubs/networkx/networkx/__init__.pyi index 2884bfc1a..86bd7edf3 100644 --- a/stubs/networkx/networkx/__init__.pyi +++ b/stubs/networkx/networkx/__init__.pyi @@ -6,9 +6,11 @@ from networkx.convert_matrix import * from networkx.drawing import * from networkx.exception import * from networkx.generators import * +from networkx.lazy_imports import _lazy_import as _lazy_import from networkx.linalg import * from networkx.readwrite import * from networkx.relabel import * +from networkx.utils.backends import _dispatch as _dispatch from . import ( algorithms as algorithms, diff --git a/stubs/networkx/networkx/algorithms/approximation/clique.pyi b/stubs/networkx/networkx/algorithms/approximation/clique.pyi index e917e7c36..1ea7793c4 100644 --- a/stubs/networkx/networkx/algorithms/approximation/clique.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/clique.pyi @@ -1,4 +1,10 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def maximum_independent_set(G): ... +@_dispatch def max_clique(G): ... +@_dispatch def clique_removal(G): ... +@_dispatch def large_clique_size(G): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi b/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi index 6ccdd17f5..eb18de118 100644 --- a/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def average_clustering(G, trials: int = 1000, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi b/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi index 2884da3b9..886607817 100644 --- a/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi @@ -1,5 +1,10 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def local_node_connectivity(G, source, target, cutoff: Incomplete | None = None): ... +@_dispatch def node_connectivity(G, s: Incomplete | None = None, t: Incomplete | None = None): ... +@_dispatch def all_pairs_node_connectivity(G, nbunch: Incomplete | None = None, cutoff: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/distance_measures.pyi b/stubs/networkx/networkx/algorithms/approximation/distance_measures.pyi index 407a169f0..136d0b8d1 100644 --- a/stubs/networkx/networkx/algorithms/approximation/distance_measures.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/distance_measures.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def diameter(G, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi b/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi index e14406571..d7ecd98b5 100644 --- a/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi @@ -1,4 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def min_weighted_dominating_set(G, weight: Incomplete | None = None): ... +@_dispatch def min_edge_dominating_set(G): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi index 2a0bd9b1d..7ede5c764 100644 --- a/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi @@ -1 +1,4 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def k_components(G, min_density: float = 0.95): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/matching.pyi b/stubs/networkx/networkx/algorithms/approximation/matching.pyi index 018588021..d4c8b8a8b 100644 --- a/stubs/networkx/networkx/algorithms/approximation/matching.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/matching.pyi @@ -1 +1,4 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def min_maximal_matching(G): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi b/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi index 170f72853..b3a63ccca 100644 --- a/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi @@ -1,4 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def randomized_partitioning(G, seed: Incomplete | None = None, p: float = 0.5, weight: Incomplete | None = None): ... +@_dispatch def one_exchange(G, initial_cut: Incomplete | None = None, seed: Incomplete | None = None, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/ramsey.pyi b/stubs/networkx/networkx/algorithms/approximation/ramsey.pyi index b0dfc1cf3..e94877bea 100644 --- a/stubs/networkx/networkx/algorithms/approximation/ramsey.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/ramsey.pyi @@ -1 +1,4 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def ramsey_R2(G): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi b/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi index 572c0bf5b..8ade9c0e5 100644 --- a/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi @@ -1,4 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def metric_closure(G, weight: str = "weight"): ... +@_dispatch def steiner_tree(G, terminal_nodes, weight: str = "weight", method: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi index 1959f98f5..9ceb4349d 100644 --- a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi @@ -1,11 +1,18 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def christofides(G, weight: str = "weight", tree: Incomplete | None = None): ... +@_dispatch def traveling_salesman_problem( G, weight: str = "weight", nodes: Incomplete | None = None, cycle: bool = True, method: Incomplete | None = None ): ... +@_dispatch def asadpour_atsp(G, weight: str = "weight", seed: Incomplete | None = None, source: Incomplete | None = None): ... +@_dispatch def greedy_tsp(G, weight: str = "weight", source: Incomplete | None = None): ... +@_dispatch def simulated_annealing_tsp( G, init_cycle, @@ -19,6 +26,7 @@ def simulated_annealing_tsp( alpha: float = 0.01, seed: Incomplete | None = None, ): ... +@_dispatch def threshold_accepting_tsp( G, init_cycle, diff --git a/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi index 637f5740b..689661866 100644 --- a/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi @@ -1,8 +1,12 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + __all__ = ["treewidth_min_degree", "treewidth_min_fill_in"] +@_dispatch def treewidth_min_degree(G): ... +@_dispatch def treewidth_min_fill_in(G): ... class MinDegreeHeuristic: diff --git a/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi b/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi index 38560009c..1e903f206 100644 --- a/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def min_weighted_vertex_cover(G, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi b/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi index e0f8cb994..f317998a9 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def average_degree_connectivity( G, source: str = "in+out", target: str = "in+out", nodes: Incomplete | None = None, weight: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi index 300160c7e..8904cc156 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi @@ -1,10 +1,16 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def degree_assortativity_coefficient( G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None ): ... +@_dispatch def degree_pearson_correlation_coefficient( G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None ): ... +@_dispatch def attribute_assortativity_coefficient(G, attribute, nodes: Incomplete | None = None): ... +@_dispatch def numeric_assortativity_coefficient(G, attribute, nodes: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi index 0801a6719..95402642c 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi @@ -1,12 +1,18 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def attribute_mixing_dict(G, attribute, nodes: Incomplete | None = None, normalized: bool = False): ... +@_dispatch def attribute_mixing_matrix( G, attribute, nodes: Incomplete | None = None, mapping: Incomplete | None = None, normalized: bool = True ): ... +@_dispatch def degree_mixing_dict( G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None, normalized: bool = False ): ... +@_dispatch def degree_mixing_matrix( G, x: str = "out", @@ -16,4 +22,5 @@ def degree_mixing_matrix( normalized: bool = True, mapping: Incomplete | None = None, ): ... +@_dispatch def mixing_dict(xy, normalized: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi b/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi index 42649c6f6..7f0e945ff 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def average_neighbor_degree( G, source: str = "out", target: str = "out", nodes: Incomplete | None = None, weight: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi b/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi index dc834ba81..d73234043 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi @@ -1,7 +1,11 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def node_attribute_xy(G, attribute, nodes: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... +@_dispatch def node_degree_xy( G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None ) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/asteroidal.pyi b/stubs/networkx/networkx/algorithms/asteroidal.pyi index 01d935ad9..07fa9c4a9 100644 --- a/stubs/networkx/networkx/algorithms/asteroidal.pyi +++ b/stubs/networkx/networkx/algorithms/asteroidal.pyi @@ -1,2 +1,6 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def find_asteroidal_triple(G): ... +@_dispatch def is_at_free(G): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/basic.pyi b/stubs/networkx/networkx/algorithms/bipartite/basic.pyi index 6eba8bda5..cf30841b6 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/basic.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/basic.pyi @@ -1,8 +1,16 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def color(G): ... +@_dispatch def is_bipartite(G): ... +@_dispatch def is_bipartite_node_set(G, nodes): ... +@_dispatch def sets(G, top_nodes: Incomplete | None = None): ... +@_dispatch def density(B, nodes): ... +@_dispatch def degrees(B, nodes, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi b/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi index ccb668e79..900809020 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi @@ -1,3 +1,8 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def degree_centrality(G, nodes): ... +@_dispatch def betweenness_centrality(G, nodes): ... +@_dispatch def closeness_centrality(G, nodes, normalized: bool = True): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi b/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi index eb4427f50..e8f427123 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi @@ -1,8 +1,13 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def latapy_clustering(G, nodes: Incomplete | None = None, mode: str = "dot"): ... clustering = latapy_clustering +@_dispatch def average_clustering(G, nodes: Incomplete | None = None, mode: str = "dot"): ... +@_dispatch def robins_alexander_clustering(G): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/covering.pyi b/stubs/networkx/networkx/algorithms/bipartite/covering.pyi index a27c5abfd..1c07f6ee0 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/covering.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/covering.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def min_edge_cover(G, matching_algorithm: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi b/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi index 9251989a2..04d79f515 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi @@ -1,8 +1,13 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def write_edgelist(G, path, comments: str = "#", delimiter: str = " ", data: bool = True, encoding: str = "utf-8") -> None: ... +@_dispatch def generate_edgelist(G, delimiter: str = " ", data: bool = True) -> Generator[Incomplete, None, None]: ... +@_dispatch def parse_edgelist( lines, comments: str = "#", @@ -11,6 +16,7 @@ def parse_edgelist( nodetype: Incomplete | None = None, data: bool = True, ): ... +@_dispatch def read_edgelist( path, comments: str = "#", diff --git a/stubs/networkx/networkx/algorithms/bipartite/generators.pyi b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi index 7c36a00a8..d422ac358 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/generators.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi @@ -1,10 +1,20 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def complete_bipartite_graph(n1, n2, create_using: Incomplete | None = None): ... +@_dispatch def configuration_model(aseq, bseq, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... +@_dispatch def havel_hakimi_graph(aseq, bseq, create_using: Incomplete | None = None): ... +@_dispatch def reverse_havel_hakimi_graph(aseq, bseq, create_using: Incomplete | None = None): ... +@_dispatch def alternating_havel_hakimi_graph(aseq, bseq, create_using: Incomplete | None = None): ... +@_dispatch def preferential_attachment_graph(aseq, p, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... +@_dispatch def random_graph(n, m, p, seed: Incomplete | None = None, directed: bool = False): ... +@_dispatch def gnmk_random_graph(n, m, k, seed: Incomplete | None = None, directed: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi index de89ed68f..b6a285265 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi @@ -1,9 +1,15 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def hopcroft_karp_matching(G, top_nodes: Incomplete | None = None): ... +@_dispatch def eppstein_matching(G, top_nodes: Incomplete | None = None): ... +@_dispatch def to_vertex_cover(G, matching, top_nodes: Incomplete | None = None): ... maximum_matching = hopcroft_karp_matching +@_dispatch def minimum_weight_full_matching(G, top_nodes: Incomplete | None = None, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi index 79f344772..e7d8e399f 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def biadjacency_matrix( G, row_order, @@ -8,4 +11,5 @@ def biadjacency_matrix( weight: str = "weight", format: str = "csr", ): ... +@_dispatch def from_biadjacency_matrix(A, create_using: Incomplete | None = None, edge_attribute: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/projection.pyi b/stubs/networkx/networkx/algorithms/bipartite/projection.pyi index ad7e73bb0..73f12dc57 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/projection.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/projection.pyi @@ -1,7 +1,14 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def projected_graph(B, nodes, multigraph: bool = False): ... +@_dispatch def weighted_projected_graph(B, nodes, ratio: bool = False): ... +@_dispatch def collaboration_weighted_projected_graph(B, nodes): ... +@_dispatch def overlap_weighted_projected_graph(B, nodes, jaccard: bool = True): ... +@_dispatch def generic_weighted_projected_graph(B, nodes, weight_function: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi b/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi index 43d54ecb1..5501fd2d8 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def node_redundancy(G, nodes: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi b/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi index 3ae4c3180..435a1795c 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def spectral_bipartivity(G, nodes: Incomplete | None = None, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/boundary.pyi b/stubs/networkx/networkx/algorithms/boundary.pyi index 725469948..51c8c9031 100644 --- a/stubs/networkx/networkx/algorithms/boundary.pyi +++ b/stubs/networkx/networkx/algorithms/boundary.pyi @@ -3,6 +3,7 @@ from collections.abc import Generator, Iterable from typing import Literal, TypeVar, overload from networkx.classes.graph import Graph, _Node +from networkx.utils.backends import _dispatch _U = TypeVar("_U") @@ -110,4 +111,5 @@ def edge_boundary( keys: Literal[True], default: _U | None = None, ) -> Generator[tuple[_Node, _Node, int, dict[str, _U]], None, None]: ... +@_dispatch def node_boundary(G: Graph[_Node], nbunch1: Iterable[_Node], nbunch2: Iterable[_Node] | None = None) -> set[_Node]: ... diff --git a/stubs/networkx/networkx/algorithms/bridges.pyi b/stubs/networkx/networkx/algorithms/bridges.pyi index af357c046..2d94a35f4 100644 --- a/stubs/networkx/networkx/algorithms/bridges.pyi +++ b/stubs/networkx/networkx/algorithms/bridges.pyi @@ -3,8 +3,11 @@ from collections.abc import Callable, Generator from typing import Literal, overload from networkx.classes.graph import Graph, _Node +from networkx.utils.backends import _dispatch +@_dispatch def bridges(G: Graph[_Node], root: _Node | None = None) -> Generator[_Node, None, None]: ... +@_dispatch def has_bridges(G: Graph[_Node], root: Incomplete | None = None) -> bool: ... @overload def local_bridges( diff --git a/stubs/networkx/networkx/algorithms/centrality/betweenness.pyi b/stubs/networkx/networkx/algorithms/centrality/betweenness.pyi index 38cc77a1a..5d638ff22 100644 --- a/stubs/networkx/networkx/algorithms/centrality/betweenness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/betweenness.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def betweenness_centrality( G, k: Incomplete | None = None, @@ -8,6 +11,7 @@ def betweenness_centrality( endpoints: bool = False, seed: Incomplete | None = None, ): ... +@_dispatch def edge_betweenness_centrality( G, k: Incomplete | None = None, normalized: bool = True, weight: Incomplete | None = None, seed: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi b/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi index a5cdba3b0..2c9d29473 100644 --- a/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi @@ -1,4 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def betweenness_centrality_subset(G, sources, targets, normalized: bool = False, weight: Incomplete | None = None): ... +@_dispatch def edge_betweenness_centrality_subset(G, sources, targets, normalized: bool = False, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi index da0e5ab87..cc7ca02da 100644 --- a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi @@ -1,6 +1,10 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def closeness_centrality(G, u: Incomplete | None = None, distance: Incomplete | None = None, wf_improved: bool = True): ... +@_dispatch def incremental_closeness_centrality( G, edge, prev_cc: Incomplete | None = None, insertion: bool = True, wf_improved: bool = True ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi index c6f6bea33..ec6506d56 100644 --- a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def approximate_current_flow_betweenness_centrality( G, normalized: bool = True, @@ -10,9 +13,11 @@ def approximate_current_flow_betweenness_centrality( kmax: int = 10000, seed: Incomplete | None = None, ): ... +@_dispatch def current_flow_betweenness_centrality( G, normalized: bool = True, weight: Incomplete | None = None, dtype=..., solver: str = "full" ): ... +@_dispatch def edge_current_flow_betweenness_centrality( G, normalized: bool = True, weight: Incomplete | None = None, dtype=..., solver: str = "full" ): ... 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 6d760a501..65eaa7765 100644 --- a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi @@ -1,8 +1,12 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def current_flow_betweenness_centrality_subset( G, sources, targets, normalized: bool = True, weight: Incomplete | None = None, dtype=..., solver: str = "lu" ): ... +@_dispatch def edge_current_flow_betweenness_centrality_subset( G, sources, targets, normalized: bool = True, weight: Incomplete | None = None, dtype=..., solver: str = "lu" ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi b/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi index 202594de0..0269117b2 100644 --- a/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def current_flow_closeness_centrality(G, weight: Incomplete | None = None, dtype=..., solver: str = "lu"): ... information_centrality = current_flow_closeness_centrality diff --git a/stubs/networkx/networkx/algorithms/centrality/degree_alg.pyi b/stubs/networkx/networkx/algorithms/centrality/degree_alg.pyi index 72f9f9bd6..19fa9b606 100644 --- a/stubs/networkx/networkx/algorithms/centrality/degree_alg.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/degree_alg.pyi @@ -1,3 +1,8 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def degree_centrality(G): ... +@_dispatch def in_degree_centrality(G): ... +@_dispatch def out_degree_centrality(G): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/dispersion.pyi b/stubs/networkx/networkx/algorithms/centrality/dispersion.pyi index 8b19af6fe..440a0f3c5 100644 --- a/stubs/networkx/networkx/algorithms/centrality/dispersion.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/dispersion.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def dispersion( G, u: Incomplete | None = None, diff --git a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi index 4043738aa..f74d25fb6 100644 --- a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi @@ -1,6 +1,10 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def eigenvector_centrality( G, max_iter: int = 100, tol: float = 1e-06, nstart: Incomplete | None = None, weight: Incomplete | None = None ): ... +@_dispatch def eigenvector_centrality_numpy(G, weight: Incomplete | None = None, max_iter: int = 50, tol: float = 0): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi b/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi index d137dab3d..f1e49b178 100644 --- a/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi @@ -1,6 +1,9 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def flow_matrix_row(G, weight: Incomplete | None = None, dtype=..., solver: str = "lu") -> Generator[Incomplete, None, None]: ... class InverseLaplacian: diff --git a/stubs/networkx/networkx/algorithms/centrality/group.pyi b/stubs/networkx/networkx/algorithms/centrality/group.pyi index 0b446f548..8431e0954 100644 --- a/stubs/networkx/networkx/algorithms/centrality/group.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/group.pyi @@ -1,6 +1,10 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def group_betweenness_centrality(G, C, normalized: bool = True, weight: Incomplete | None = None, endpoints: bool = False): ... +@_dispatch def prominent_group( G, k, @@ -10,7 +14,11 @@ def prominent_group( normalized: bool = True, greedy: bool = False, ): ... +@_dispatch def group_closeness_centrality(G, S, weight: Incomplete | None = None): ... +@_dispatch def group_degree_centrality(G, S): ... +@_dispatch def group_in_degree_centrality(G, S): ... +@_dispatch def group_out_degree_centrality(G, S): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi b/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi index 3f518c33c..22b1b8458 100644 --- a/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def harmonic_centrality( G, nbunch: Incomplete | None = None, distance: Incomplete | None = None, sources: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/katz.pyi b/stubs/networkx/networkx/algorithms/centrality/katz.pyi index a55741328..7ad4c1ed9 100644 --- a/stubs/networkx/networkx/algorithms/centrality/katz.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/katz.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def katz_centrality( G, alpha: float = 0.1, @@ -10,6 +13,7 @@ def katz_centrality( normalized: bool = True, weight: Incomplete | None = None, ): ... +@_dispatch def katz_centrality_numpy( G, alpha: float = 0.1, beta: float = 1.0, normalized: bool = True, weight: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi b/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi index 3095884c7..1d29b3c99 100644 --- a/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def laplacian_centrality( G, normalized: bool = True, diff --git a/stubs/networkx/networkx/algorithms/centrality/load.pyi b/stubs/networkx/networkx/algorithms/centrality/load.pyi index a4ed84f5e..66508d057 100644 --- a/stubs/networkx/networkx/algorithms/centrality/load.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/load.pyi @@ -1,11 +1,15 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + __all__ = ["load_centrality", "edge_load_centrality"] +@_dispatch def newman_betweenness_centrality( G, v: Incomplete | None = None, cutoff: Incomplete | None = None, normalized: bool = True, weight: Incomplete | None = None ): ... load_centrality = newman_betweenness_centrality +@_dispatch def edge_load_centrality(G, cutoff: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/percolation.pyi b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi index 5cccd57e1..42431fed2 100644 --- a/stubs/networkx/networkx/algorithms/centrality/percolation.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def percolation_centrality( G, attribute: str = "percolation", states: Incomplete | None = None, weight: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/reaching.pyi b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi index 6dca49336..69d2017c1 100644 --- a/stubs/networkx/networkx/algorithms/centrality/reaching.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi @@ -1,6 +1,10 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def global_reaching_centrality(G, weight: Incomplete | None = None, normalized: bool = True): ... +@_dispatch def local_reaching_centrality( G, v, paths: Incomplete | None = None, weight: Incomplete | None = None, normalized: bool = True ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/second_order.pyi b/stubs/networkx/networkx/algorithms/centrality/second_order.pyi index 6197d1011..3bbf8e2e6 100644 --- a/stubs/networkx/networkx/algorithms/centrality/second_order.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/second_order.pyi @@ -1 +1,4 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def second_order_centrality(G): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi b/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi index 302823625..e7969b808 100644 --- a/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi @@ -1,4 +1,10 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def subgraph_centrality_exp(G): ... +@_dispatch def subgraph_centrality(G): ... +@_dispatch def communicability_betweenness_centrality(G): ... +@_dispatch def estrada_index(G): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/trophic.pyi b/stubs/networkx/networkx/algorithms/centrality/trophic.pyi index 393b4a4bc..64e801df8 100644 --- a/stubs/networkx/networkx/algorithms/centrality/trophic.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/trophic.pyi @@ -1,3 +1,8 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def trophic_levels(G, weight: str = "weight"): ... +@_dispatch def trophic_differences(G, weight: str = "weight"): ... +@_dispatch def trophic_incoherence_parameter(G, weight: str = "weight", cannibalism: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi b/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi index f8d829fa0..3b529cee2 100644 --- a/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def voterank(G, number_of_nodes: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/chains.pyi b/stubs/networkx/networkx/algorithms/chains.pyi index 03249f994..90cd6fe60 100644 --- a/stubs/networkx/networkx/algorithms/chains.pyi +++ b/stubs/networkx/networkx/algorithms/chains.pyi @@ -1,5 +1,7 @@ from collections.abc import Generator from networkx.classes.graph import Graph, _Node +from networkx.utils.backends import _dispatch +@_dispatch def chain_decomposition(G: Graph[_Node], root: _Node | None = None) -> Generator[list[tuple[_Node, _Node]], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/chordal.pyi b/stubs/networkx/networkx/algorithms/chordal.pyi index 2f2fde3a1..c14b40538 100644 --- a/stubs/networkx/networkx/algorithms/chordal.pyi +++ b/stubs/networkx/networkx/algorithms/chordal.pyi @@ -3,10 +3,15 @@ from collections.abc import Generator, Hashable from networkx.classes.graph import Graph, _Node from networkx.exception import NetworkXException +from networkx.utils.backends import _dispatch class NetworkXTreewidthBoundExceeded(NetworkXException): ... +@_dispatch def is_chordal(G: Graph[Hashable]) -> bool: ... +@_dispatch def find_induced_nodes(G: Graph[_Node], s: _Node, t: _Node, treewidth_bound: float = sys.maxsize) -> set[_Node]: ... +@_dispatch def chordal_graph_cliques(G: Graph[_Node]) -> Generator[frozenset[_Node], None, None]: ... +@_dispatch def chordal_graph_treewidth(G: Graph[Hashable]) -> int: ... diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi index 3cfe6eb83..3bae47633 100644 --- a/stubs/networkx/networkx/algorithms/clique.pyi +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -1,18 +1,22 @@ from _typeshed import SupportsGetItem, Unused -from collections.abc import Container, Generator, Iterable, Iterator, Sized +from collections.abc import Generator, Iterable, Iterator, Sized from typing import overload from networkx.classes.graph import Graph, _Node +from networkx.utils.backends import _dispatch +@_dispatch def enumerate_all_cliques(G: Graph[_Node]) -> Generator[list[_Node], None, None]: ... +@_dispatch def find_cliques(G: Graph[_Node], nodes: SupportsGetItem[slice, _Node] | None = None) -> Generator[list[_Node], None, None]: ... +@_dispatch def find_cliques_recursive(G: Graph[_Node], nodes: SupportsGetItem[slice, _Node] | None = None) -> Iterator[list[_Node]]: ... +@_dispatch def make_max_clique_graph(G: Graph[_Node], create_using: type[Graph[_Node]] | None = None) -> Graph[_Node]: ... +@_dispatch def make_clique_bipartite( G: Graph[_Node], fpos: Unused = None, create_using: type[Graph[_Node]] | None = None, name: Unused = None ) -> Graph[_Node]: ... -def graph_clique_number(G: Graph[_Node], cliques: Iterable[_Node] | None = None) -> int: ... -def graph_number_of_cliques(G: Graph[_Node], cliques: Sized | None = None) -> int: ... @overload def node_clique_number( # type: ignore[misc] # Incompatible return types G: Graph[_Node], @@ -24,17 +28,3 @@ def node_clique_number( # type: ignore[misc] # Incompatible return types def node_clique_number( G: Graph[_Node], nodes: _Node, cliques: Iterable[Sized] | None = None, separate_nodes: Unused = False ) -> int: ... -@overload -def number_of_cliques( # type: ignore[misc] # Incompatible return types - G: Graph[_Node], nodes: list[_Node] | None = None, cliques: Iterable[Container[_Node]] | None = None -) -> dict[_Node, int]: ... -@overload -def number_of_cliques(G: Graph[_Node], nodes: _Node, cliques: Iterable[Container[_Node]] | None = None) -> int: ... -@overload -def cliques_containing_node( # type: ignore[misc] # Incompatible return types - G: Graph[_Node], nodes: list[_Node] | None = None, cliques: Iterable[Container[_Node]] | None = None -) -> dict[_Node, list[_Node]]: ... -@overload -def cliques_containing_node( - G: Graph[_Node], nodes: _Node, cliques: Iterable[Container[_Node]] | None = None -) -> Generator[list[_Node], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/cluster.pyi b/stubs/networkx/networkx/algorithms/cluster.pyi index 9e4b5211e..fc4e1fb63 100644 --- a/stubs/networkx/networkx/algorithms/cluster.pyi +++ b/stubs/networkx/networkx/algorithms/cluster.pyi @@ -1,8 +1,16 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def triangles(G, nodes: Incomplete | None = None): ... +@_dispatch def average_clustering(G, nodes: Incomplete | None = None, weight: Incomplete | None = None, count_zeros: bool = True): ... +@_dispatch def clustering(G, nodes: Incomplete | None = None, weight: Incomplete | None = None): ... +@_dispatch def transitivity(G): ... +@_dispatch def square_clustering(G, nodes: Incomplete | None = None): ... +@_dispatch def generalized_degree(G, nodes: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi b/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi index d5a2ebe18..866e127d9 100644 --- a/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi +++ b/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi @@ -1 +1,4 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def equitable_color(G, num_colors): ... diff --git a/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi b/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi index 22e42b366..aaaac626f 100644 --- a/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi +++ b/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi @@ -1,6 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + __all__ = [ "greedy_color", "strategy_connected_sequential", @@ -13,14 +15,23 @@ __all__ = [ "strategy_smallest_last", ] +@_dispatch def strategy_largest_first(G, colors): ... +@_dispatch def strategy_random_sequential(G, colors, seed: Incomplete | None = None): ... +@_dispatch def strategy_smallest_last(G, colors): ... +@_dispatch def strategy_independent_set(G, colors) -> Generator[Incomplete, Incomplete, None]: ... +@_dispatch def strategy_connected_sequential_bfs(G, colors): ... +@_dispatch def strategy_connected_sequential_dfs(G, colors): ... +@_dispatch def strategy_connected_sequential(G, colors, traversal: str = "bfs") -> Generator[Incomplete, None, None]: ... +@_dispatch def strategy_saturation_largest_first(G, colors) -> Generator[Incomplete, None, Incomplete]: ... +@_dispatch def greedy_color(G, strategy: str = "largest_first", interchange: bool = False): ... class _Node: diff --git a/stubs/networkx/networkx/algorithms/communicability_alg.pyi b/stubs/networkx/networkx/algorithms/communicability_alg.pyi index df90b4c6f..55ab8cd05 100644 --- a/stubs/networkx/networkx/algorithms/communicability_alg.pyi +++ b/stubs/networkx/networkx/algorithms/communicability_alg.pyi @@ -1,2 +1,6 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def communicability(G): ... +@_dispatch def communicability_exp(G): ... diff --git a/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi b/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi index 842f7c011..2604518dd 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 networkx.utils.backends import _dispatch + +@_dispatch def asyn_fluidc(G, k, max_iter: int = 100, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/community/centrality.pyi b/stubs/networkx/networkx/algorithms/community/centrality.pyi index b3f0e2a6c..715fa7013 100644 --- a/stubs/networkx/networkx/algorithms/community/centrality.pyi +++ b/stubs/networkx/networkx/algorithms/community/centrality.pyi @@ -1,4 +1,7 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def girvan_newman(G, most_valuable_edge: Incomplete | None = None) -> Generator[Incomplete, None, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/community/community_utils.pyi b/stubs/networkx/networkx/algorithms/community/community_utils.pyi index aa5517b41..dc011e9a7 100644 --- a/stubs/networkx/networkx/algorithms/community/community_utils.pyi +++ b/stubs/networkx/networkx/algorithms/community/community_utils.pyi @@ -1 +1,4 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def is_partition(G, communities): ... diff --git a/stubs/networkx/networkx/algorithms/community/kclique.pyi b/stubs/networkx/networkx/algorithms/community/kclique.pyi index c614fa487..aebf35222 100644 --- a/stubs/networkx/networkx/algorithms/community/kclique.pyi +++ b/stubs/networkx/networkx/algorithms/community/kclique.pyi @@ -1,4 +1,7 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def k_clique_communities(G, k, cliques: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi b/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi index 8063bcdd5..e8a0ad899 100644 --- a/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi +++ b/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def kernighan_lin_bisection( G, partition: Incomplete | None = None, max_iter: int = 10, weight: str = "weight", seed: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/community/label_propagation.pyi b/stubs/networkx/networkx/algorithms/community/label_propagation.pyi index af023350e..b3db6ac4c 100644 --- a/stubs/networkx/networkx/algorithms/community/label_propagation.pyi +++ b/stubs/networkx/networkx/algorithms/community/label_propagation.pyi @@ -1,7 +1,11 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def asyn_lpa_communities( G, weight: Incomplete | None = None, seed: Incomplete | None = None ) -> Generator[Incomplete, Incomplete, None]: ... +@_dispatch def label_propagation_communities(G): ... diff --git a/stubs/networkx/networkx/algorithms/community/louvain.pyi b/stubs/networkx/networkx/algorithms/community/louvain.pyi index 64c554664..0155ccd71 100644 --- a/stubs/networkx/networkx/algorithms/community/louvain.pyi +++ b/stubs/networkx/networkx/algorithms/community/louvain.pyi @@ -1,9 +1,13 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def louvain_communities( G, weight: str = "weight", resolution: float = 1, threshold: float = 1e-07, seed: Incomplete | None = None ): ... +@_dispatch def louvain_partitions( G, weight: str = "weight", resolution: float = 1, threshold: float = 1e-07, seed: Incomplete | None = None ) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/community/lukes.pyi b/stubs/networkx/networkx/algorithms/community/lukes.pyi index bf281313d..f748adb81 100644 --- a/stubs/networkx/networkx/algorithms/community/lukes.pyi +++ b/stubs/networkx/networkx/algorithms/community/lukes.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def lukes_partitioning(G, max_size, node_weight: Incomplete | None = None, edge_weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/community/modularity_max.pyi b/stubs/networkx/networkx/algorithms/community/modularity_max.pyi index e994d7760..1ac861d8a 100644 --- a/stubs/networkx/networkx/algorithms/community/modularity_max.pyi +++ b/stubs/networkx/networkx/algorithms/community/modularity_max.pyi @@ -1,6 +1,10 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def greedy_modularity_communities( G, weight: Incomplete | None = None, resolution: float = 1, cutoff: int = 1, best_n: Incomplete | None = None ): ... +@_dispatch def naive_greedy_modularity_communities(G, resolution: float = 1, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/community/quality.pyi b/stubs/networkx/networkx/algorithms/community/quality.pyi index dff61e455..2ffecb7b3 100644 --- a/stubs/networkx/networkx/algorithms/community/quality.pyi +++ b/stubs/networkx/networkx/algorithms/community/quality.pyi @@ -1,9 +1,12 @@ from networkx.exception import NetworkXError +from networkx.utils.backends import _dispatch __all__ = ["modularity", "partition_quality"] class NotAPartition(NetworkXError): def __init__(self, G, collection) -> None: ... +@_dispatch def modularity(G, communities, weight: str = "weight", resolution: float = 1): ... +@_dispatch def partition_quality(G, partition): ... diff --git a/stubs/networkx/networkx/algorithms/components/attracting.pyi b/stubs/networkx/networkx/algorithms/components/attracting.pyi index a954808ed..8a6dd93e3 100644 --- a/stubs/networkx/networkx/algorithms/components/attracting.pyi +++ b/stubs/networkx/networkx/algorithms/components/attracting.pyi @@ -1,6 +1,11 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def attracting_components(G) -> Generator[Incomplete, None, None]: ... +@_dispatch def number_attracting_components(G): ... +@_dispatch def is_attracting_component(G): ... diff --git a/stubs/networkx/networkx/algorithms/components/biconnected.pyi b/stubs/networkx/networkx/algorithms/components/biconnected.pyi index 384dbe18d..b7dc97487 100644 --- a/stubs/networkx/networkx/algorithms/components/biconnected.pyi +++ b/stubs/networkx/networkx/algorithms/components/biconnected.pyi @@ -1,7 +1,13 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def is_biconnected(G): ... +@_dispatch def biconnected_component_edges(G) -> Generator[Incomplete, Incomplete, None]: ... +@_dispatch def biconnected_components(G) -> Generator[Incomplete, None, None]: ... +@_dispatch def articulation_points(G) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/components/connected.pyi b/stubs/networkx/networkx/algorithms/components/connected.pyi index 4ba209106..1e1024471 100644 --- a/stubs/networkx/networkx/algorithms/components/connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/connected.pyi @@ -1,7 +1,13 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def connected_components(G) -> Generator[Incomplete, None, None]: ... +@_dispatch def number_connected_components(G): ... +@_dispatch def is_connected(G): ... +@_dispatch def node_connected_component(G, n): ... diff --git a/stubs/networkx/networkx/algorithms/components/semiconnected.pyi b/stubs/networkx/networkx/algorithms/components/semiconnected.pyi index 10bf78a9d..179784032 100644 --- a/stubs/networkx/networkx/algorithms/components/semiconnected.pyi +++ b/stubs/networkx/networkx/algorithms/components/semiconnected.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def is_semiconnected(G, topo_order: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi index 27c58b928..41b77c125 100644 --- a/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi @@ -2,10 +2,17 @@ from collections.abc import Generator, Hashable, Iterable from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node +from networkx.utils.backends import _dispatch +@_dispatch def strongly_connected_components(G: Graph[_Node]) -> Generator[set[_Node], None, None]: ... +@_dispatch def kosaraju_strongly_connected_components(G: Graph[_Node], source: _Node | None = None) -> Generator[set[_Node], None, None]: ... +@_dispatch def strongly_connected_components_recursive(G: Graph[_Node]) -> Generator[set[_Node], None, None]: ... +@_dispatch def number_strongly_connected_components(G: Graph[Hashable]) -> int: ... +@_dispatch def is_strongly_connected(G: Graph[Hashable]) -> bool: ... +@_dispatch def condensation(G: DiGraph[_Node], scc: Iterable[Iterable[_Node]] | None = None) -> DiGraph[int]: ... diff --git a/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi b/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi index 04f5c555e..95283d2bd 100644 --- a/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi @@ -1,7 +1,11 @@ from collections.abc import Generator, Hashable from networkx.classes.graph import Graph, _Node +from networkx.utils.backends import _dispatch +@_dispatch def weakly_connected_components(G: Graph[_Node]) -> Generator[set[_Node], None, None]: ... +@_dispatch def number_weakly_connected_components(G: Graph[Hashable]) -> int: ... +@_dispatch def is_weakly_connected(G: Graph[Hashable]) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi index 77918d923..75c14803d 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from networkx.algorithms.flow import edmonds_karp +from networkx.utils.backends import _dispatch __all__ = [ "average_node_connectivity", @@ -13,6 +14,7 @@ __all__ = [ default_flow_func = edmonds_karp +@_dispatch def local_node_connectivity( G, s, @@ -22,9 +24,13 @@ def local_node_connectivity( residual: Incomplete | None = None, cutoff: Incomplete | None = None, ): ... +@_dispatch def node_connectivity(G, s: Incomplete | None = None, t: Incomplete | None = None, flow_func: Incomplete | None = None): ... +@_dispatch def average_node_connectivity(G, flow_func: Incomplete | None = None): ... +@_dispatch def all_pairs_node_connectivity(G, nbunch: Incomplete | None = None, flow_func: Incomplete | None = None): ... +@_dispatch def local_edge_connectivity( G, s, @@ -34,6 +40,7 @@ def local_edge_connectivity( residual: Incomplete | None = None, cutoff: Incomplete | None = None, ): ... +@_dispatch def edge_connectivity( G, s: Incomplete | None = None, diff --git a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi index de6cfd051..7c9301002 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi @@ -1,16 +1,21 @@ from _typeshed import Incomplete from networkx.algorithms.flow import edmonds_karp +from networkx.utils.backends import _dispatch __all__ = ["minimum_st_node_cut", "minimum_node_cut", "minimum_st_edge_cut", "minimum_edge_cut"] default_flow_func = edmonds_karp +@_dispatch def minimum_st_edge_cut( G, s, t, flow_func: Incomplete | None = None, auxiliary: Incomplete | None = None, residual: Incomplete | None = None ): ... +@_dispatch def minimum_st_node_cut( G, s, t, flow_func: Incomplete | None = None, auxiliary: Incomplete | None = None, residual: Incomplete | None = None ): ... +@_dispatch def minimum_node_cut(G, s: Incomplete | None = None, t: Incomplete | None = None, flow_func: Incomplete | None = None): ... +@_dispatch def minimum_edge_cut(G, s: Incomplete | None = None, t: Incomplete | None = None, flow_func: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi b/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi index daca82b9c..6cca9ca6c 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi @@ -2,11 +2,13 @@ from _typeshed import Incomplete from collections.abc import Generator from networkx.algorithms.flow import edmonds_karp +from networkx.utils.backends import _dispatch __all__ = ["edge_disjoint_paths", "node_disjoint_paths"] default_flow_func = edmonds_karp +@_dispatch def edge_disjoint_paths( G, s, @@ -16,6 +18,7 @@ def edge_disjoint_paths( auxiliary: Incomplete | None = None, residual: Incomplete | None = None, ) -> Generator[Incomplete, None, None]: ... +@_dispatch def node_disjoint_paths( G, s, diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi index 0608747f1..133ab4460 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -1,9 +1,13 @@ from collections.abc import Generator, Hashable from networkx.classes.graph import Graph, _Node +from networkx.utils.backends import _dispatch +@_dispatch def is_k_edge_connected(G: Graph[Hashable], k: int): ... +@_dispatch def is_locally_k_edge_connected(G, s, t, k): ... +@_dispatch def k_edge_augmentation( G: Graph[_Node], k: int, diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi index b8c4a413b..f0d92cc63 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi @@ -1,8 +1,13 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def k_edge_components(G, k): ... +@_dispatch def k_edge_subgraphs(G, k): ... +@_dispatch def bridge_components(G) -> Generator[Incomplete, Incomplete, None]: ... class EdgeComponentAuxGraph: diff --git a/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi index 980187ead..967df857c 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi @@ -1,9 +1,11 @@ from _typeshed import Incomplete from networkx.algorithms.flow import edmonds_karp +from networkx.utils.backends import _dispatch __all__ = ["k_components"] default_flow_func = edmonds_karp +@_dispatch def k_components(G, flow_func: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi b/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi index e72d08005..20a196706 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi @@ -2,9 +2,11 @@ from _typeshed import Incomplete from collections.abc import Generator from networkx.algorithms.flow import edmonds_karp +from networkx.utils.backends import _dispatch __all__ = ["all_node_cuts"] default_flow_func = edmonds_karp +@_dispatch def all_node_cuts(G, k: Incomplete | None = None, flow_func: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/stoerwagner.pyi b/stubs/networkx/networkx/algorithms/connectivity/stoerwagner.pyi index 1463d416c..e8125730f 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/stoerwagner.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/stoerwagner.pyi @@ -1 +1,4 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def stoer_wagner(G, weight: str = "weight", heap=...): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/utils.pyi b/stubs/networkx/networkx/algorithms/connectivity/utils.pyi index c4c2f53ae..12872bab7 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/utils.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/utils.pyi @@ -1,2 +1,6 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def build_auxiliary_node_connectivity(G): ... +@_dispatch def build_auxiliary_edge_connectivity(G): ... diff --git a/stubs/networkx/networkx/algorithms/core.pyi b/stubs/networkx/networkx/algorithms/core.pyi index 6e33b6614..65ba65147 100644 --- a/stubs/networkx/networkx/algorithms/core.pyi +++ b/stubs/networkx/networkx/algorithms/core.pyi @@ -1,9 +1,18 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def core_number(G): ... +@_dispatch def k_core(G, k: Incomplete | None = None, core_number: Incomplete | None = None): ... +@_dispatch def k_shell(G, k: Incomplete | None = None, core_number: Incomplete | None = None): ... +@_dispatch def k_crust(G, k: Incomplete | None = None, core_number: Incomplete | None = None): ... +@_dispatch def k_corona(G, k, core_number: Incomplete | None = None): ... +@_dispatch def k_truss(G, k): ... +@_dispatch def onion_layers(G): ... diff --git a/stubs/networkx/networkx/algorithms/covering.pyi b/stubs/networkx/networkx/algorithms/covering.pyi index 9685e76f9..673049503 100644 --- a/stubs/networkx/networkx/algorithms/covering.pyi +++ b/stubs/networkx/networkx/algorithms/covering.pyi @@ -1,4 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def min_edge_cover(G, matching_algorithm: Incomplete | None = None): ... +@_dispatch def is_edge_cover(G, cover): ... diff --git a/stubs/networkx/networkx/algorithms/cuts.pyi b/stubs/networkx/networkx/algorithms/cuts.pyi index 1cbf2030d..2f6d488e2 100644 --- a/stubs/networkx/networkx/algorithms/cuts.pyi +++ b/stubs/networkx/networkx/algorithms/cuts.pyi @@ -1,10 +1,20 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def cut_size(G, S, T: Incomplete | None = None, weight: Incomplete | None = None): ... +@_dispatch def volume(G, S, weight: Incomplete | None = None): ... +@_dispatch def normalized_cut_size(G, S, T: Incomplete | None = None, weight: Incomplete | None = None): ... +@_dispatch def conductance(G, S, T: Incomplete | None = None, weight: Incomplete | None = None): ... +@_dispatch def edge_expansion(G, S, T: Incomplete | None = None, weight: Incomplete | None = None): ... +@_dispatch def mixing_expansion(G, S, T: Incomplete | None = None, weight: Incomplete | None = None): ... +@_dispatch def node_expansion(G, S): ... +@_dispatch def boundary_expansion(G, S): ... diff --git a/stubs/networkx/networkx/algorithms/cycles.pyi b/stubs/networkx/networkx/algorithms/cycles.pyi index f637db85b..a4b09797b 100644 --- a/stubs/networkx/networkx/algorithms/cycles.pyi +++ b/stubs/networkx/networkx/algorithms/cycles.pyi @@ -1,7 +1,11 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def cycle_basis(G, root: Incomplete | None = None): ... +@_dispatch def simple_cycles(G, length_bound: Incomplete | None = None) -> Generator[Incomplete, Incomplete, None]: ... class _NeighborhoodCache(dict[Incomplete, Incomplete]): @@ -9,7 +13,11 @@ class _NeighborhoodCache(dict[Incomplete, Incomplete]): def __init__(self, G) -> None: ... def __missing__(self, v): ... +@_dispatch def chordless_cycles(G, length_bound: Incomplete | None = None) -> Generator[Incomplete, Incomplete, None]: ... +@_dispatch def recursive_simple_cycles(G): ... +@_dispatch def find_cycle(G, source: Incomplete | None = None, orientation: Incomplete | None = None): ... +@_dispatch def minimum_cycle_basis(G, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/d_separation.pyi b/stubs/networkx/networkx/algorithms/d_separation.pyi index 12a4a645c..8ee16cec2 100644 --- a/stubs/networkx/networkx/algorithms/d_separation.pyi +++ b/stubs/networkx/networkx/algorithms/d_separation.pyi @@ -1,3 +1,8 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def d_separated(G, x, y, z): ... +@_dispatch def minimal_d_separator(G, u, v): ... +@_dispatch def is_minimal_d_separator(G, u, v, z): ... diff --git a/stubs/networkx/networkx/algorithms/dag.pyi b/stubs/networkx/networkx/algorithms/dag.pyi index 47a677009..bd59c8e58 100644 --- a/stubs/networkx/networkx/algorithms/dag.pyi +++ b/stubs/networkx/networkx/algorithms/dag.pyi @@ -2,21 +2,35 @@ from _typeshed import SupportsRichComparison from collections.abc import Callable, Generator, Iterable, Reversible from networkx.classes.graph import Graph, _Node +from networkx.utils.backends import _dispatch +@_dispatch def descendants(G: Graph[_Node], source: _Node) -> set[_Node]: ... +@_dispatch def ancestors(G: Graph[_Node], source: _Node) -> set[_Node]: ... +@_dispatch def is_directed_acyclic_graph(G: Graph[_Node]) -> bool: ... +@_dispatch def topological_sort(G: Graph[_Node]) -> Generator[_Node, None, None]: ... +@_dispatch def lexicographical_topological_sort( G: Graph[_Node], key: Callable[[_Node], SupportsRichComparison] | None = None ) -> Generator[_Node, None, None]: ... +@_dispatch def all_topological_sorts(G: Graph[_Node]) -> Generator[list[_Node], None, None]: ... +@_dispatch def is_aperiodic(G: Graph[_Node]) -> bool: ... +@_dispatch def transitive_closure(G: Graph[_Node], reflexive: bool = False) -> Graph[_Node]: ... +@_dispatch def transitive_reduction(G: Graph[_Node]) -> Graph[_Node]: ... +@_dispatch def antichains(G: Graph[_Node], topo_order: Reversible[_Node] | None = None) -> Generator[list[_Node], None, None]: ... +@_dispatch def dag_longest_path( G: Graph[_Node], weight: str = "weight", default_weight: int = 1, topo_order: Iterable[_Node] | None = None ) -> list[_Node]: ... +@_dispatch def dag_longest_path_length(G: Graph[_Node], weight: str = "weight", default_weight: int = 1) -> int: ... +@_dispatch def dag_to_branching(G: Graph[_Node]) -> Graph[_Node]: ... diff --git a/stubs/networkx/networkx/algorithms/distance_measures.pyi b/stubs/networkx/networkx/algorithms/distance_measures.pyi index 0119b424e..6949c2669 100644 --- a/stubs/networkx/networkx/algorithms/distance_measures.pyi +++ b/stubs/networkx/networkx/algorithms/distance_measures.pyi @@ -1,9 +1,18 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def eccentricity(G, v: Incomplete | None = None, sp: Incomplete | None = None, weight: Incomplete | None = None): ... +@_dispatch def diameter(G, e: Incomplete | None = None, usebounds: bool = False, weight: Incomplete | None = None): ... +@_dispatch def periphery(G, e: Incomplete | None = None, usebounds: bool = False, weight: Incomplete | None = None): ... +@_dispatch def radius(G, e: Incomplete | None = None, usebounds: bool = False, weight: Incomplete | None = None): ... +@_dispatch def center(G, e: Incomplete | None = None, usebounds: bool = False, weight: Incomplete | None = None): ... +@_dispatch def barycenter(G, weight: Incomplete | None = None, attr: Incomplete | None = None, sp: Incomplete | None = None): ... +@_dispatch def resistance_distance(G, nodeA, nodeB, weight: Incomplete | None = None, invert_weight: bool = True): ... diff --git a/stubs/networkx/networkx/algorithms/distance_regular.pyi b/stubs/networkx/networkx/algorithms/distance_regular.pyi index 2a6f49032..4b3b23e02 100644 --- a/stubs/networkx/networkx/algorithms/distance_regular.pyi +++ b/stubs/networkx/networkx/algorithms/distance_regular.pyi @@ -1,4 +1,10 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def is_distance_regular(G): ... +@_dispatch def global_parameters(b, c): ... +@_dispatch def intersection_array(G): ... +@_dispatch def is_strongly_regular(G): ... diff --git a/stubs/networkx/networkx/algorithms/dominance.pyi b/stubs/networkx/networkx/algorithms/dominance.pyi index 707ccfc3d..37d5ab6e5 100644 --- a/stubs/networkx/networkx/algorithms/dominance.pyi +++ b/stubs/networkx/networkx/algorithms/dominance.pyi @@ -1,2 +1,6 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def immediate_dominators(G, start): ... +@_dispatch def dominance_frontiers(G, start): ... diff --git a/stubs/networkx/networkx/algorithms/dominating.pyi b/stubs/networkx/networkx/algorithms/dominating.pyi index e48c5e173..03dae96b8 100644 --- a/stubs/networkx/networkx/algorithms/dominating.pyi +++ b/stubs/networkx/networkx/algorithms/dominating.pyi @@ -1,4 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def dominating_set(G, start_with: Incomplete | None = None): ... +@_dispatch def is_dominating_set(G, nbunch): ... diff --git a/stubs/networkx/networkx/algorithms/efficiency_measures.pyi b/stubs/networkx/networkx/algorithms/efficiency_measures.pyi index 4a1b3e50d..c3eb60647 100644 --- a/stubs/networkx/networkx/algorithms/efficiency_measures.pyi +++ b/stubs/networkx/networkx/algorithms/efficiency_measures.pyi @@ -1,3 +1,8 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def efficiency(G, u, v): ... +@_dispatch def global_efficiency(G): ... +@_dispatch def local_efficiency(G): ... diff --git a/stubs/networkx/networkx/algorithms/euler.pyi b/stubs/networkx/networkx/algorithms/euler.pyi index 73120e1b1..f63b1337d 100644 --- a/stubs/networkx/networkx/algorithms/euler.pyi +++ b/stubs/networkx/networkx/algorithms/euler.pyi @@ -1,9 +1,17 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def is_eulerian(G): ... +@_dispatch def is_semieulerian(G): ... +@_dispatch def eulerian_circuit(G, source: Incomplete | None = None, keys: bool = False) -> Generator[Incomplete, Incomplete, None]: ... +@_dispatch def has_eulerian_path(G, source: Incomplete | None = None): ... +@_dispatch def eulerian_path(G, source: Incomplete | None = None, keys: bool = False) -> Generator[Incomplete, Incomplete, None]: ... +@_dispatch def eulerize(G): ... diff --git a/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi b/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi index 18c237d26..94e7ad790 100644 --- a/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi +++ b/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def boykov_kolmogorov( G, s, diff --git a/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi b/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi index cffacb633..bdcad0ee8 100644 --- a/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi +++ b/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi @@ -1 +1,4 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def capacity_scaling(G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight", heap=...): ... diff --git a/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi b/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi index 1a96f54f1..bf85ca8f5 100644 --- a/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi +++ b/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def dinitz( G, s, diff --git a/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi b/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi index b9cee6b8a..f6c43c5f0 100644 --- a/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi +++ b/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def edmonds_karp( G, s, diff --git a/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi b/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi index efa59ca8d..a72af8b9f 100644 --- a/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi +++ b/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi @@ -1,9 +1,12 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + from .edmondskarp import edmonds_karp __all__ = ["gomory_hu_tree"] default_flow_func = edmonds_karp +@_dispatch def gomory_hu_tree(G, capacity: str = "capacity", flow_func: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/flow/maxflow.pyi b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi index fa98e32cf..ef3e7acc3 100644 --- a/stubs/networkx/networkx/algorithms/flow/maxflow.pyi +++ b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi @@ -1,12 +1,18 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + from .preflowpush import preflow_push __all__ = ["maximum_flow", "maximum_flow_value", "minimum_cut", "minimum_cut_value"] default_flow_func = preflow_push +@_dispatch def maximum_flow(flowG, _s, _t, capacity: str = "capacity", flow_func: Incomplete | None = None, **kwargs): ... +@_dispatch def maximum_flow_value(flowG, _s, _t, capacity: str = "capacity", flow_func: Incomplete | None = None, **kwargs): ... +@_dispatch def minimum_cut(flowG, _s, _t, capacity: str = "capacity", flow_func: Incomplete | None = None, **kwargs): ... +@_dispatch def minimum_cut_value(flowG, _s, _t, capacity: str = "capacity", flow_func: Incomplete | None = None, **kwargs): ... diff --git a/stubs/networkx/networkx/algorithms/flow/mincost.pyi b/stubs/networkx/networkx/algorithms/flow/mincost.pyi index 4f441965a..d1bed62bb 100644 --- a/stubs/networkx/networkx/algorithms/flow/mincost.pyi +++ b/stubs/networkx/networkx/algorithms/flow/mincost.pyi @@ -1,4 +1,10 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def min_cost_flow_cost(G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... +@_dispatch def min_cost_flow(G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... +@_dispatch def cost_of_flow(G, flowDict, weight: str = "weight"): ... +@_dispatch def max_flow_min_cost(G, s, t, capacity: str = "capacity", weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi b/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi index 0039ca0ad..662b66359 100644 --- a/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi +++ b/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi @@ -1,6 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + class _DataEssentialsAndFunctions: node_list: Incomplete node_indices: Incomplete @@ -36,4 +38,5 @@ class _DataEssentialsAndFunctions: def residual_capacity(self, i, p): ... def find_leaving_edge(self, Wn, We): ... +@_dispatch def network_simplex(G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi b/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi index 6d38c6b93..97ce358a1 100644 --- a/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi +++ b/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def preflow_push( G, s, diff --git a/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi b/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi index 3d460bc43..2d7000027 100644 --- a/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi +++ b/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def shortest_augmenting_path( G, s, diff --git a/stubs/networkx/networkx/algorithms/flow/utils.pyi b/stubs/networkx/networkx/algorithms/flow/utils.pyi index b110dba94..41b7bb945 100644 --- a/stubs/networkx/networkx/algorithms/flow/utils.pyi +++ b/stubs/networkx/networkx/algorithms/flow/utils.pyi @@ -1,5 +1,7 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + class CurrentEdge: def __init__(self, edges) -> None: ... def get(self): ... @@ -16,6 +18,9 @@ class GlobalRelabelThreshold: def is_reached(self): ... def clear_work(self) -> None: ... +@_dispatch def build_residual_network(G, capacity): ... +@_dispatch def detect_unboundedness(R, s, t) -> None: ... +@_dispatch def build_flow_dict(G, R): ... diff --git a/stubs/networkx/networkx/algorithms/graph_hashing.pyi b/stubs/networkx/networkx/algorithms/graph_hashing.pyi index e2fd08c03..50d4c6721 100644 --- a/stubs/networkx/networkx/algorithms/graph_hashing.pyi +++ b/stubs/networkx/networkx/algorithms/graph_hashing.pyi @@ -1,8 +1,12 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def weisfeiler_lehman_graph_hash( G, edge_attr: Incomplete | None = None, node_attr: Incomplete | None = None, iterations: int = 3, digest_size: int = 16 ): ... +@_dispatch def weisfeiler_lehman_subgraph_hashes( G, edge_attr: Incomplete | None = None, node_attr: Incomplete | None = None, iterations: int = 3, digest_size: int = 16 ): ... diff --git a/stubs/networkx/networkx/algorithms/graphical.pyi b/stubs/networkx/networkx/algorithms/graphical.pyi index f13f5e99c..02b44c455 100644 --- a/stubs/networkx/networkx/algorithms/graphical.pyi +++ b/stubs/networkx/networkx/algorithms/graphical.pyi @@ -1,6 +1,14 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def is_graphical(sequence, method: str = "eg"): ... +@_dispatch def is_valid_degree_sequence_havel_hakimi(deg_sequence): ... +@_dispatch def is_valid_degree_sequence_erdos_gallai(deg_sequence): ... +@_dispatch def is_multigraphical(sequence): ... +@_dispatch def is_pseudographical(sequence): ... +@_dispatch def is_digraphical(in_sequence, out_sequence): ... diff --git a/stubs/networkx/networkx/algorithms/hierarchy.pyi b/stubs/networkx/networkx/algorithms/hierarchy.pyi index 8919d04b1..6cecb2b26 100644 --- a/stubs/networkx/networkx/algorithms/hierarchy.pyi +++ b/stubs/networkx/networkx/algorithms/hierarchy.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def flow_hierarchy(G, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/hybrid.pyi b/stubs/networkx/networkx/algorithms/hybrid.pyi index df5f4bcd0..efb3a27eb 100644 --- a/stubs/networkx/networkx/algorithms/hybrid.pyi +++ b/stubs/networkx/networkx/algorithms/hybrid.pyi @@ -1,2 +1,6 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def kl_connected_subgraph(G, k, l, low_memory: bool = False, same_as_graph: bool = False): ... +@_dispatch def is_kl_connected(G, k, l, low_memory: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/isolate.pyi b/stubs/networkx/networkx/algorithms/isolate.pyi index 0b25847c8..f620e5e62 100644 --- a/stubs/networkx/networkx/algorithms/isolate.pyi +++ b/stubs/networkx/networkx/algorithms/isolate.pyi @@ -1,3 +1,8 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def is_isolate(G, n): ... +@_dispatch def isolates(G): ... +@_dispatch def number_of_isolates(G): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi b/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi index 35caa37cc..7d2fa069c 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi @@ -1,17 +1,23 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + __all__ = ["could_be_isomorphic", "fast_could_be_isomorphic", "faster_could_be_isomorphic", "is_isomorphic"] +@_dispatch def could_be_isomorphic(G1, G2): ... graph_could_be_isomorphic = could_be_isomorphic +@_dispatch def fast_could_be_isomorphic(G1, G2): ... fast_graph_could_be_isomorphic = fast_could_be_isomorphic +@_dispatch def faster_could_be_isomorphic(G1, G2): ... faster_graph_could_be_isomorphic = faster_could_be_isomorphic +@_dispatch def is_isomorphic(G1, G2, node_match: Incomplete | None = None, edge_match: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi b/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi index 0b525aafe..74cb0f884 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi @@ -1,17 +1,25 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def categorical_node_match(attr, default): ... categorical_edge_match: Incomplete +@_dispatch def categorical_multiedge_match(attr, default): ... +@_dispatch def numerical_node_match(attr, default, rtol: float = 1e-05, atol: float = 1e-08): ... numerical_edge_match: Incomplete +@_dispatch def numerical_multiedge_match(attr, default, rtol: float = 1e-05, atol: float = 1e-08): ... +@_dispatch def generic_node_match(attr, default, op): ... generic_edge_match: Incomplete +@_dispatch def generic_multiedge_match(attr, default, op): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi b/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi index b6502d719..791970616 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi @@ -1,2 +1,6 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def rooted_tree_isomorphism(t1, root1, t2, root2): ... +@_dispatch def tree_isomorphism(t1, t2): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi b/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi index 578392014..8cfa42a43 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi @@ -2,6 +2,8 @@ from _typeshed import Incomplete from collections.abc import Generator from typing import NamedTuple +from networkx.utils.backends import _dispatch + class _GraphParameters(NamedTuple): G1: Incomplete G2: Incomplete @@ -23,8 +25,11 @@ class _StateParameters(NamedTuple): T2_tilde: Incomplete T2_tilde_in: Incomplete +@_dispatch def vf2pp_isomorphism(G1, G2, node_label: Incomplete | None = None, default_label: Incomplete | None = None): ... +@_dispatch def vf2pp_is_isomorphic(G1, G2, node_label: Incomplete | None = None, default_label: Incomplete | None = None): ... +@_dispatch def vf2pp_all_isomorphisms( G1, G2, node_label: Incomplete | None = None, default_label: Incomplete | None = None ) -> Generator[Incomplete, None, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi b/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi index 7eccedf80..46b3f7099 100644 --- a/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi +++ b/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def hits(G, max_iter: int = 100, tol: float = 1e-08, nstart: Incomplete | None = None, normalized: bool = True): ... diff --git a/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi b/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi index 048f4226c..c283f0e66 100644 --- a/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi +++ b/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def pagerank( G, alpha: float = 0.85, @@ -10,6 +13,7 @@ def pagerank( weight: str = "weight", dangling: Incomplete | None = None, ): ... +@_dispatch def google_matrix( G, alpha: float = 0.85, diff --git a/stubs/networkx/networkx/algorithms/link_prediction.pyi b/stubs/networkx/networkx/algorithms/link_prediction.pyi index 69082e00d..aa0a530fb 100644 --- a/stubs/networkx/networkx/algorithms/link_prediction.pyi +++ b/stubs/networkx/networkx/algorithms/link_prediction.pyi @@ -1,10 +1,20 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def resource_allocation_index(G, ebunch: Incomplete | None = None): ... +@_dispatch def jaccard_coefficient(G, ebunch: Incomplete | None = None): ... +@_dispatch def adamic_adar_index(G, ebunch: Incomplete | None = None): ... +@_dispatch def common_neighbor_centrality(G, ebunch: Incomplete | None = None, alpha: float = 0.8): ... +@_dispatch def preferential_attachment(G, ebunch: Incomplete | None = None): ... +@_dispatch def cn_soundarajan_hopcroft(G, ebunch: Incomplete | None = None, community: str = "community"): ... +@_dispatch def ra_index_soundarajan_hopcroft(G, ebunch: Incomplete | None = None, community: str = "community"): ... +@_dispatch def within_inter_cluster(G, ebunch: Incomplete | None = None, delta: float = 0.001, community: str = "community"): ... diff --git a/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi b/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi index 57b6f19ba..f9e16cfc4 100644 --- a/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi +++ b/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi @@ -1,8 +1,13 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def all_pairs_lowest_common_ancestor(G, pairs: Incomplete | None = None): ... +@_dispatch def lowest_common_ancestor(G, node1, node2, default: Incomplete | None = None): ... +@_dispatch def tree_all_pairs_lowest_common_ancestor( G, root: Incomplete | None = None, pairs: Incomplete | None = None ) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/matching.pyi b/stubs/networkx/networkx/algorithms/matching.pyi index 968e26045..3873396af 100644 --- a/stubs/networkx/networkx/algorithms/matching.pyi +++ b/stubs/networkx/networkx/algorithms/matching.pyi @@ -1,6 +1,14 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def maximal_matching(G): ... +@_dispatch def is_matching(G, matching): ... +@_dispatch def is_maximal_matching(G, matching): ... +@_dispatch def is_perfect_matching(G, matching): ... +@_dispatch def min_weight_matching(G, weight: str = "weight"): ... +@_dispatch def max_weight_matching(G, maxcardinality: bool = False, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/minors/contraction.pyi b/stubs/networkx/networkx/algorithms/minors/contraction.pyi index 350c734b8..1a1a1fdc2 100644 --- a/stubs/networkx/networkx/algorithms/minors/contraction.pyi +++ b/stubs/networkx/networkx/algorithms/minors/contraction.pyi @@ -1,6 +1,10 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def equivalence_classes(iterable, relation): ... +@_dispatch def quotient_graph( G, partition, @@ -10,8 +14,10 @@ def quotient_graph( relabel: bool = False, create_using: Incomplete | None = None, ): ... +@_dispatch def contracted_nodes(G, u, v, self_loops: bool = True, copy: bool = True): ... identified_nodes = contracted_nodes +@_dispatch def contracted_edge(G, edge, self_loops: bool = True, copy: bool = True): ... diff --git a/stubs/networkx/networkx/algorithms/mis.pyi b/stubs/networkx/networkx/algorithms/mis.pyi index e4b46e6c5..4172e5fab 100644 --- a/stubs/networkx/networkx/algorithms/mis.pyi +++ b/stubs/networkx/networkx/algorithms/mis.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def maximal_independent_set(G, nodes: Incomplete | None = None, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/moral.pyi b/stubs/networkx/networkx/algorithms/moral.pyi index dad4d3ee3..e333ac5e2 100644 --- a/stubs/networkx/networkx/algorithms/moral.pyi +++ b/stubs/networkx/networkx/algorithms/moral.pyi @@ -1 +1,4 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def moral_graph(G): ... diff --git a/stubs/networkx/networkx/algorithms/node_classification.pyi b/stubs/networkx/networkx/algorithms/node_classification.pyi index 14d8a769c..bec0e815a 100644 --- a/stubs/networkx/networkx/algorithms/node_classification.pyi +++ b/stubs/networkx/networkx/algorithms/node_classification.pyi @@ -1,2 +1,6 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def harmonic_function(G, max_iter: int = 30, label_name: str = "label"): ... +@_dispatch def local_and_global_consistency(G, alpha: float = 0.99, max_iter: int = 30, label_name: str = "label"): ... diff --git a/stubs/networkx/networkx/algorithms/non_randomness.pyi b/stubs/networkx/networkx/algorithms/non_randomness.pyi index da85a16ce..82459492d 100644 --- a/stubs/networkx/networkx/algorithms/non_randomness.pyi +++ b/stubs/networkx/networkx/algorithms/non_randomness.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def non_randomness(G, k: Incomplete | None = None, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/operators/all.pyi b/stubs/networkx/networkx/algorithms/operators/all.pyi index e4cc8ea4f..c14667101 100644 --- a/stubs/networkx/networkx/algorithms/operators/all.pyi +++ b/stubs/networkx/networkx/algorithms/operators/all.pyi @@ -1,4 +1,10 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def union_all(graphs, rename=()): ... +@_dispatch def disjoint_union_all(graphs): ... +@_dispatch def compose_all(graphs): ... +@_dispatch def intersection_all(graphs): ... diff --git a/stubs/networkx/networkx/algorithms/operators/binary.pyi b/stubs/networkx/networkx/algorithms/operators/binary.pyi index 37cf06498..14bab95cd 100644 --- a/stubs/networkx/networkx/algorithms/operators/binary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/binary.pyi @@ -3,10 +3,15 @@ from collections.abc import Hashable from typing import TypeVar from networkx.classes.digraph import DiGraph +from networkx.utils.backends import _dispatch +@_dispatch def disjoint_union(G, H): ... +@_dispatch def intersection(G, H): ... +@_dispatch def difference(G, H): ... +@_dispatch def symmetric_difference(G, H): ... _X = TypeVar("_X", bound=Hashable, covariant=True) @@ -14,5 +19,7 @@ _Y = TypeVar("_Y", bound=Hashable, covariant=True) # GT = TypeVar('GT', bound=Graph[_Node]) # TODO: This does not handle the cases when graphs of different types are passed which is allowed +@_dispatch def compose(G: DiGraph[_X], H: DiGraph[_Y]) -> DiGraph[_X | _Y]: ... +@_dispatch def union(G: DiGraph[_X], H: DiGraph[_Y], rename: Incomplete = ()) -> DiGraph[_X | _Y]: ... diff --git a/stubs/networkx/networkx/algorithms/operators/product.pyi b/stubs/networkx/networkx/algorithms/operators/product.pyi index 8a3694580..e7dc28a4e 100644 --- a/stubs/networkx/networkx/algorithms/operators/product.pyi +++ b/stubs/networkx/networkx/algorithms/operators/product.pyi @@ -1,7 +1,16 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def tensor_product(G, H): ... +@_dispatch def cartesian_product(G, H): ... +@_dispatch def lexicographic_product(G, H): ... +@_dispatch def strong_product(G, H): ... +@_dispatch def power(G, k): ... +@_dispatch def rooted_product(G, H, root): ... +@_dispatch def corona_product(G, H): ... diff --git a/stubs/networkx/networkx/algorithms/operators/unary.pyi b/stubs/networkx/networkx/algorithms/operators/unary.pyi index 45878fa54..9fe98be94 100644 --- a/stubs/networkx/networkx/algorithms/operators/unary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/unary.pyi @@ -2,8 +2,11 @@ from collections.abc import Hashable from typing import TypeVar from networkx.classes.graph import Graph +from networkx.utils.backends import _dispatch _G = TypeVar("_G", bound=Graph[Hashable]) +@_dispatch def complement(G): ... +@_dispatch def reverse(G: _G, copy: bool = True) -> _G: ... diff --git a/stubs/networkx/networkx/algorithms/planar_drawing.pyi b/stubs/networkx/networkx/algorithms/planar_drawing.pyi index 328b776bb..315cc41d1 100644 --- a/stubs/networkx/networkx/algorithms/planar_drawing.pyi +++ b/stubs/networkx/networkx/algorithms/planar_drawing.pyi @@ -1 +1,4 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def combinatorial_embedding_to_pos(embedding, fully_triangulate: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index 9a3d14db0..3bbf80340 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -3,10 +3,13 @@ from collections.abc import Generator, Mapping, MutableSet, Reversible from networkx.classes.digraph import DiGraph from networkx.classes.graph import _Node +from networkx.utils.backends import _dispatch __all__ = ["check_planarity", "is_planar", "PlanarEmbedding"] +@_dispatch def is_planar(G) -> bool: ... +@_dispatch def check_planarity(G, counterexample: bool = False): ... class Interval: diff --git a/stubs/networkx/networkx/algorithms/polynomials.pyi b/stubs/networkx/networkx/algorithms/polynomials.pyi index bbe5dcfb4..d6f4cb066 100644 --- a/stubs/networkx/networkx/algorithms/polynomials.pyi +++ b/stubs/networkx/networkx/algorithms/polynomials.pyi @@ -1,2 +1,6 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def tutte_polynomial(G): ... +@_dispatch def chromatic_polynomial(G): ... diff --git a/stubs/networkx/networkx/algorithms/reciprocity.pyi b/stubs/networkx/networkx/algorithms/reciprocity.pyi index cb181dd09..56195c752 100644 --- a/stubs/networkx/networkx/algorithms/reciprocity.pyi +++ b/stubs/networkx/networkx/algorithms/reciprocity.pyi @@ -1,4 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def reciprocity(G, nodes: Incomplete | None = None): ... +@_dispatch def overall_reciprocity(G): ... diff --git a/stubs/networkx/networkx/algorithms/regular.pyi b/stubs/networkx/networkx/algorithms/regular.pyi index 751e5cc78..7a0be2130 100644 --- a/stubs/networkx/networkx/algorithms/regular.pyi +++ b/stubs/networkx/networkx/algorithms/regular.pyi @@ -1,3 +1,8 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def is_regular(G): ... +@_dispatch def is_k_regular(G, k): ... +@_dispatch def k_factor(G, k, matching_weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/richclub.pyi b/stubs/networkx/networkx/algorithms/richclub.pyi index 5e7903e19..b7da6c2db 100644 --- a/stubs/networkx/networkx/algorithms/richclub.pyi +++ b/stubs/networkx/networkx/algorithms/richclub.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def rich_club_coefficient(G, normalized: bool = True, Q: float = 100, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi index 4394432a7..28a07a518 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi @@ -1,4 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def astar_path(G, source, target, heuristic: Incomplete | None = None, weight: str = "weight"): ... +@_dispatch def astar_path_length(G, source, target, heuristic: Incomplete | None = None, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi index a931da0ec..fc7b12cb8 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi @@ -1,6 +1,12 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def floyd_warshall_numpy(G, nodelist: Incomplete | None = None, weight: str = "weight"): ... +@_dispatch def floyd_warshall_predecessor_and_distance(G, weight: str = "weight"): ... +@_dispatch def reconstruct_path(source, target, predecessors): ... +@_dispatch def floyd_warshall(G, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi index 4c60b9483..e28fb643a 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi @@ -3,7 +3,9 @@ from collections.abc import Generator from typing import overload from networkx.classes.graph import Graph, _Node +from networkx.utils.backends import _dispatch +@_dispatch def has_path(G, source, target): ... @overload def shortest_path( @@ -13,6 +15,7 @@ def shortest_path( def shortest_path(G: Graph[_Node], target: _Node, method: str = "dijkstra") -> dict[_Node, list[_Node]]: ... @overload def shortest_path(G: Graph[_Node], source: _Node, method: str = "dijkstra") -> dict[_Node, list[_Node]]: ... +@_dispatch def shortest_path_length( G, source: Incomplete | None = None, @@ -20,7 +23,9 @@ def shortest_path_length( weight: Incomplete | None = None, method: str = "dijkstra", ): ... +@_dispatch def average_shortest_path_length(G, weight: Incomplete | None = None, method: str | None = None): ... +@_dispatch def all_shortest_paths( G: Graph[_Node], source: _Node, target: _Node, weight: Incomplete | None = None, method: str = "dijkstra" ) -> Generator[list[_Node], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi index 706c04a6d..b9505baa8 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi @@ -1,13 +1,23 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def single_source_shortest_path_length(G, source, cutoff: Incomplete | None = None): ... +@_dispatch def single_target_shortest_path_length(G, target, cutoff: Incomplete | None = None): ... +@_dispatch def all_pairs_shortest_path_length(G, cutoff: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... +@_dispatch def bidirectional_shortest_path(G, source, target): ... +@_dispatch def single_source_shortest_path(G, source, cutoff: Incomplete | None = None): ... +@_dispatch def single_target_shortest_path(G, target, cutoff: Incomplete | None = None): ... +@_dispatch def all_pairs_shortest_path(G, cutoff: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... +@_dispatch def predecessor( G, source, target: Incomplete | None = None, cutoff: Incomplete | None = None, return_seen: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi index 43bcb9a50..3f7ce7a47 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi @@ -1,36 +1,63 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def dijkstra_path(G, source, target, weight: str = "weight"): ... +@_dispatch def dijkstra_path_length(G, source, target, weight: str = "weight"): ... +@_dispatch def single_source_dijkstra_path(G, source, cutoff: Incomplete | None = None, weight: str = "weight"): ... +@_dispatch def single_source_dijkstra_path_length(G, source, cutoff: Incomplete | None = None, weight: str = "weight"): ... +@_dispatch def single_source_dijkstra( G, source, target: Incomplete | None = None, cutoff: Incomplete | None = None, weight: str = "weight" ): ... +@_dispatch def multi_source_dijkstra_path(G, sources, cutoff: Incomplete | None = None, weight: str = "weight"): ... +@_dispatch def multi_source_dijkstra_path_length(G, sources, cutoff: Incomplete | None = None, weight: str = "weight"): ... +@_dispatch def multi_source_dijkstra( G, sources, target: Incomplete | None = None, cutoff: Incomplete | None = None, weight: str = "weight" ): ... +@_dispatch def dijkstra_predecessor_and_distance(G, source, cutoff: Incomplete | None = None, weight: str = "weight"): ... +@_dispatch def all_pairs_dijkstra(G, cutoff: Incomplete | None = None, weight: str = "weight") -> Generator[Incomplete, None, None]: ... +@_dispatch def all_pairs_dijkstra_path_length( G, cutoff: Incomplete | None = None, weight: str = "weight" ) -> Generator[Incomplete, None, None]: ... +@_dispatch def all_pairs_dijkstra_path(G, cutoff: Incomplete | None = None, weight: str = "weight") -> Generator[Incomplete, None, None]: ... +@_dispatch def bellman_ford_predecessor_and_distance( G, source, target: Incomplete | None = None, weight: str = "weight", heuristic: bool = False ): ... +@_dispatch def bellman_ford_path(G, source, target, weight: str = "weight"): ... +@_dispatch def bellman_ford_path_length(G, source, target, weight: str = "weight"): ... +@_dispatch def single_source_bellman_ford_path(G, source, weight: str = "weight"): ... +@_dispatch def single_source_bellman_ford_path_length(G, source, weight: str = "weight"): ... +@_dispatch def single_source_bellman_ford(G, source, target: Incomplete | None = None, weight: str = "weight"): ... +@_dispatch def all_pairs_bellman_ford_path_length(G, weight: str = "weight") -> Generator[Incomplete, None, None]: ... +@_dispatch def all_pairs_bellman_ford_path(G, weight: str = "weight") -> Generator[Incomplete, None, None]: ... +@_dispatch def goldberg_radzik(G, source, weight: str = "weight"): ... +@_dispatch def negative_edge_cycle(G, weight: str = "weight", heuristic: bool = True): ... +@_dispatch def find_negative_cycle(G, source, weight: str = "weight"): ... +@_dispatch def bidirectional_dijkstra(G, source, target, weight: str = "weight"): ... +@_dispatch def johnson(G, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/similarity.pyi b/stubs/networkx/networkx/algorithms/similarity.pyi index f18150d09..dbd0e036d 100644 --- a/stubs/networkx/networkx/algorithms/similarity.pyi +++ b/stubs/networkx/networkx/algorithms/similarity.pyi @@ -1,6 +1,9 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def graph_edit_distance( G1, G2, @@ -16,6 +19,7 @@ def graph_edit_distance( upper_bound: Incomplete | None = None, timeout: Incomplete | None = None, ): ... +@_dispatch def optimal_edit_paths( G1, G2, @@ -29,6 +33,7 @@ def optimal_edit_paths( edge_ins_cost: Incomplete | None = None, upper_bound: Incomplete | None = None, ): ... +@_dispatch def optimize_graph_edit_distance( G1, G2, @@ -42,6 +47,7 @@ def optimize_graph_edit_distance( edge_ins_cost: Incomplete | None = None, upper_bound: Incomplete | None = None, ) -> Generator[Incomplete, None, None]: ... +@_dispatch def optimize_edit_paths( G1, G2, @@ -58,6 +64,7 @@ def optimize_edit_paths( roots: Incomplete | None = None, timeout: Incomplete | None = None, ) -> Generator[Incomplete, None, Incomplete]: ... +@_dispatch def simrank_similarity( G, source: Incomplete | None = None, @@ -66,9 +73,11 @@ def simrank_similarity( max_iterations: int = 1000, tolerance: float = 0.0001, ): ... +@_dispatch def panther_similarity( G, source, k: int = 5, path_length: int = 5, c: float = 0.5, delta: float = 0.1, eps: Incomplete | None = None ): ... +@_dispatch def generate_random_paths( G, sample_size, path_length: int = 5, index_map: Incomplete | None = None ) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/simple_paths.pyi b/stubs/networkx/networkx/algorithms/simple_paths.pyi index 46b3d643a..292bf9d57 100644 --- a/stubs/networkx/networkx/algorithms/simple_paths.pyi +++ b/stubs/networkx/networkx/algorithms/simple_paths.pyi @@ -2,16 +2,21 @@ from _typeshed import Incomplete from collections.abc import Generator, Sequence from networkx.classes.graph import Graph, _Node +from networkx.utils.backends import _dispatch __all__ = ["all_simple_paths", "is_simple_path", "shortest_simple_paths", "all_simple_edge_paths"] +@_dispatch def is_simple_path(G: Graph[_Node], nodes: Sequence[_Node]): ... +@_dispatch def all_simple_paths( G: Graph[_Node], source: _Node, target: _Node, cutoff: Incomplete | None = None ) -> Generator[list[_Node], None, None]: ... +@_dispatch def all_simple_edge_paths( G: Graph[_Node], source: _Node, target: _Node, cutoff: Incomplete | None = None ) -> Generator[list[_Node] | list[tuple[_Node, _Node]], None, list[_Node] | None]: ... +@_dispatch def shortest_simple_paths( G: Graph[_Node], source: _Node, target: _Node, weight: Incomplete | None = None ) -> Generator[list[_Node], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/smallworld.pyi b/stubs/networkx/networkx/algorithms/smallworld.pyi index baa6acb25..eb1a8c653 100644 --- a/stubs/networkx/networkx/algorithms/smallworld.pyi +++ b/stubs/networkx/networkx/algorithms/smallworld.pyi @@ -1,8 +1,14 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def random_reference(G, niter: int = 1, connectivity: bool = True, seed: Incomplete | None = None): ... +@_dispatch def lattice_reference( G, niter: int = 5, D: Incomplete | None = None, connectivity: bool = True, seed: Incomplete | None = None ): ... +@_dispatch def sigma(G, niter: int = 100, nrand: int = 10, seed: Incomplete | None = None): ... +@_dispatch def omega(G, niter: int = 5, nrand: int = 10, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/smetric.pyi b/stubs/networkx/networkx/algorithms/smetric.pyi index 1a312747a..c1104f532 100644 --- a/stubs/networkx/networkx/algorithms/smetric.pyi +++ b/stubs/networkx/networkx/algorithms/smetric.pyi @@ -1 +1,4 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def s_metric(G, normalized: bool = True): ... diff --git a/stubs/networkx/networkx/algorithms/sparsifiers.pyi b/stubs/networkx/networkx/algorithms/sparsifiers.pyi index 6c37f8125..b03b832f4 100644 --- a/stubs/networkx/networkx/algorithms/sparsifiers.pyi +++ b/stubs/networkx/networkx/algorithms/sparsifiers.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def spanner(G, stretch, weight: Incomplete | None = None, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/structuralholes.pyi b/stubs/networkx/networkx/algorithms/structuralholes.pyi index c1f587134..30edb0f2c 100644 --- a/stubs/networkx/networkx/algorithms/structuralholes.pyi +++ b/stubs/networkx/networkx/algorithms/structuralholes.pyi @@ -1,5 +1,10 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def effective_size(G, nodes: Incomplete | None = None, weight: Incomplete | None = None): ... +@_dispatch def constraint(G, nodes: Incomplete | None = None, weight: Incomplete | None = None): ... +@_dispatch def local_constraint(G, u, v, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/summarization.pyi b/stubs/networkx/networkx/algorithms/summarization.pyi index 0477d1f70..c871b7efd 100644 --- a/stubs/networkx/networkx/algorithms/summarization.pyi +++ b/stubs/networkx/networkx/algorithms/summarization.pyi @@ -1,6 +1,10 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def dedensify(G, threshold, prefix: Incomplete | None = None, copy: bool = True): ... +@_dispatch def snap_aggregation( G, node_attributes, diff --git a/stubs/networkx/networkx/algorithms/swap.pyi b/stubs/networkx/networkx/algorithms/swap.pyi index 1c640e406..f11235573 100644 --- a/stubs/networkx/networkx/algorithms/swap.pyi +++ b/stubs/networkx/networkx/algorithms/swap.pyi @@ -1,5 +1,10 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def directed_edge_swap(G, *, nswap: int = 1, max_tries: int = 100, seed: Incomplete | None = None): ... +@_dispatch def double_edge_swap(G, nswap: int = 1, max_tries: int = 100, seed: Incomplete | None = None): ... +@_dispatch def connected_double_edge_swap(G, nswap: int = 1, _window_threshold: int = 3, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/threshold.pyi b/stubs/networkx/networkx/algorithms/threshold.pyi index dedeb06d5..f1fb06058 100644 --- a/stubs/networkx/networkx/algorithms/threshold.pyi +++ b/stubs/networkx/networkx/algorithms/threshold.pyi @@ -1,4 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def is_threshold_graph(G): ... +@_dispatch def find_threshold_graph(G, create_using: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/tournament.pyi b/stubs/networkx/networkx/algorithms/tournament.pyi index 5fe9745bc..21eb5721a 100644 --- a/stubs/networkx/networkx/algorithms/tournament.pyi +++ b/stubs/networkx/networkx/algorithms/tournament.pyi @@ -1,8 +1,16 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def is_tournament(G): ... +@_dispatch def hamiltonian_path(G): ... +@_dispatch def random_tournament(n, seed: Incomplete | None = None): ... +@_dispatch def score_sequence(G): ... +@_dispatch def is_reachable(G, s, t): ... +@_dispatch def is_strongly_connected(G): ... diff --git a/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi b/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi index caad5b0b1..4db534c6d 100644 --- a/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi @@ -1,4 +1,7 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def bfs_beam_edges(G, source, value, width: Incomplete | None = None) -> Generator[Incomplete, Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi b/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi index 731b1b5c1..e02ce7e7c 100644 --- a/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi @@ -1,17 +1,25 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def bfs_edges( G, source, reverse: bool = False, depth_limit: Incomplete | None = None, sort_neighbors: Incomplete | None = None ) -> Generator[Incomplete, Incomplete, None]: ... +@_dispatch def bfs_tree( G, source, reverse: bool = False, depth_limit: Incomplete | None = None, sort_neighbors: Incomplete | None = None ): ... +@_dispatch def bfs_predecessors( G, source, depth_limit: Incomplete | None = None, sort_neighbors: Incomplete | None = None ) -> Generator[Incomplete, None, None]: ... +@_dispatch def bfs_successors( G, source, depth_limit: Incomplete | None = None, sort_neighbors: Incomplete | None = None ) -> Generator[Incomplete, None, None]: ... +@_dispatch def bfs_layers(G, sources) -> Generator[Incomplete, None, None]: ... +@_dispatch def descendants_at_distance(G, source, distance): ... diff --git a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi index f7bdc54f0..7a45dcd38 100644 --- a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi @@ -2,13 +2,21 @@ from _typeshed import Incomplete from collections.abc import Generator from networkx.classes.graph import Graph, _Node +from networkx.utils.backends import _dispatch +@_dispatch def dfs_edges( G: Graph[_Node], source: _Node | None = None, depth_limit: int | None = None ) -> Generator[tuple[_Node, _Node], None, None]: ... +@_dispatch def dfs_tree(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... +@_dispatch def dfs_predecessors(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... +@_dispatch def dfs_successors(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... +@_dispatch def dfs_postorder_nodes(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... +@_dispatch def dfs_preorder_nodes(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... +@_dispatch def dfs_labeled_edges(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi b/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi index 2220d26ff..91992a617 100644 --- a/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi @@ -1,6 +1,9 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def edge_bfs( G, source: Incomplete | None = None, orientation: Incomplete | None = None ) -> Generator[Incomplete, None, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi b/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi index 8c7dc084e..8d4ad7ec1 100644 --- a/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi @@ -1,6 +1,9 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def edge_dfs( G, source: Incomplete | None = None, orientation: Incomplete | None = None ) -> Generator[Incomplete, None, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi index 4d4e5bcfe..0758083b4 100644 --- a/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -4,6 +4,7 @@ from dataclasses import dataclass from networkx.classes.graph import _Node from networkx.classes.multidigraph import MultiDiGraph +from networkx.utils.backends import _dispatch __all__ = [ "branching_weight", @@ -16,7 +17,9 @@ __all__ = [ "Edmonds", ] +@_dispatch def branching_weight(G, attr: str = "weight", default: float = 1): ... +@_dispatch def greedy_branching(G, attr: str = "weight", default: float = 1, kind: str = "max", seed: Incomplete | None = None): ... class MultiDiGraph_EdgeKey(MultiDiGraph[_Node]): @@ -46,15 +49,19 @@ class Edmonds: seed: Incomplete | None = None, ): ... +@_dispatch def maximum_branching( G, attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: Incomplete | None = None ): ... +@_dispatch def minimum_branching( G, attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: Incomplete | None = None ): ... +@_dispatch def maximum_spanning_arborescence( G, attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: Incomplete | None = None ): ... +@_dispatch def minimum_spanning_arborescence( G, attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/tree/coding.pyi b/stubs/networkx/networkx/algorithms/tree/coding.pyi index 88cfc57bd..aaf585c35 100644 --- a/stubs/networkx/networkx/algorithms/tree/coding.pyi +++ b/stubs/networkx/networkx/algorithms/tree/coding.pyi @@ -1,8 +1,13 @@ from networkx.exception import NetworkXException +from networkx.utils.backends import _dispatch class NotATree(NetworkXException): ... +@_dispatch def to_nested_tuple(T, root, canonical_form: bool = False): ... +@_dispatch def from_nested_tuple(sequence, sensible_relabeling: bool = False): ... +@_dispatch def to_prufer_sequence(T): ... +@_dispatch def from_prufer_sequence(sequence): ... diff --git a/stubs/networkx/networkx/algorithms/tree/decomposition.pyi b/stubs/networkx/networkx/algorithms/tree/decomposition.pyi index bbafb2a06..ea14d081b 100644 --- a/stubs/networkx/networkx/algorithms/tree/decomposition.pyi +++ b/stubs/networkx/networkx/algorithms/tree/decomposition.pyi @@ -1 +1,4 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def junction_tree(G): ... diff --git a/stubs/networkx/networkx/algorithms/tree/mst.pyi b/stubs/networkx/networkx/algorithms/tree/mst.pyi index 5ab610c69..860063406 100644 --- a/stubs/networkx/networkx/algorithms/tree/mst.pyi +++ b/stubs/networkx/networkx/algorithms/tree/mst.pyi @@ -3,22 +3,30 @@ from collections.abc import Iterator from dataclasses import dataclass from enum import Enum +from networkx.utils.backends import _dispatch + class EdgePartition(Enum): OPEN = 0 INCLUDED = 1 EXCLUDED = 2 +@_dispatch def minimum_spanning_edges( G, algorithm: str = "kruskal", weight: str = "weight", keys: bool = True, data: bool = True, ignore_nan: bool = False ): ... +@_dispatch def maximum_spanning_edges( G, algorithm: str = "kruskal", weight: str = "weight", keys: bool = True, data: bool = True, ignore_nan: bool = False ): ... +@_dispatch def minimum_spanning_tree(G, weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False): ... +@_dispatch def partition_spanning_tree( G, minimum: bool = True, weight: str = "weight", partition: str = "partition", ignore_nan: bool = False ): ... +@_dispatch def maximum_spanning_tree(G, weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False): ... +@_dispatch def random_spanning_tree(G, weight: Incomplete | None = None, *, multiplicative: bool = True, seed: Incomplete | None = None): ... class SpanningTreeIterator: diff --git a/stubs/networkx/networkx/algorithms/tree/operations.pyi b/stubs/networkx/networkx/algorithms/tree/operations.pyi index c6e5dcf58..712f9f546 100644 --- a/stubs/networkx/networkx/algorithms/tree/operations.pyi +++ b/stubs/networkx/networkx/algorithms/tree/operations.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def join(rooted_trees, label_attribute: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/tree/recognition.pyi b/stubs/networkx/networkx/algorithms/tree/recognition.pyi index e73e010c2..49b318a85 100644 --- a/stubs/networkx/networkx/algorithms/tree/recognition.pyi +++ b/stubs/networkx/networkx/algorithms/tree/recognition.pyi @@ -1,4 +1,10 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def is_arborescence(G): ... +@_dispatch def is_branching(G): ... +@_dispatch def is_forest(G): ... +@_dispatch def is_tree(G): ... diff --git a/stubs/networkx/networkx/algorithms/triads.pyi b/stubs/networkx/networkx/algorithms/triads.pyi index 860f407d2..c3b4eeba4 100644 --- a/stubs/networkx/networkx/algorithms/triads.pyi +++ b/stubs/networkx/networkx/algorithms/triads.pyi @@ -1,10 +1,19 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def triadic_census(G, nodelist: Incomplete | None = None): ... +@_dispatch def is_triad(G): ... +@_dispatch def all_triplets(G): ... +@_dispatch def all_triads(G) -> Generator[Incomplete, None, None]: ... +@_dispatch def triads_by_type(G): ... +@_dispatch def triad_type(G): ... +@_dispatch def random_triad(G, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/vitality.pyi b/stubs/networkx/networkx/algorithms/vitality.pyi index 348555a0a..abc5840d5 100644 --- a/stubs/networkx/networkx/algorithms/vitality.pyi +++ b/stubs/networkx/networkx/algorithms/vitality.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def closeness_vitality( G, node: Incomplete | None = None, weight: Incomplete | None = None, wiener_index: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/voronoi.pyi b/stubs/networkx/networkx/algorithms/voronoi.pyi index bb79ac621..baefb2ea7 100644 --- a/stubs/networkx/networkx/algorithms/voronoi.pyi +++ b/stubs/networkx/networkx/algorithms/voronoi.pyi @@ -1 +1,4 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def voronoi_cells(G, center_nodes, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/wiener.pyi b/stubs/networkx/networkx/algorithms/wiener.pyi index 5cfbf599e..dbafb2128 100644 --- a/stubs/networkx/networkx/algorithms/wiener.pyi +++ b/stubs/networkx/networkx/algorithms/wiener.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def wiener_index(G, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/classes/__init__.pyi b/stubs/networkx/networkx/classes/__init__.pyi index 1289c8a1c..a0bf8d86e 100644 --- a/stubs/networkx/networkx/classes/__init__.pyi +++ b/stubs/networkx/networkx/classes/__init__.pyi @@ -1,10 +1,4 @@ -from . import ( - backends as backends, - coreviews as coreviews, - filters as filters, - graphviews as graphviews, - reportviews as reportviews, -) +from . import coreviews as coreviews, filters as filters, graphviews as graphviews, reportviews as reportviews from .digraph import DiGraph as DiGraph from .function import * from .graph import Graph as Graph diff --git a/stubs/networkx/networkx/classes/backends.pyi b/stubs/networkx/networkx/classes/backends.pyi deleted file mode 100644 index 3d488f4b6..000000000 --- a/stubs/networkx/networkx/classes/backends.pyi +++ /dev/null @@ -1,15 +0,0 @@ -from _typeshed import Incomplete -from collections.abc import Callable - -__all__ = ["_dispatch", "_mark_tests"] - -class PluginInfo: - def __init__(self) -> None: ... - def __bool__(self) -> bool: ... - @property - def items(self): ... - def __contains__(self, name) -> bool: ... - def __getitem__(self, name): ... - -def _dispatch(func: Incomplete | None = None, *, name: Incomplete | None = None) -> Callable[..., Incomplete]: ... -def _mark_tests(items) -> None: ... diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index 03a822286..145713b36 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -5,7 +5,6 @@ from typing import Literal, TypeVar, overload from networkx.algorithms.planarity import PlanarEmbedding from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _NBunch, _Node -from networkx.classes.graphviews import reverse_view as reverse_view, subgraph_view as subgraph_view from networkx.classes.multigraph import MultiGraph __all__ = [ @@ -21,9 +20,7 @@ __all__ = [ "freeze", "is_frozen", "subgraph", - "subgraph_view", "induced_subgraph", - "reverse_view", "edge_subgraph", "restricted_view", "to_directed", @@ -87,14 +84,14 @@ def set_node_attributes( values: SupportsItems[_Node, SupportsKeysAndGetItem[Incomplete, Incomplete] | Iterable[tuple[Incomplete, Incomplete]]], name: None = None, ) -> None: ... -def get_node_attributes(G: Graph[_Node], name: str) -> dict[_Node, Incomplete]: ... +def get_node_attributes(G: Graph[_Node], name: str, default=None) -> dict[_Node, Incomplete]: ... @overload def set_edge_attributes(G: Graph[_Node], values: SupportsItems[tuple[_Node, _Node], Incomplete], name: str) -> None: ... @overload def set_edge_attributes(G: MultiGraph[_Node], values: dict[tuple[_Node, _Node, Incomplete], Incomplete], name: str) -> None: ... @overload def set_edge_attributes(G: Graph[Hashable], values, name: None = None) -> None: ... -def get_edge_attributes(G: Graph[_Node], name: str) -> dict[tuple[_Node, _Node], Incomplete]: ... +def get_edge_attributes(G: Graph[_Node], name: str, default=None) -> dict[tuple[_Node, _Node], Incomplete]: ... def all_neighbors(graph: Graph[_Node], node: _Node) -> Iterator[_Node]: ... def non_neighbors(graph: Graph[_Node], node: _Node) -> Generator[_Node, None, None]: ... def non_edges(graph: Graph[_Node]) -> Generator[tuple[_Node, _Node], None, None]: ... diff --git a/stubs/networkx/networkx/classes/graphviews.pyi b/stubs/networkx/networkx/classes/graphviews.pyi index 91ce48ad8..798eed572 100644 --- a/stubs/networkx/networkx/classes/graphviews.pyi +++ b/stubs/networkx/networkx/classes/graphviews.pyi @@ -21,18 +21,18 @@ def generic_graph_view(G: Graph[_Node], create_using: type[MultiGraph[_Node]]) - def generic_graph_view(G: Graph[_Node], create_using: type[Graph[_Node]]) -> Graph[_Node]: ... @overload def subgraph_view( - G: MultiDiGraph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_Node, _Node, int], bool] = ... + G: MultiDiGraph[_Node], *, filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_Node, _Node, int], bool] = ... ) -> MultiDiGraph[_Node]: ... @overload def subgraph_view( - G: MultiGraph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_Node, _Node, int], bool] = ... + G: MultiGraph[_Node], *, filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_Node, _Node, int], bool] = ... ) -> MultiGraph[_Node]: ... @overload def subgraph_view( - G: DiGraph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_Node, _Node], bool] = ... + G: DiGraph[_Node], *, filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_Node, _Node], bool] = ... ) -> DiGraph[_Node]: ... @overload def subgraph_view( - G: Graph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_Node, _Node], bool] = ... + G: Graph[_Node], *, filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_Node, _Node], bool] = ... ) -> Graph[_Node]: ... def reverse_view(G: _D) -> _D: ... diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index 6a8c34d81..35e5d9f16 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -43,7 +43,9 @@ class InMultiDegreeView(DiDegreeView[_Node]): ... class OutMultiDegreeView(DiDegreeView[_Node]): ... class OutEdgeDataView(Generic[_Node, _D]): - def __init__(self, viewer, nbunch: _NBunch[_Node] = None, data: bool = False, default: Incomplete | None = None) -> None: ... + def __init__( + self, viewer, nbunch: _NBunch[_Node] = None, data: bool = False, *, default: Incomplete | None = None + ) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_D]: ... def __contains__(self, e: _Edge[_Node]) -> bool: ... @@ -53,7 +55,7 @@ class InEdgeDataView(OutEdgeDataView[_Node, _D]): ... class OutMultiEdgeDataView(OutEdgeDataView[_Node, _D]): def __init__( - self, viewer, nbunch: _NBunch[_Node] = None, data: bool = False, keys: bool = False, default: Incomplete | None = None + self, viewer, nbunch: _NBunch[_Node] = None, data: bool = False, *, default: Incomplete | None = None, keys: bool = False ) -> None: ... class MultiEdgeDataView(OutEdgeDataView[_Node, _D]): ... @@ -66,10 +68,10 @@ class OutEdgeView(AbstractSet[Incomplete], Mapping[Incomplete, Incomplete], Gene def __contains__(self, e: _Edge[_Node]) -> bool: ... # type: ignore[override] def __getitem__(self, e: _Edge[_Node]) -> dict[str, Any]: ... @overload - def __call__(self, nbunch: None = None, data: Literal[False] = False, default: Unused = None) -> Self: ... + def __call__(self, nbunch: None = None, data: Literal[False] = False, *, default: Unused = None) -> Self: ... @overload def __call__( - self, nbunch: _NBunch[_Node], data: Literal[True], default: None = None + self, nbunch: _NBunch[_Node], data: Literal[True], *, default: None = None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... @overload def __call__( @@ -77,7 +79,7 @@ class OutEdgeView(AbstractSet[Incomplete], Mapping[Incomplete, Incomplete], Gene ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... @overload def __call__( - self, nbunch: _NBunch[_Node], data: str, default: _U | None = None + self, nbunch: _NBunch[_Node], data: str, *, default: _U | None = None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... @overload def __call__( @@ -100,35 +102,33 @@ class InEdgeView(OutEdgeView[_Node]): ... class OutMultiEdgeView(OutEdgeView[_Node]): @overload # type: ignore[override] # Has an additional `keys` keyword argument def __call__( - self, nbunch: None = None, data: Literal[False] = False, *, keys: Literal[True], default: Unused = None + self, nbunch: None = None, data: Literal[False] = False, *, default: Unused = None, keys: Literal[True] ) -> Self: ... @overload - def __call__(self, nbunch: None, data: Literal[False], keys: Literal[True], default: Unused = None) -> Self: ... - @overload def __call__( - self, nbunch: _NBunch[_Node], data: Literal[True], keys: bool = False, default: None = None + self, nbunch: _NBunch[_Node], data: Literal[True], *, default: None = None, keys: bool = False ) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... @overload def __call__( - self, nbunch: _NBunch[_Node] = None, *, data: Literal[True], keys: bool = False, default: None = None + self, nbunch: _NBunch[_Node] = None, *, data: Literal[True], default: None = None, keys: bool = False ) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... @overload def __call__( - self, nbunch: _NBunch[_Node], data: str, keys: bool = False, default: _U | None = None + self, nbunch: _NBunch[_Node], data: str, *, default: _U | None = None, keys: bool = False ) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... @overload def __call__( - self, nbunch: _NBunch[_Node] = None, *, data: str, keys: bool = False, default: _U | None = None + self, nbunch: _NBunch[_Node] = None, *, data: str, default: _U | None = None, keys: bool = False ) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... - @overload # type: ignore[override] # Has an additional `keys` keyword argument - def data(self, data: Literal[False], keys: Literal[False] = False, default: Unused = None, nbunch: None = None) -> Self: ... + @overload + def data(self, data: Literal[False], default: Unused = None, nbunch: None = None, keys: Literal[False] = False) -> Self: ... @overload def data( - self, data: Literal[True] = True, keys: bool = False, default: None = None, nbunch: _NBunch[_Node] = None + self, data: Literal[True] = True, default: None = None, nbunch: _NBunch[_Node] = None, keys: bool = False ) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... @overload def data( - self, data: str, keys: bool = False, default: _U | None = None, nbunch: _NBunch[_Node] = None + self, data: str, default: _U | None = None, nbunch: _NBunch[_Node] = None, keys: bool = False ) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... class MultiEdgeView(OutMultiEdgeView[_Node]): ... diff --git a/stubs/networkx/networkx/convert.pyi b/stubs/networkx/networkx/convert.pyi index b72526598..0b4ea4daf 100644 --- a/stubs/networkx/networkx/convert.pyi +++ b/stubs/networkx/networkx/convert.pyi @@ -2,6 +2,7 @@ from _typeshed import Incomplete from collections.abc import Callable, Iterable from networkx.classes.graph import Graph, _Data, _Node +from networkx.utils.backends import _dispatch __all__ = [ "to_networkx_graph", @@ -16,9 +17,14 @@ __all__ = [ def to_networkx_graph( data: _Data[_Node], create_using: Graph[_Node] | Callable[[], Graph[_Node]] | None = None, multigraph_input: bool = False ) -> Graph[_Node]: ... +@_dispatch def to_dict_of_lists(G: Graph[_Node], nodelist: None | Iterable[_Node] = None) -> dict[_Node, list[_Node]]: ... +@_dispatch def from_dict_of_lists(d: dict[_Node, Iterable[_Node]], create_using: Incomplete | None = None) -> Incomplete: ... def to_dict_of_dicts(G, nodelist=None, edge_data=None) -> dict[Incomplete, Incomplete]: ... +@_dispatch def from_dict_of_dicts(d, create_using=None, multigraph_input=False): ... +@_dispatch def to_edgelist(G, nodelist=None): ... +@_dispatch def from_edgelist(edgelist, create_using=None): ... diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index 4cbcb69d7..4b508a7b5 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -5,6 +5,7 @@ from typing_extensions import TypeAlias import numpy from networkx.classes.graph import Graph, _Node +from networkx.utils.backends import _dispatch # stub_uploader won't allow pandas-stubs in the requires field https://github.com/typeshed-internal/stub_uploader/issues/90 # from pandas import DataFrame @@ -16,6 +17,7 @@ _ExtensionDtype: TypeAlias = Incomplete _Axes: TypeAlias = Collection[_Node] _G = TypeVar("_G", bound=Graph[Hashable]) +@_dispatch def to_pandas_adjacency( G: Graph[_Node], nodelist: _Axes[_Node] | None = None, @@ -29,6 +31,7 @@ def to_pandas_adjacency( def from_pandas_adjacency(df: _DataFrame, create_using: type[_G]) -> _G: ... @overload def from_pandas_adjacency(df: _DataFrame, create_using: None = None) -> Graph[Incomplete]: ... +@_dispatch def to_pandas_edgelist( G: Graph[_Node], source: str | int = "source", @@ -65,6 +68,7 @@ def from_pandas_edgelist( create_using: None = None, edge_key: str | None = None, ) -> Graph[Incomplete]: ... +@_dispatch def to_numpy_array( G: Graph[_Node], nodelist: Collection[_Node] | None = None, diff --git a/stubs/networkx/networkx/drawing/nx_agraph.pyi b/stubs/networkx/networkx/drawing/nx_agraph.pyi index 732774059..58534aaad 100644 --- a/stubs/networkx/networkx/drawing/nx_agraph.pyi +++ b/stubs/networkx/networkx/drawing/nx_agraph.pyi @@ -4,13 +4,16 @@ from io import TextIOBase from typing_extensions import TypeAlias from networkx.classes.graph import Graph, _Node +from networkx.utils.backends import _dispatch # from pygraphviz.agraph import AGraph as _AGraph _AGraph: TypeAlias = Incomplete +@_dispatch def from_agraph(A, create_using: Incomplete | None = None) -> Graph[Incomplete]: ... def to_agraph(N: Graph[Hashable]) -> _AGraph: ... def write_dot(G: Graph[Hashable], path: str | TextIOBase) -> None: ... +@_dispatch def read_dot(path: str | TextIOBase) -> Graph[Incomplete]: ... def graphviz_layout( G: Graph[_Node], prog: str = "neato", root: str | None = None, args: str = "" diff --git a/stubs/networkx/networkx/drawing/nx_pydot.pyi b/stubs/networkx/networkx/drawing/nx_pydot.pyi index bdd3931ef..7a37ceabc 100644 --- a/stubs/networkx/networkx/drawing/nx_pydot.pyi +++ b/stubs/networkx/networkx/drawing/nx_pydot.pyi @@ -1,7 +1,11 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + def write_dot(G, path) -> None: ... +@_dispatch def read_dot(path): ... +@_dispatch def from_pydot(P): ... def to_pydot(N): ... def graphviz_layout(G, prog: str = "neato", root: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/atlas.pyi b/stubs/networkx/networkx/generators/atlas.pyi index 568996e5c..3c6ab78a4 100644 --- a/stubs/networkx/networkx/generators/atlas.pyi +++ b/stubs/networkx/networkx/generators/atlas.pyi @@ -1,2 +1,6 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def graph_atlas(i): ... +@_dispatch def graph_atlas_g(): ... diff --git a/stubs/networkx/networkx/generators/classic.pyi b/stubs/networkx/networkx/generators/classic.pyi index 10f573208..5ce9da870 100644 --- a/stubs/networkx/networkx/generators/classic.pyi +++ b/stubs/networkx/networkx/generators/classic.pyi @@ -1,21 +1,42 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def full_rary_tree(r, n, create_using: Incomplete | None = None): ... +@_dispatch def balanced_tree(r, h, create_using: Incomplete | None = None): ... +@_dispatch def barbell_graph(m1, m2, create_using: Incomplete | None = None): ... +@_dispatch def binomial_tree(n, create_using: Incomplete | None = None): ... +@_dispatch def complete_graph(n, create_using: Incomplete | None = None): ... +@_dispatch def circular_ladder_graph(n, create_using: Incomplete | None = None): ... +@_dispatch def circulant_graph(n, offsets, create_using: Incomplete | None = None): ... +@_dispatch def cycle_graph(n, create_using: Incomplete | None = None): ... +@_dispatch def dorogovtsev_goltsev_mendes_graph(n, create_using: Incomplete | None = None): ... +@_dispatch def empty_graph(n: Incomplete | int = 0, create_using: Incomplete | None = None, default=...): ... +@_dispatch def ladder_graph(n, create_using: Incomplete | None = None): ... +@_dispatch def lollipop_graph(m, n, create_using: Incomplete | None = None): ... +@_dispatch def null_graph(create_using: Incomplete | None = None): ... +@_dispatch def path_graph(n, create_using: Incomplete | None = None): ... +@_dispatch def star_graph(n, create_using: Incomplete | None = None): ... +@_dispatch def trivial_graph(create_using: Incomplete | None = None): ... +@_dispatch def turan_graph(n, r): ... +@_dispatch def wheel_graph(n, create_using: Incomplete | None = None): ... +@_dispatch def complete_multipartite_graph(*subset_sizes): ... diff --git a/stubs/networkx/networkx/generators/cographs.pyi b/stubs/networkx/networkx/generators/cographs.pyi index 148b1e725..ce3faccf2 100644 --- a/stubs/networkx/networkx/generators/cographs.pyi +++ b/stubs/networkx/networkx/generators/cographs.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def random_cograph(n, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/community.pyi b/stubs/networkx/networkx/generators/community.pyi index 870f9627c..893f3b824 100644 --- a/stubs/networkx/networkx/generators/community.pyi +++ b/stubs/networkx/networkx/generators/community.pyi @@ -1,13 +1,24 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def caveman_graph(l, k): ... +@_dispatch def connected_caveman_graph(l, k): ... +@_dispatch def relaxed_caveman_graph(l, k, p, seed: Incomplete | None = None): ... +@_dispatch def random_partition_graph(sizes, p_in, p_out, seed: Incomplete | None = None, directed: bool = False): ... +@_dispatch def planted_partition_graph(l, k, p_in, p_out, seed: Incomplete | None = None, directed: bool = False): ... +@_dispatch def gaussian_random_partition_graph(n, s, v, p_in, p_out, directed: bool = False, seed: Incomplete | None = None): ... +@_dispatch def ring_of_cliques(num_cliques, clique_size): ... +@_dispatch def windmill_graph(n, k): ... +@_dispatch def stochastic_block_model( sizes, p, @@ -17,6 +28,7 @@ def stochastic_block_model( selfloops: bool = False, sparse: bool = True, ): ... +@_dispatch def LFR_benchmark_graph( n, tau1, diff --git a/stubs/networkx/networkx/generators/degree_seq.pyi b/stubs/networkx/networkx/generators/degree_seq.pyi index c075d6139..73ba1619e 100644 --- a/stubs/networkx/networkx/generators/degree_seq.pyi +++ b/stubs/networkx/networkx/generators/degree_seq.pyi @@ -1,5 +1,7 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + __all__ = [ "configuration_model", "directed_configuration_model", @@ -10,14 +12,21 @@ __all__ = [ "random_degree_sequence_graph", ] +@_dispatch def configuration_model(deg_sequence, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... +@_dispatch def directed_configuration_model( in_degree_sequence, out_degree_sequence, create_using: Incomplete | None = None, seed: Incomplete | None = None ): ... +@_dispatch def expected_degree_graph(w, seed: Incomplete | None = None, selfloops: bool = True): ... +@_dispatch def havel_hakimi_graph(deg_sequence, create_using: Incomplete | None = None): ... +@_dispatch def directed_havel_hakimi_graph(in_deg_sequence, out_deg_sequence, create_using: Incomplete | None = None): ... +@_dispatch def degree_sequence_tree(deg_sequence, create_using: Incomplete | None = None): ... +@_dispatch def random_degree_sequence_graph(sequence, seed: Incomplete | None = None, tries: int = 10): ... class DegreeSequenceRandomGraph: diff --git a/stubs/networkx/networkx/generators/directed.pyi b/stubs/networkx/networkx/generators/directed.pyi index 73a9b62da..9bae0a95b 100644 --- a/stubs/networkx/networkx/generators/directed.pyi +++ b/stubs/networkx/networkx/generators/directed.pyi @@ -1,8 +1,14 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def gn_graph(n, kernel: Incomplete | None = None, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... +@_dispatch def gnr_graph(n, p, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... +@_dispatch def gnc_graph(n, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... +@_dispatch def scale_free_graph( n, alpha: float = 0.41, @@ -14,4 +20,5 @@ def scale_free_graph( seed: Incomplete | None = None, initial_graph: Incomplete | None = None, ): ... +@_dispatch def random_k_out_graph(n, k, alpha, self_loops: bool = True, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/duplication.pyi b/stubs/networkx/networkx/generators/duplication.pyi index 7127ab188..ea7f95cb0 100644 --- a/stubs/networkx/networkx/generators/duplication.pyi +++ b/stubs/networkx/networkx/generators/duplication.pyi @@ -1,4 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def partial_duplication_graph(N, n, p, q, seed: Incomplete | None = None): ... +@_dispatch def duplication_divergence_graph(n, p, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/ego.pyi b/stubs/networkx/networkx/generators/ego.pyi index 509eb94ea..adeb8b300 100644 --- a/stubs/networkx/networkx/generators/ego.pyi +++ b/stubs/networkx/networkx/generators/ego.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def ego_graph(G, n, radius: float = 1, center: bool = True, undirected: bool = False, distance: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/expanders.pyi b/stubs/networkx/networkx/generators/expanders.pyi index 1fed931ba..80c0f30e4 100644 --- a/stubs/networkx/networkx/generators/expanders.pyi +++ b/stubs/networkx/networkx/generators/expanders.pyi @@ -1,5 +1,10 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def margulis_gabber_galil_graph(n, create_using: Incomplete | None = None): ... +@_dispatch def chordal_cycle_graph(p, create_using: Incomplete | None = None): ... +@_dispatch def paley_graph(p, create_using: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/geometric.pyi b/stubs/networkx/networkx/generators/geometric.pyi index aabc39070..0f146cee0 100644 --- a/stubs/networkx/networkx/generators/geometric.pyi +++ b/stubs/networkx/networkx/generators/geometric.pyi @@ -1,9 +1,14 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def geometric_edges(G, radius, p: float = 2): ... +@_dispatch def random_geometric_graph( n, radius, dim: int = 2, pos: Incomplete | None = None, p: float = 2, seed: Incomplete | None = None ): ... +@_dispatch def soft_random_geometric_graph( n, radius, @@ -13,6 +18,7 @@ def soft_random_geometric_graph( p_dist: Incomplete | None = None, seed: Incomplete | None = None, ): ... +@_dispatch def geographical_threshold_graph( n, theta, @@ -23,6 +29,7 @@ def geographical_threshold_graph( p_dist: Incomplete | None = None, seed: Incomplete | None = None, ): ... +@_dispatch def waxman_graph( n, beta: float = 0.4, @@ -34,7 +41,9 @@ def waxman_graph( ): ... # docstring marks p as int, but it still works with floats. So I think it's better for consistency +@_dispatch def navigable_small_world_graph(n, p: float = 1, q: int = 1, r: float = 2, dim: int = 2, seed: Incomplete | None = None): ... +@_dispatch def thresholded_random_geometric_graph( n, radius, diff --git a/stubs/networkx/networkx/generators/harary_graph.pyi b/stubs/networkx/networkx/generators/harary_graph.pyi index ed11de40d..d797ee6ed 100644 --- a/stubs/networkx/networkx/generators/harary_graph.pyi +++ b/stubs/networkx/networkx/generators/harary_graph.pyi @@ -1,4 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def hnm_harary_graph(n, m, create_using: Incomplete | None = None): ... +@_dispatch def hkn_harary_graph(k, n, create_using: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/internet_as_graphs.pyi b/stubs/networkx/networkx/generators/internet_as_graphs.pyi index 060132735..a870d2970 100644 --- a/stubs/networkx/networkx/generators/internet_as_graphs.pyi +++ b/stubs/networkx/networkx/generators/internet_as_graphs.pyi @@ -1,5 +1,7 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + __all__ = ["random_internet_as_graph"] class AS_graph_generator: @@ -35,4 +37,5 @@ class AS_graph_generator: nodes: Incomplete def generate(self): ... +@_dispatch def random_internet_as_graph(n, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/intersection.pyi b/stubs/networkx/networkx/generators/intersection.pyi index 373de5edd..b850ad56c 100644 --- a/stubs/networkx/networkx/generators/intersection.pyi +++ b/stubs/networkx/networkx/generators/intersection.pyi @@ -1,5 +1,10 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def uniform_random_intersection_graph(n, m, p, seed: Incomplete | None = None): ... +@_dispatch def k_random_intersection_graph(n, m, k, seed: Incomplete | None = None): ... +@_dispatch def general_random_intersection_graph(n, m, p, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/interval_graph.pyi b/stubs/networkx/networkx/generators/interval_graph.pyi index b9e29f29b..dd964187d 100644 --- a/stubs/networkx/networkx/generators/interval_graph.pyi +++ b/stubs/networkx/networkx/generators/interval_graph.pyi @@ -1 +1,4 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def interval_graph(intervals): ... diff --git a/stubs/networkx/networkx/generators/joint_degree_seq.pyi b/stubs/networkx/networkx/generators/joint_degree_seq.pyi index 38ee477ce..844df93ef 100644 --- a/stubs/networkx/networkx/generators/joint_degree_seq.pyi +++ b/stubs/networkx/networkx/generators/joint_degree_seq.pyi @@ -1,6 +1,12 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def is_valid_joint_degree(joint_degrees): ... +@_dispatch def joint_degree_graph(joint_degrees, seed: Incomplete | None = None): ... +@_dispatch def is_valid_directed_joint_degree(in_degrees, out_degrees, nkk): ... +@_dispatch def directed_joint_degree_graph(in_degrees, out_degrees, nkk, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/lattice.pyi b/stubs/networkx/networkx/generators/lattice.pyi index 98fa1110c..72205876e 100644 --- a/stubs/networkx/networkx/generators/lattice.pyi +++ b/stubs/networkx/networkx/generators/lattice.pyi @@ -1,11 +1,18 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def grid_2d_graph(m, n, periodic: bool = False, create_using: Incomplete | None = None): ... +@_dispatch def grid_graph(dim, periodic: bool = False): ... +@_dispatch def hypercube_graph(n): ... +@_dispatch def triangular_lattice_graph( m, n, periodic: bool = False, with_positions: bool = True, create_using: Incomplete | None = None ): ... +@_dispatch def hexagonal_lattice_graph( m, n, periodic: bool = False, with_positions: bool = True, create_using: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/generators/line.pyi b/stubs/networkx/networkx/generators/line.pyi index 75ad81cd6..fac54f339 100644 --- a/stubs/networkx/networkx/generators/line.pyi +++ b/stubs/networkx/networkx/generators/line.pyi @@ -1,4 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def line_graph(G, create_using: Incomplete | None = None): ... +@_dispatch def inverse_line_graph(G): ... diff --git a/stubs/networkx/networkx/generators/mycielski.pyi b/stubs/networkx/networkx/generators/mycielski.pyi index 0036c330c..38f2b4957 100644 --- a/stubs/networkx/networkx/generators/mycielski.pyi +++ b/stubs/networkx/networkx/generators/mycielski.pyi @@ -1,2 +1,6 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def mycielskian(G, iterations: int = 1): ... +@_dispatch def mycielski_graph(n): ... diff --git a/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi b/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi index 4ef477bbc..e97bf7838 100644 --- a/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi +++ b/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi @@ -1,5 +1,9 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + +@_dispatch def nonisomorphic_trees(order, create: str = "graph") -> Generator[Incomplete, None, None]: ... +@_dispatch def number_of_nonisomorphic_trees(order): ... diff --git a/stubs/networkx/networkx/generators/random_graphs.pyi b/stubs/networkx/networkx/generators/random_graphs.pyi index 6a075ac2a..f18caa3b8 100644 --- a/stubs/networkx/networkx/generators/random_graphs.pyi +++ b/stubs/networkx/networkx/generators/random_graphs.pyi @@ -1,23 +1,42 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def fast_gnp_random_graph(n, p, seed: Incomplete | None = None, directed: bool = False): ... +@_dispatch def gnp_random_graph(n, p, seed: Incomplete | None = None, directed: bool = False): ... binomial_graph = gnp_random_graph erdos_renyi_graph = gnp_random_graph +@_dispatch def dense_gnm_random_graph(n, m, seed: Incomplete | None = None): ... +@_dispatch def gnm_random_graph(n, m, seed: Incomplete | None = None, directed: bool = False): ... +@_dispatch def newman_watts_strogatz_graph(n, k, p, seed: Incomplete | None = None): ... +@_dispatch def watts_strogatz_graph(n, k, p, seed: Incomplete | None = None): ... +@_dispatch def connected_watts_strogatz_graph(n, k, p, tries: int = 100, seed: Incomplete | None = None): ... +@_dispatch def random_regular_graph(d, n, seed: Incomplete | None = None): ... +@_dispatch def barabasi_albert_graph(n, m, seed: Incomplete | None = None, initial_graph: Incomplete | None = None): ... +@_dispatch def dual_barabasi_albert_graph(n, m1, m2, p, seed: Incomplete | None = None, initial_graph: Incomplete | None = None): ... +@_dispatch def extended_barabasi_albert_graph(n, m, p, q, seed: Incomplete | None = None): ... +@_dispatch def powerlaw_cluster_graph(n, m, p, seed: Incomplete | None = None): ... +@_dispatch def random_lobster(n, p1, p2, seed: Incomplete | None = None): ... +@_dispatch def random_shell_graph(constructor, seed: Incomplete | None = None): ... +@_dispatch def random_powerlaw_tree(n, gamma: float = 3, seed: Incomplete | None = None, tries: int = 100): ... +@_dispatch def random_powerlaw_tree_sequence(n, gamma: float = 3, seed: Incomplete | None = None, tries: int = 100): ... +@_dispatch def random_kernel_graph(n, kernel_integral, kernel_root: Incomplete | None = None, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/small.pyi b/stubs/networkx/networkx/generators/small.pyi index ef08aa1fd..56ad13a33 100644 --- a/stubs/networkx/networkx/generators/small.pyi +++ b/stubs/networkx/networkx/generators/small.pyi @@ -1,25 +1,50 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def LCF_graph(n, shift_list, repeats, create_using: Incomplete | None = None): ... +@_dispatch def bull_graph(create_using: Incomplete | None = None): ... +@_dispatch def chvatal_graph(create_using: Incomplete | None = None): ... +@_dispatch def cubical_graph(create_using: Incomplete | None = None): ... +@_dispatch def desargues_graph(create_using: Incomplete | None = None): ... +@_dispatch def diamond_graph(create_using: Incomplete | None = None): ... +@_dispatch def dodecahedral_graph(create_using: Incomplete | None = None): ... +@_dispatch def frucht_graph(create_using: Incomplete | None = None): ... +@_dispatch def heawood_graph(create_using: Incomplete | None = None): ... +@_dispatch def hoffman_singleton_graph(): ... +@_dispatch def house_graph(create_using: Incomplete | None = None): ... +@_dispatch def house_x_graph(create_using: Incomplete | None = None): ... +@_dispatch def icosahedral_graph(create_using: Incomplete | None = None): ... +@_dispatch def krackhardt_kite_graph(create_using: Incomplete | None = None): ... +@_dispatch def moebius_kantor_graph(create_using: Incomplete | None = None): ... +@_dispatch def octahedral_graph(create_using: Incomplete | None = None): ... +@_dispatch def pappus_graph(): ... +@_dispatch def petersen_graph(create_using: Incomplete | None = None): ... +@_dispatch def sedgewick_maze_graph(create_using: Incomplete | None = None): ... +@_dispatch def tetrahedral_graph(create_using: Incomplete | None = None): ... +@_dispatch def truncated_cube_graph(create_using: Incomplete | None = None): ... +@_dispatch def truncated_tetrahedron_graph(create_using: Incomplete | None = None): ... +@_dispatch def tutte_graph(create_using: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/social.pyi b/stubs/networkx/networkx/generators/social.pyi index c28651c1c..18a7a9fd9 100644 --- a/stubs/networkx/networkx/generators/social.pyi +++ b/stubs/networkx/networkx/generators/social.pyi @@ -1,4 +1,10 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def karate_club_graph(): ... +@_dispatch def davis_southern_women_graph(): ... +@_dispatch def florentine_families_graph(): ... +@_dispatch def les_miserables_graph(): ... diff --git a/stubs/networkx/networkx/generators/spectral_graph_forge.pyi b/stubs/networkx/networkx/generators/spectral_graph_forge.pyi index e9e6c5618..62cb464ce 100644 --- a/stubs/networkx/networkx/generators/spectral_graph_forge.pyi +++ b/stubs/networkx/networkx/generators/spectral_graph_forge.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def spectral_graph_forge(G, alpha, transformation: str = "identity", seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/stochastic.pyi b/stubs/networkx/networkx/generators/stochastic.pyi index 3b1d05ad1..c97ff6531 100644 --- a/stubs/networkx/networkx/generators/stochastic.pyi +++ b/stubs/networkx/networkx/generators/stochastic.pyi @@ -1 +1,4 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def stochastic_graph(G, copy: bool = True, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/generators/sudoku.pyi b/stubs/networkx/networkx/generators/sudoku.pyi index 001227381..a271c6539 100644 --- a/stubs/networkx/networkx/generators/sudoku.pyi +++ b/stubs/networkx/networkx/generators/sudoku.pyi @@ -1 +1,4 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def sudoku_graph(n: int = 3): ... diff --git a/stubs/networkx/networkx/generators/trees.pyi b/stubs/networkx/networkx/generators/trees.pyi index 584dd3221..313baec45 100644 --- a/stubs/networkx/networkx/generators/trees.pyi +++ b/stubs/networkx/networkx/generators/trees.pyi @@ -1,5 +1,10 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def prefix_tree(paths): ... +@_dispatch def prefix_tree_recursive(paths): ... +@_dispatch def random_tree(n, seed: Incomplete | None = None, create_using: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/triads.pyi b/stubs/networkx/networkx/generators/triads.pyi index 73290b745..1ab083026 100644 --- a/stubs/networkx/networkx/generators/triads.pyi +++ b/stubs/networkx/networkx/generators/triads.pyi @@ -1 +1,4 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def triad_graph(triad_name): ... diff --git a/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi b/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi index 1a1cb701b..0a01e2419 100644 --- a/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi +++ b/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi @@ -1,5 +1,7 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + class _PCGSolver: def __init__(self, A, M) -> None: ... def solve(self, B, tol): ... @@ -8,6 +10,7 @@ class _LUSolver: def __init__(self, A) -> None: ... def solve(self, B, tol: Incomplete | None = None): ... +@_dispatch def algebraic_connectivity( G, weight: str = "weight", @@ -16,6 +19,7 @@ def algebraic_connectivity( method: str = "tracemin_pcg", seed: Incomplete | None = None, ): ... +@_dispatch def fiedler_vector( G, weight: str = "weight", @@ -24,6 +28,7 @@ def fiedler_vector( method: str = "tracemin_pcg", seed: Incomplete | None = None, ): ... +@_dispatch def spectral_ordering( G, weight: str = "weight", @@ -32,6 +37,7 @@ def spectral_ordering( method: str = "tracemin_pcg", seed: Incomplete | None = None, ): ... +@_dispatch def spectral_bisection( G, weight: str = "weight", diff --git a/stubs/networkx/networkx/linalg/attrmatrix.pyi b/stubs/networkx/networkx/linalg/attrmatrix.pyi index 4383cdd66..f8cfebb7b 100644 --- a/stubs/networkx/networkx/linalg/attrmatrix.pyi +++ b/stubs/networkx/networkx/linalg/attrmatrix.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def attr_matrix( G, edge_attr: Incomplete | None = None, @@ -9,6 +12,7 @@ def attr_matrix( dtype: Incomplete | None = None, order: Incomplete | None = None, ): ... +@_dispatch def attr_sparse_matrix( G, edge_attr: Incomplete | None = None, diff --git a/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi b/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi index 14ae63154..ee7a1bb94 100644 --- a/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi +++ b/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi @@ -1,3 +1,6 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def bethe_hessian_matrix(G, r: Incomplete | None = None, nodelist: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/linalg/graphmatrix.pyi b/stubs/networkx/networkx/linalg/graphmatrix.pyi index b8aabe9df..58d1b6613 100644 --- a/stubs/networkx/networkx/linalg/graphmatrix.pyi +++ b/stubs/networkx/networkx/linalg/graphmatrix.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def incidence_matrix( G, nodelist: Incomplete | None = None, @@ -7,4 +10,5 @@ def incidence_matrix( oriented: bool = False, weight: Incomplete | None = None, ): ... +@_dispatch def adjacency_matrix(G, nodelist: Incomplete | None = None, dtype: Incomplete | None = None, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/linalg/laplacianmatrix.pyi b/stubs/networkx/networkx/linalg/laplacianmatrix.pyi index 6f89c4d43..8921eb899 100644 --- a/stubs/networkx/networkx/linalg/laplacianmatrix.pyi +++ b/stubs/networkx/networkx/linalg/laplacianmatrix.pyi @@ -1,11 +1,18 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def laplacian_matrix(G, nodelist: Incomplete | None = None, weight: str = "weight"): ... +@_dispatch def normalized_laplacian_matrix(G, nodelist: Incomplete | None = None, weight: str = "weight"): ... +@_dispatch def total_spanning_tree_weight(G, weight: Incomplete | None = None): ... +@_dispatch def directed_laplacian_matrix( G, nodelist: Incomplete | None = None, weight: str = "weight", walk_type: Incomplete | None = None, alpha: float = 0.95 ): ... +@_dispatch def directed_combinatorial_laplacian_matrix( G, nodelist: Incomplete | None = None, weight: str = "weight", walk_type: Incomplete | None = None, alpha: float = 0.95 ): ... diff --git a/stubs/networkx/networkx/linalg/modularitymatrix.pyi b/stubs/networkx/networkx/linalg/modularitymatrix.pyi index 5f4e32f96..581a858df 100644 --- a/stubs/networkx/networkx/linalg/modularitymatrix.pyi +++ b/stubs/networkx/networkx/linalg/modularitymatrix.pyi @@ -1,4 +1,8 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def modularity_matrix(G, nodelist: Incomplete | None = None, weight: Incomplete | None = None): ... +@_dispatch def directed_modularity_matrix(G, nodelist: Incomplete | None = None, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/linalg/spectrum.pyi b/stubs/networkx/networkx/linalg/spectrum.pyi index d8cc72d89..a7713345e 100644 --- a/stubs/networkx/networkx/linalg/spectrum.pyi +++ b/stubs/networkx/networkx/linalg/spectrum.pyi @@ -1,7 +1,14 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def laplacian_spectrum(G, weight: str = "weight"): ... +@_dispatch def normalized_laplacian_spectrum(G, weight: str = "weight"): ... +@_dispatch def adjacency_spectrum(G, weight: str = "weight"): ... +@_dispatch def modularity_spectrum(G): ... +@_dispatch def bethe_hessian_spectrum(G, r: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/readwrite/adjlist.pyi b/stubs/networkx/networkx/readwrite/adjlist.pyi index 901ddbce6..3afb506f9 100644 --- a/stubs/networkx/networkx/readwrite/adjlist.pyi +++ b/stubs/networkx/networkx/readwrite/adjlist.pyi @@ -1,8 +1,11 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + def generate_adjlist(G, delimiter: str = " ") -> Generator[Incomplete, None, None]: ... def write_adjlist(G, path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8") -> None: ... +@_dispatch def parse_adjlist( lines, comments: str = "#", @@ -10,6 +13,7 @@ def parse_adjlist( create_using: Incomplete | None = None, nodetype: Incomplete | None = None, ): ... +@_dispatch def read_adjlist( path, comments: str = "#", diff --git a/stubs/networkx/networkx/readwrite/edgelist.pyi b/stubs/networkx/networkx/readwrite/edgelist.pyi index c2345c2ca..084a08fdc 100644 --- a/stubs/networkx/networkx/readwrite/edgelist.pyi +++ b/stubs/networkx/networkx/readwrite/edgelist.pyi @@ -1,8 +1,11 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + def generate_edgelist(G, delimiter: str = " ", data: bool = True) -> Generator[Incomplete, None, None]: ... def write_edgelist(G, path, comments: str = "#", delimiter: str = " ", data: bool = True, encoding: str = "utf-8") -> None: ... +@_dispatch def parse_edgelist( lines, comments: str = "#", @@ -11,6 +14,7 @@ def parse_edgelist( nodetype: Incomplete | None = None, data: bool = True, ): ... +@_dispatch def read_edgelist( path, comments: str = "#", @@ -22,6 +26,7 @@ def read_edgelist( encoding: str = "utf-8", ): ... def write_weighted_edgelist(G, path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8") -> None: ... +@_dispatch def read_weighted_edgelist( path, comments: str = "#", diff --git a/stubs/networkx/networkx/readwrite/gexf.pyi b/stubs/networkx/networkx/readwrite/gexf.pyi index 08c030021..844dae89a 100644 --- a/stubs/networkx/networkx/readwrite/gexf.pyi +++ b/stubs/networkx/networkx/readwrite/gexf.pyi @@ -1,12 +1,15 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + __all__ = ["write_gexf", "read_gexf", "relabel_gexf_graph", "generate_gexf"] def write_gexf(G, path, encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft") -> None: ... def generate_gexf( G, encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft" ) -> Generator[Incomplete, Incomplete, None]: ... +@_dispatch def read_gexf(path, node_type: Incomplete | None = None, relabel: bool = False, version: str = "1.2draft"): ... class GEXF: diff --git a/stubs/networkx/networkx/readwrite/gml.pyi b/stubs/networkx/networkx/readwrite/gml.pyi index 363de75fa..4cd4c6afd 100644 --- a/stubs/networkx/networkx/readwrite/gml.pyi +++ b/stubs/networkx/networkx/readwrite/gml.pyi @@ -3,11 +3,15 @@ from collections.abc import Generator from enum import Enum from typing import Generic, NamedTuple, TypeVar +from networkx.utils.backends import _dispatch + _T = TypeVar("_T") __all__ = ["read_gml", "parse_gml", "generate_gml", "write_gml"] +@_dispatch def read_gml(path, label: str = "label", destringizer: Incomplete | None = None): ... +@_dispatch def parse_gml(lines, label: str = "label", destringizer: Incomplete | None = None): ... class Pattern(Enum): diff --git a/stubs/networkx/networkx/readwrite/graph6.pyi b/stubs/networkx/networkx/readwrite/graph6.pyi index fa668ef8e..3ee6a8641 100644 --- a/stubs/networkx/networkx/readwrite/graph6.pyi +++ b/stubs/networkx/networkx/readwrite/graph6.pyi @@ -1,6 +1,10 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def from_graph6_bytes(bytes_in): ... def to_graph6_bytes(G, nodes: Incomplete | None = None, header: bool = True): ... +@_dispatch def read_graph6(path): ... def write_graph6(G, path, nodes: Incomplete | None = None, header: bool = True): ... diff --git a/stubs/networkx/networkx/readwrite/graphml.pyi b/stubs/networkx/networkx/readwrite/graphml.pyi index 83b866123..548b1db14 100644 --- a/stubs/networkx/networkx/readwrite/graphml.pyi +++ b/stubs/networkx/networkx/readwrite/graphml.pyi @@ -2,6 +2,8 @@ from _typeshed import Incomplete from collections.abc import Generator from typing import Final +from networkx.utils.backends import _dispatch + __all__ = [ "write_graphml", "read_graphml", @@ -38,7 +40,9 @@ def generate_graphml( named_key_ids: bool = False, edge_id_from_attribute: Incomplete | None = None, ) -> Generator[Incomplete, Incomplete, None]: ... +@_dispatch def read_graphml(path, node_type=..., edge_key_type=..., force_multigraph: bool = False): ... +@_dispatch def parse_graphml(graphml_string, node_type=..., edge_key_type=..., force_multigraph: bool = False): ... class GraphML: diff --git a/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi b/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi index 1bf7db87a..fa2d68e67 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi @@ -1,2 +1,6 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def adjacency_data(G, attrs={"id": "id", "key": "key"}): ... +@_dispatch 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 ad9f22923..03c5dd56d 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi @@ -1,2 +1,5 @@ +from networkx.utils.backends import _dispatch + def cytoscape_data(G, name: str = "name", ident: str = "id"): ... +@_dispatch def cytoscape_graph(data, name: str = "name", ident: str = "id"): ... diff --git a/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi b/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi index 319c21153..040e13d40 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi @@ -1,15 +1,11 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + def node_link_data( - G, - attrs: Incomplete | None = None, - *, - source: str = "source", - target: str = "target", - name: str = "id", - key: str = "key", - link: str = "links", + G, *, source: str = "source", target: str = "target", name: str = "id", key: str = "key", link: str = "links" ): ... +@_dispatch def node_link_graph( data, directed: bool = False, diff --git a/stubs/networkx/networkx/readwrite/json_graph/tree.pyi b/stubs/networkx/networkx/readwrite/json_graph/tree.pyi index b6cae9443..2c8d342e5 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/tree.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/tree.pyi @@ -1,2 +1,5 @@ +from networkx.utils.backends import _dispatch + def tree_data(G, root, ident: str = "id", children: str = "children"): ... +@_dispatch def tree_graph(data, ident: str = "id", children: str = "children"): ... diff --git a/stubs/networkx/networkx/readwrite/leda.pyi b/stubs/networkx/networkx/readwrite/leda.pyi index c0701362f..5611384a5 100644 --- a/stubs/networkx/networkx/readwrite/leda.pyi +++ b/stubs/networkx/networkx/readwrite/leda.pyi @@ -1,2 +1,6 @@ +from networkx.utils.backends import _dispatch + +@_dispatch def read_leda(path, encoding: str = "UTF-8"): ... +@_dispatch def parse_leda(lines): ... diff --git a/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi b/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi index f09488bb6..d1c2de83b 100644 --- a/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi +++ b/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi @@ -1,8 +1,11 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + 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: ... +@_dispatch def parse_multiline_adjlist( lines, comments: str = "#", @@ -11,6 +14,7 @@ def parse_multiline_adjlist( nodetype: Incomplete | None = None, edgetype: Incomplete | None = None, ): ... +@_dispatch def read_multiline_adjlist( path, comments: str = "#", diff --git a/stubs/networkx/networkx/readwrite/p2g.pyi b/stubs/networkx/networkx/readwrite/p2g.pyi index a50ea09af..c4a1a630d 100644 --- a/stubs/networkx/networkx/readwrite/p2g.pyi +++ b/stubs/networkx/networkx/readwrite/p2g.pyi @@ -1,3 +1,7 @@ +from networkx.utils.backends import _dispatch + def write_p2g(G, path, encoding: str = "utf-8") -> None: ... +@_dispatch def read_p2g(path, encoding: str = "utf-8"): ... +@_dispatch def parse_p2g(lines): ... diff --git a/stubs/networkx/networkx/readwrite/pajek.pyi b/stubs/networkx/networkx/readwrite/pajek.pyi index e1b59215b..fdce2f818 100644 --- a/stubs/networkx/networkx/readwrite/pajek.pyi +++ b/stubs/networkx/networkx/readwrite/pajek.pyi @@ -1,7 +1,11 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.utils.backends import _dispatch + def generate_pajek(G) -> Generator[Incomplete, None, None]: ... def write_pajek(G, path, encoding: str = "UTF-8") -> None: ... +@_dispatch def read_pajek(path, encoding: str = "UTF-8"): ... +@_dispatch def parse_pajek(lines): ... diff --git a/stubs/networkx/networkx/readwrite/sparse6.pyi b/stubs/networkx/networkx/readwrite/sparse6.pyi index 9336e6f5e..7674f644e 100644 --- a/stubs/networkx/networkx/readwrite/sparse6.pyi +++ b/stubs/networkx/networkx/readwrite/sparse6.pyi @@ -1,6 +1,10 @@ from _typeshed import Incomplete +from networkx.utils.backends import _dispatch + +@_dispatch def from_sparse6_bytes(string): ... def to_sparse6_bytes(G, nodes: Incomplete | None = None, header: bool = True): ... +@_dispatch def read_sparse6(path): ... def write_sparse6(G, path, nodes: Incomplete | None = None, header: bool = True) -> None: ... diff --git a/stubs/networkx/networkx/readwrite/text.pyi b/stubs/networkx/networkx/readwrite/text.pyi index 9bd43b819..83d92915b 100644 --- a/stubs/networkx/networkx/readwrite/text.pyi +++ b/stubs/networkx/networkx/readwrite/text.pyi @@ -46,6 +46,7 @@ def generate_network_text( sources: Incomplete | None = None, max_depth: Incomplete | None = None, ascii_only: bool = False, + vertical_chains: bool = False, ) -> Generator[Incomplete, None, Incomplete]: ... def write_network_text( graph, @@ -55,6 +56,7 @@ def write_network_text( max_depth: Incomplete | None = None, ascii_only: bool = False, end: str = "\n", + vertical_chains=False, ) -> None: ... def forest_str( graph, with_labels: bool = True, sources: Incomplete | None = None, write: Incomplete | None = None, ascii_only: bool = False diff --git a/stubs/networkx/networkx/relabel.pyi b/stubs/networkx/networkx/relabel.pyi index 7788ba91c..f8402f5e4 100644 --- a/stubs/networkx/networkx/relabel.pyi +++ b/stubs/networkx/networkx/relabel.pyi @@ -6,6 +6,7 @@ from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph from networkx.classes.multidigraph import MultiDiGraph from networkx.classes.multigraph import MultiGraph +from networkx.utils.backends import _dispatch _X = TypeVar("_X", bound=Hashable) _Y = TypeVar("_Y", bound=Hashable) @@ -18,6 +19,7 @@ def relabel_nodes(G: DiGraph[_X], mapping: Mapping[_X, _Y], copy: bool = True) - def relabel_nodes(G: MultiGraph[_X], mapping: Mapping[_X, _Y], copy: bool = True) -> MultiGraph[_X | _Y]: ... @overload def relabel_nodes(G: Graph[_X], mapping: Mapping[_X, _Y], copy: bool = True) -> Graph[_X | _Y]: ... +@_dispatch def convert_node_labels_to_integers( G: Graph[Hashable], first_label: int = 0, diff --git a/stubs/networkx/networkx/utils/backends.pyi b/stubs/networkx/networkx/utils/backends.pyi new file mode 100644 index 000000000..bec848c0a --- /dev/null +++ b/stubs/networkx/networkx/utils/backends.pyi @@ -0,0 +1,61 @@ +from _typeshed import Incomplete +from collections.abc import Callable, Mapping +from typing import Any, Generic, TypeVar, overload +from typing_extensions import ParamSpec, Self + +_P = ParamSpec("_P") +_R = TypeVar("_R") +__all__ = ["_dispatch"] + +class _dispatch(Generic[_P, _R]): + __defaults__: Incomplete + __kwdefaults__: Incomplete + __module__: Incomplete + __qualname__: Incomplete + __wrapped__: Incomplete + orig_func: Callable[_P, _R] | None + name: str + edge_attrs: dict[str, Any] | None + node_attrs: dict[str, Any] | None + preserve_edge_attrs: bool + preserve_node_attrs: bool + preserve_graph_attrs: bool + optional_graphs: Incomplete + list_graphs: Incomplete + graphs: dict[str, int] + backends: dict[str, Incomplete] + # Incomplete: Ignoring the case where func=None returns a partial, + # we only care about `_dispatch` used as a static-typing decorator + def __new__( + cls, + func: Callable[_P, _R] | None = None, + *, + name: str | None = None, + graphs: str | None | Mapping[str, int] = "G", + edge_attrs: str | dict[str, Any] | None = None, + node_attrs: str | dict[str, Any] | None = None, + preserve_edge_attrs: bool = False, + preserve_node_attrs: bool = False, + preserve_graph_attrs: bool = False, + preserve_all_attrs: bool = False, + ) -> Self: ... + @property + def __doc__(self): ... + @__doc__.setter + def __doc__(self, val) -> None: ... + @property + def __signature__(self): ... + # Type system limitations doesn't allow us to define this as it truly should. + # But specifying backend with backend_kwargs isn't a common usecase anyway + # and specifying backend as explicitely None is possible but not intended. + # If this ever changes, update stubs/networkx/@tests/test_cases/check_dispatch_decorator.py + @overload + def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R: ... + @overload + def __call__(self, *args: Any, backend: str, **backend_kwargs: Any) -> _R: ... + # @overload + # def __call__(self, *args: _P.args, backend: None = None, **kwargs: _P.kwargs) -> _R: ... + # @overload + # def __call__(self, *args: _P.args, backend: str, **kwargs: _P.kwargs, **backend_kwargs: Any) -> _R: ... + + def __reduce__(self): ...