From 7f0f1694bc0456b9f5a3ae23e9a199594d7bd180 Mon Sep 17 00:00:00 2001 From: Daniel Darabos Date: Thu, 30 Jan 2025 15:51:19 +0100 Subject: [PATCH 1/7] Generate stubs for new modules. --- stubs/networkx/networkx/algorithms/__init__.pyi | 3 +++ .../networkx/networkx/algorithms/approximation/density.pyi | 4 ++++ stubs/networkx/networkx/algorithms/bipartite/__init__.pyi | 1 + .../networkx/algorithms/bipartite/extendability.pyi | 4 ++++ stubs/networkx/networkx/algorithms/community/leiden.pyi | 6 ++++++ stubs/networkx/networkx/algorithms/time_dependent.pyi | 5 +++++ stubs/networkx/networkx/algorithms/walks.pyi | 4 ++++ stubs/networkx/networkx/generators/__init__.pyi | 2 ++ stubs/networkx/networkx/generators/time_series.pyi | 4 ++++ 9 files changed, 33 insertions(+) create mode 100644 stubs/networkx/networkx/algorithms/approximation/density.pyi create mode 100644 stubs/networkx/networkx/algorithms/bipartite/extendability.pyi create mode 100644 stubs/networkx/networkx/algorithms/community/leiden.pyi create mode 100644 stubs/networkx/networkx/algorithms/time_dependent.pyi create mode 100644 stubs/networkx/networkx/algorithms/walks.pyi create mode 100644 stubs/networkx/networkx/generators/time_series.pyi diff --git a/stubs/networkx/networkx/algorithms/__init__.pyi b/stubs/networkx/networkx/algorithms/__init__.pyi index 8d47145126d6..57141f108e16 100644 --- a/stubs/networkx/networkx/algorithms/__init__.pyi +++ b/stubs/networkx/networkx/algorithms/__init__.pyi @@ -30,6 +30,7 @@ from networkx.algorithms.bipartite import ( ) from networkx.algorithms.boundary import * from networkx.algorithms.bridges import * +from networkx.algorithms.broadcasting import * from networkx.algorithms.centrality import * from networkx.algorithms.chains import * from networkx.algorithms.chordal import * @@ -116,6 +117,7 @@ from networkx.algorithms.sparsifiers import * from networkx.algorithms.structuralholes import * from networkx.algorithms.summarization import * from networkx.algorithms.swap import * +from networkx.algorithms.time_dependent import * from networkx.algorithms.traversal import * from networkx.algorithms.tree.branchings import ( ArborescenceIterator as ArborescenceIterator, @@ -132,4 +134,5 @@ from networkx.algorithms.tree.recognition import * from networkx.algorithms.triads import * from networkx.algorithms.vitality import * from networkx.algorithms.voronoi import * +from networkx.algorithms.walks import * from networkx.algorithms.wiener import * diff --git a/stubs/networkx/networkx/algorithms/approximation/density.pyi b/stubs/networkx/networkx/algorithms/approximation/density.pyi new file mode 100644 index 000000000000..c7c0edcfad88 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/density.pyi @@ -0,0 +1,4 @@ +from networkx.utils.backends import _dispatchable + +@_dispatchable +def densest_subgraph(G, iterations=1, *, method='greedy++'): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/__init__.pyi b/stubs/networkx/networkx/algorithms/bipartite/__init__.pyi index 1f279a092959..0df90e4f1d7d 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/__init__.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/__init__.pyi @@ -3,6 +3,7 @@ from networkx.algorithms.bipartite.centrality import * from networkx.algorithms.bipartite.cluster import * from networkx.algorithms.bipartite.covering import * from networkx.algorithms.bipartite.edgelist import * +from networkx.algorithms.bipartite.extendability import * from networkx.algorithms.bipartite.generators import * from networkx.algorithms.bipartite.matching import * from networkx.algorithms.bipartite.matrix import * diff --git a/stubs/networkx/networkx/algorithms/bipartite/extendability.pyi b/stubs/networkx/networkx/algorithms/bipartite/extendability.pyi new file mode 100644 index 000000000000..36f3e6775c91 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/extendability.pyi @@ -0,0 +1,4 @@ +from networkx.utils.backends import _dispatchable + +@_dispatchable +def maximal_extendability(G): ... diff --git a/stubs/networkx/networkx/algorithms/community/leiden.pyi b/stubs/networkx/networkx/algorithms/community/leiden.pyi new file mode 100644 index 000000000000..9232e9836cee --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/leiden.pyi @@ -0,0 +1,6 @@ +from networkx.utils.backends import _dispatchable + +@_dispatchable +def leiden_communities(G, weight='weight', resolution=1, max_level=None, seed=None): ... +@_dispatchable +def leiden_partitions(G, weight='weight', resolution=1, seed=None): ... diff --git a/stubs/networkx/networkx/algorithms/time_dependent.pyi b/stubs/networkx/networkx/algorithms/time_dependent.pyi new file mode 100644 index 000000000000..00ca16d96d15 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/time_dependent.pyi @@ -0,0 +1,5 @@ +from networkx.utils.backends import _dispatchable +from _typeshed import Incomplete + +@_dispatchable +def cd_index(G, node, time_delta, *, time: str = 'time', weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/walks.pyi b/stubs/networkx/networkx/algorithms/walks.pyi new file mode 100644 index 000000000000..a9d4b94e5f55 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/walks.pyi @@ -0,0 +1,4 @@ +from networkx.utils.backends import _dispatchable + +@_dispatchable +def number_of_walks(G, walk_length): ... diff --git a/stubs/networkx/networkx/generators/__init__.pyi b/stubs/networkx/networkx/generators/__init__.pyi index c19ff74b7229..878faee7cacc 100644 --- a/stubs/networkx/networkx/generators/__init__.pyi +++ b/stubs/networkx/networkx/generators/__init__.pyi @@ -8,6 +8,7 @@ from networkx.generators.duplication import * from networkx.generators.ego import * from networkx.generators.expanders import * from networkx.generators.geometric import * +from networkx.generators.harary_graph import * from networkx.generators.internet_as_graphs import * from networkx.generators.intersection import * from networkx.generators.interval_graph import * @@ -23,5 +24,6 @@ from networkx.generators.social import * from networkx.generators.spectral_graph_forge import * from networkx.generators.stochastic import * from networkx.generators.sudoku import * +from networkx.generators.time_series import * from networkx.generators.trees import * from networkx.generators.triads import * diff --git a/stubs/networkx/networkx/generators/time_series.pyi b/stubs/networkx/networkx/generators/time_series.pyi new file mode 100644 index 000000000000..b5655e820964 --- /dev/null +++ b/stubs/networkx/networkx/generators/time_series.pyi @@ -0,0 +1,4 @@ +from networkx.utils.backends import _dispatchable + +@_dispatchable +def visibility_graph(series): ... From 3eb19650a3c48934f01c3dcdaf4edbedfffb9572 Mon Sep 17 00:00:00 2001 From: Daniel Darabos Date: Thu, 30 Jan 2025 16:21:36 +0100 Subject: [PATCH 2/7] Formatting changes from automation. --- stubs/networkx/networkx/algorithms/approximation/density.pyi | 2 +- .../networkx/algorithms/approximation/traveling_salesman.pyi | 1 - .../networkx/networkx/algorithms/approximation/treewidth.pyi | 1 + .../networkx/networkx/algorithms/centrality/flow_matrix.pyi | 4 ++++ stubs/networkx/networkx/algorithms/clique.pyi | 2 +- .../networkx/algorithms/coloring/greedy_coloring.pyi | 2 ++ stubs/networkx/networkx/algorithms/community/leiden.pyi | 4 ++-- .../networkx/algorithms/connectivity/connectivity.pyi | 1 - stubs/networkx/networkx/algorithms/connectivity/cuts.pyi | 1 - .../networkx/algorithms/connectivity/disjoint_paths.pyi | 1 - .../networkx/algorithms/connectivity/edge_kcomponents.pyi | 1 + .../networkx/algorithms/connectivity/kcomponents.pyi | 1 - stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi | 1 - stubs/networkx/networkx/algorithms/cycles.pyi | 1 + stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi | 1 - stubs/networkx/networkx/algorithms/flow/maxflow.pyi | 1 - stubs/networkx/networkx/algorithms/flow/networksimplex.pyi | 1 + stubs/networkx/networkx/algorithms/flow/utils.pyi | 1 + stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi | 1 + .../networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi | 5 +++++ .../networkx/algorithms/isomorphism/temporalisomorphvf2.pyi | 2 ++ .../networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi | 2 ++ stubs/networkx/networkx/algorithms/operators/binary.pyi | 2 -- stubs/networkx/networkx/algorithms/planarity.pyi | 3 +++ .../networkx/networkx/algorithms/shortest_paths/weighted.pyi | 1 - stubs/networkx/networkx/algorithms/simple_paths.pyi | 1 + stubs/networkx/networkx/algorithms/time_dependent.pyi | 5 +++-- stubs/networkx/networkx/algorithms/tree/branchings.pyi | 2 ++ stubs/networkx/networkx/algorithms/tree/mst.pyi | 2 ++ 29 files changed, 36 insertions(+), 17 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/approximation/density.pyi b/stubs/networkx/networkx/algorithms/approximation/density.pyi index c7c0edcfad88..309e46909ae7 100644 --- a/stubs/networkx/networkx/algorithms/approximation/density.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/density.pyi @@ -1,4 +1,4 @@ from networkx.utils.backends import _dispatchable @_dispatchable -def densest_subgraph(G, iterations=1, *, method='greedy++'): ... +def densest_subgraph(G, iterations=1, *, method="greedy++"): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi index e44e31519d14..c7775c382562 100644 --- a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi @@ -18,7 +18,6 @@ def simulated_annealing_tsp( init_cycle, weight: str = "weight", source: Incomplete | None = None, - # docstring says int, but it can be a float and does become a float mid-equation if alpha is also a float temp: float = 100, move: str = "1-1", max_iterations: int = 10, diff --git a/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi index 5a68247f5b49..837a9ca4d87d 100644 --- a/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi @@ -11,5 +11,6 @@ def treewidth_min_fill_in(G): ... class MinDegreeHeuristic: count: Incomplete + def __init__(self, graph) -> None: ... def best_node(self, graph): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi b/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi index 12a98580dbde..7b7f43908ffb 100644 --- a/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi @@ -12,6 +12,7 @@ class InverseLaplacian: w: Incomplete C: Incomplete L1: Incomplete + def __init__(self, L, width: Incomplete | None = None, dtype: Incomplete | None = None) -> None: ... def init_solver(self, L) -> None: ... def solve(self, r) -> None: ... @@ -22,18 +23,21 @@ class InverseLaplacian: class FullInverseLaplacian(InverseLaplacian): IL: Incomplete + def init_solver(self, L) -> None: ... def solve(self, rhs): ... def solve_inverse(self, r): ... class SuperLUInverseLaplacian(InverseLaplacian): lusolve: Incomplete + def init_solver(self, L) -> None: ... def solve_inverse(self, r): ... def solve(self, rhs): ... class CGInverseLaplacian(InverseLaplacian): M: Incomplete + def init_solver(self, L) -> None: ... def solve(self, rhs): ... def solve_inverse(self, r): ... diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi index e7409ca915d8..bacc2dbe5522 100644 --- a/stubs/networkx/networkx/algorithms/clique.pyi +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -18,7 +18,7 @@ def make_clique_bipartite( G: Graph[_Node], fpos: Unused = None, create_using: type[Graph[_Node]] | None = None, name: Unused = None ) -> Graph[_Node]: ... @overload -def node_clique_number( # type: ignore[misc] # Incompatible return types +def node_clique_number( G: Graph[_Node], nodes: Iterable[_Node] | None = None, cliques: Iterable[Iterable[_Node]] | None = None, diff --git a/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi b/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi index 26b8767083d0..f6e9b68a3fae 100644 --- a/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi +++ b/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi @@ -39,6 +39,7 @@ class _Node: color: int adj_list: Incomplete adj_color: Incomplete + def __init__(self, node_id, n) -> None: ... def assign_color(self, adj_entry, color) -> None: ... def clear_color(self, adj_entry, color) -> None: ... @@ -51,4 +52,5 @@ class _AdjEntry: mate: Incomplete col_next: Incomplete col_prev: Incomplete + def __init__(self, node_id) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/community/leiden.pyi b/stubs/networkx/networkx/algorithms/community/leiden.pyi index 9232e9836cee..2aa7eace3cf2 100644 --- a/stubs/networkx/networkx/algorithms/community/leiden.pyi +++ b/stubs/networkx/networkx/algorithms/community/leiden.pyi @@ -1,6 +1,6 @@ from networkx.utils.backends import _dispatchable @_dispatchable -def leiden_communities(G, weight='weight', resolution=1, max_level=None, seed=None): ... +def leiden_communities(G, weight="weight", resolution=1, max_level=None, seed=None): ... @_dispatchable -def leiden_partitions(G, weight='weight', resolution=1, seed=None): ... +def leiden_partitions(G, weight="weight", resolution=1, seed=None): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi index a13069989845..3840e14a1dc0 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi @@ -11,7 +11,6 @@ __all__ = [ "edge_connectivity", "all_pairs_node_connectivity", ] - default_flow_func = edmonds_karp @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi index 44372c2d915c..b50cc37f60c4 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi @@ -4,7 +4,6 @@ from networkx.algorithms.flow import edmonds_karp from networkx.utils.backends import _dispatchable __all__ = ["minimum_st_node_cut", "minimum_node_cut", "minimum_st_edge_cut", "minimum_edge_cut"] - default_flow_func = edmonds_karp @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi b/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi index 2f8fc3abe242..79e7f7e4e18f 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi @@ -5,7 +5,6 @@ from networkx.algorithms.flow import edmonds_karp from networkx.utils.backends import _dispatchable __all__ = ["edge_disjoint_paths", "node_disjoint_paths"] - default_flow_func = edmonds_karp @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi index 2578606fb13f..68b1f8d0adb3 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi @@ -13,6 +13,7 @@ def bridge_components(G) -> Generator[Incomplete, Incomplete, None]: ... class EdgeComponentAuxGraph: A: Incomplete H: Incomplete + @classmethod def construct(cls, G): ... def k_edge_components(self, k) -> Generator[Incomplete, Incomplete, None]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi index ee074a6a682d..694a28cb3c5f 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi @@ -4,7 +4,6 @@ from networkx.algorithms.flow import edmonds_karp from networkx.utils.backends import _dispatchable __all__ = ["k_components"] - default_flow_func = edmonds_karp @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi b/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi index 8f527058659c..21ccb3525415 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi @@ -5,7 +5,6 @@ from networkx.algorithms.flow import edmonds_karp from networkx.utils.backends import _dispatchable __all__ = ["all_node_cuts"] - default_flow_func = edmonds_karp @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/cycles.pyi b/stubs/networkx/networkx/algorithms/cycles.pyi index 8236680f3f05..be263e37302f 100644 --- a/stubs/networkx/networkx/algorithms/cycles.pyi +++ b/stubs/networkx/networkx/algorithms/cycles.pyi @@ -10,6 +10,7 @@ def simple_cycles(G, length_bound: Incomplete | None = None) -> Generator[Incomp class _NeighborhoodCache(dict[Incomplete, Incomplete]): G: Incomplete + def __init__(self, G) -> None: ... def __missing__(self, v): ... diff --git a/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi b/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi index 5c7f878564d1..86dbddc3c2b1 100644 --- a/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi +++ b/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi @@ -5,7 +5,6 @@ from networkx.utils.backends import _dispatchable from .edmondskarp import edmonds_karp __all__ = ["gomory_hu_tree"] - default_flow_func = edmonds_karp @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/flow/maxflow.pyi b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi index f64d48aa8cdb..ac77657c0ead 100644 --- a/stubs/networkx/networkx/algorithms/flow/maxflow.pyi +++ b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi @@ -5,7 +5,6 @@ from networkx.utils.backends import _dispatchable from .preflowpush import preflow_push __all__ = ["maximum_flow", "maximum_flow_value", "minimum_cut", "minimum_cut_value"] - default_flow_func = preflow_push @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi b/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi index dcbc88ac35c6..36573daa7ade 100644 --- a/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi +++ b/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi @@ -22,6 +22,7 @@ class _DataEssentialsAndFunctions: next_node_dft: Incomplete prev_node_dft: Incomplete last_descendent_dft: Incomplete + def __init__(self, G, multigraph, demand: str = "demand", capacity: str = "capacity", weight: str = "weight") -> None: ... def initialize_spanning_tree(self, n, faux_inf) -> None: ... def find_apex(self, p, q): ... diff --git a/stubs/networkx/networkx/algorithms/flow/utils.pyi b/stubs/networkx/networkx/algorithms/flow/utils.pyi index 04c99b4ed081..3b041a5fc2b1 100644 --- a/stubs/networkx/networkx/algorithms/flow/utils.pyi +++ b/stubs/networkx/networkx/algorithms/flow/utils.pyi @@ -10,6 +10,7 @@ class CurrentEdge: class Level: active: Incomplete inactive: Incomplete + def __init__(self) -> None: ... class GlobalRelabelThreshold: diff --git a/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi index 259d9f7735ce..4a64a8191674 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi @@ -6,6 +6,7 @@ class ISMAGS: subgraph: Incomplete node_equality: Incomplete edge_equality: Incomplete + def __init__( self, graph, diff --git a/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi b/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi index 7b2e2c3d296d..dd57778fcc7a 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi @@ -11,6 +11,7 @@ class GraphMatcher: G2_node_order: Incomplete old_recursion_limit: Incomplete test: str + def __init__(self, G1, G2) -> None: ... def reset_recursion_limit(self) -> None: ... def candidate_pairs_iter(self) -> Generator[Incomplete, None, None]: ... @@ -20,6 +21,7 @@ class GraphMatcher: inout_2: Incomplete state: Incomplete mapping: Incomplete + def initialize(self) -> None: ... def is_isomorphic(self): ... def isomorphisms_iter(self) -> Generator[Incomplete, Incomplete, None]: ... @@ -42,6 +44,7 @@ class DiGraphMatcher(GraphMatcher): out_2: Incomplete state: Incomplete mapping: Incomplete + def initialize(self) -> None: ... def syntactic_feasibility(self, G1_node, G2_node): ... @@ -50,6 +53,7 @@ class GMState: G1_node: Incomplete G2_node: Incomplete depth: Incomplete + def __init__(self, GM, G1_node: Incomplete | None = None, G2_node: Incomplete | None = None) -> None: ... def restore(self) -> None: ... @@ -58,5 +62,6 @@ class DiGMState: G1_node: Incomplete G2_node: Incomplete depth: Incomplete + def __init__(self, GM, G1_node: Incomplete | None = None, G2_node: Incomplete | None = None) -> None: ... def restore(self) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi b/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi index a3200872c5e1..060f3d193541 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi @@ -7,6 +7,7 @@ __all__ = ["TimeRespectingGraphMatcher", "TimeRespectingDiGraphMatcher"] class TimeRespectingGraphMatcher(GraphMatcher): temporal_attribute_name: Incomplete delta: Incomplete + def __init__(self, G1, G2, temporal_attribute_name, delta) -> None: ... def one_hop(self, Gx, Gx_node, neighbors): ... def two_hop(self, Gx, core_x, Gx_node, neighbors): ... @@ -15,6 +16,7 @@ class TimeRespectingGraphMatcher(GraphMatcher): class TimeRespectingDiGraphMatcher(DiGraphMatcher): temporal_attribute_name: Incomplete delta: Incomplete + def __init__(self, G1, G2, temporal_attribute_name, delta) -> None: ... def get_pred_dates(self, Gx, Gx_node, core_x, pred): ... def get_succ_dates(self, Gx, Gx_node, core_x, succ): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi b/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi index 5c84c8f6c340..3800601bc5e9 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi @@ -9,6 +9,7 @@ class GraphMatcher(vf2.GraphMatcher): edge_match: Incomplete G1_adj: Incomplete G2_adj: Incomplete + def __init__(self, G1, G2, node_match: Incomplete | None = None, edge_match: Incomplete | None = None) -> None: ... semantic_feasibility: Incomplete @@ -17,6 +18,7 @@ class DiGraphMatcher(vf2.DiGraphMatcher): edge_match: Incomplete G1_adj: Incomplete G2_adj: Incomplete + def __init__(self, G1, G2, node_match: Incomplete | None = None, edge_match: Incomplete | None = None) -> None: ... def semantic_feasibility(self, G1_node, G2_node): ... diff --git a/stubs/networkx/networkx/algorithms/operators/binary.pyi b/stubs/networkx/networkx/algorithms/operators/binary.pyi index ef7f4943ca52..536ab75240a2 100644 --- a/stubs/networkx/networkx/algorithms/operators/binary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/binary.pyi @@ -15,8 +15,6 @@ def symmetric_difference(G, H): ... _X = TypeVar("_X", bound=Hashable, covariant=True) _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 @_dispatchable def compose(G: DiGraph[_X], H: DiGraph[_Y]) -> DiGraph[_X | _Y]: ... diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index 5df3c945c7c4..9d7e58086962 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -15,6 +15,7 @@ def check_planarity(G, counterexample: bool = False): ... class Interval: low: Incomplete high: Incomplete + def __init__(self, low: Incomplete | None = None, high: Incomplete | None = None) -> None: ... def empty(self): ... def copy(self): ... @@ -23,6 +24,7 @@ class Interval: class ConflictPair: left: Incomplete right: Incomplete + def __init__(self, left=..., right=...) -> None: ... def swap(self) -> None: ... def lowest(self, planarity_state): ... @@ -46,6 +48,7 @@ class LRPlanarity: left_ref: Incomplete right_ref: Incomplete embedding: Incomplete + def __init__(self, G) -> None: ... def lr_planarity(self): ... def lr_planarity_recursive(self): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi index 2716cbfbc84c..7eebe73c0c36 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi @@ -5,7 +5,6 @@ from typing_extensions import TypeAlias from networkx.utils.backends import _dispatchable -# type alias for the weight function _WeightFunction: TypeAlias = Callable[[Any, Any, dict[str, Any]], float | None] @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/simple_paths.pyi b/stubs/networkx/networkx/algorithms/simple_paths.pyi index 6e69d1d1386e..83bd0815252f 100644 --- a/stubs/networkx/networkx/algorithms/simple_paths.pyi +++ b/stubs/networkx/networkx/algorithms/simple_paths.pyi @@ -25,6 +25,7 @@ class PathBuffer: paths: Incomplete sortedpaths: Incomplete counter: Incomplete + def __init__(self) -> None: ... def __len__(self): ... def push(self, cost, path) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/time_dependent.pyi b/stubs/networkx/networkx/algorithms/time_dependent.pyi index 00ca16d96d15..195ca18840b9 100644 --- a/stubs/networkx/networkx/algorithms/time_dependent.pyi +++ b/stubs/networkx/networkx/algorithms/time_dependent.pyi @@ -1,5 +1,6 @@ -from networkx.utils.backends import _dispatchable from _typeshed import Incomplete +from networkx.utils.backends import _dispatchable + @_dispatchable -def cd_index(G, node, time_delta, *, time: str = 'time', weight: Incomplete | None = None): ... +def cd_index(G, node, time_delta, *, time: str = "time", weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi index 5bed2ab210ef..dcb6d2a8413a 100644 --- a/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -47,7 +47,9 @@ class ArborescenceIterator: method: Incomplete partition_key: str init_partition: Incomplete + def __init__(self, G, weight: str = "weight", minimum: bool = True, init_partition: Incomplete | None = None) -> None: ... partition_queue: Incomplete + def __iter__(self) -> Iterator[Incomplete]: ... def __next__(self): ... diff --git a/stubs/networkx/networkx/algorithms/tree/mst.pyi b/stubs/networkx/networkx/algorithms/tree/mst.pyi index 178b5a771cb7..065e6f178fc5 100644 --- a/stubs/networkx/networkx/algorithms/tree/mst.pyi +++ b/stubs/networkx/networkx/algorithms/tree/mst.pyi @@ -40,7 +40,9 @@ class SpanningTreeIterator: minimum: Incomplete ignore_nan: Incomplete partition_key: str + def __init__(self, G, weight: str = "weight", minimum: bool = True, ignore_nan: bool = False) -> None: ... partition_queue: Incomplete + def __iter__(self) -> Iterator[Incomplete]: ... def __next__(self): ... From 2ae350bbed9300e6b9b8505fb0131350fd51a6e5 Mon Sep 17 00:00:00 2001 From: Daniel Darabos Date: Mon, 3 Feb 2025 17:12:23 +0100 Subject: [PATCH 3/7] Add types extracted from docstrings. --- .../algorithms/approximation/clique.pyi | 9 +- .../approximation/clustering_coefficient.pyi | 6 +- .../algorithms/approximation/connectivity.pyi | 9 +- .../algorithms/approximation/density.pyi | 3 +- .../approximation/distance_measures.pyi | 6 +- .../approximation/dominating_set.pyi | 7 +- .../algorithms/approximation/kcomponents.pyi | 3 +- .../algorithms/approximation/matching.pyi | 3 +- .../algorithms/approximation/maxcut.pyi | 8 +- .../algorithms/approximation/ramsey.pyi | 3 +- .../algorithms/approximation/steinertree.pyi | 7 +- .../approximation/traveling_salesman.pyi | 51 ++++---- .../algorithms/approximation/treewidth.pyi | 5 +- .../algorithms/approximation/vertex_cover.pyi | 5 +- .../algorithms/assortativity/connectivity.pyi | 5 +- .../algorithms/assortativity/correlation.pyi | 11 +- .../algorithms/assortativity/mixing.pyi | 17 +-- .../assortativity/neighbor_degree.pyi | 9 +- .../algorithms/assortativity/pairs.pyi | 7 +- .../networkx/algorithms/asteroidal.pyi | 5 +- .../networkx/algorithms/bipartite/basic.pyi | 15 ++- .../algorithms/bipartite/centrality.pyi | 7 +- .../networkx/algorithms/bipartite/cluster.pyi | 9 +- .../algorithms/bipartite/covering.pyi | 5 +- .../algorithms/bipartite/edgelist.pyi | 25 ++-- .../algorithms/bipartite/extendability.pyi | 3 +- .../algorithms/bipartite/generators.pyi | 24 ++-- .../algorithms/bipartite/matching.pyi | 11 +- .../networkx/algorithms/bipartite/matrix.pyi | 17 ++- .../algorithms/bipartite/projection.pyi | 13 +- .../algorithms/bipartite/redundancy.pyi | 5 +- .../algorithms/bipartite/spectral.pyi | 5 +- .../networkx/networkx/algorithms/boundary.pyi | 86 ++----------- .../networkx/networkx/algorithms/bridges.pyi | 15 +-- .../algorithms/centrality/betweenness.pyi | 12 +- .../centrality/betweenness_subset.pyi | 6 +- .../algorithms/centrality/closeness.pyi | 12 +- .../centrality/current_flow_betweenness.pyi | 18 +-- .../current_flow_betweenness_subset.pyi | 19 ++- .../centrality/current_flow_closeness.pyi | 5 +- .../algorithms/centrality/dispersion.pyi | 8 +- .../algorithms/centrality/eigenvector.pyi | 9 +- .../networkx/algorithms/centrality/group.pyi | 29 +++-- .../algorithms/centrality/harmonic.pyi | 7 +- .../networkx/algorithms/centrality/katz.pyi | 21 ++- .../algorithms/centrality/laplacian.pyi | 11 +- .../networkx/algorithms/centrality/load.pyi | 7 +- .../algorithms/centrality/percolation.pyi | 5 +- .../algorithms/centrality/reaching.pyi | 8 +- .../algorithms/centrality/second_order.pyi | 3 +- .../algorithms/centrality/subgraph_alg.pyi | 9 +- .../algorithms/centrality/trophic.pyi | 8 +- .../algorithms/centrality/voterank_alg.pyi | 5 +- stubs/networkx/networkx/algorithms/chains.pyi | 2 +- .../networkx/networkx/algorithms/chordal.pyi | 6 +- stubs/networkx/networkx/algorithms/clique.pyi | 22 +--- .../networkx/networkx/algorithms/cluster.pyi | 17 ++- .../coloring/equitable_coloring.pyi | 3 +- .../algorithms/coloring/greedy_coloring.pyi | 24 +--- .../algorithms/communicability_alg.pyi | 5 +- .../algorithms/community/asyn_fluid.pyi | 6 +- .../algorithms/community/centrality.pyi | 5 +- .../algorithms/community/community_utils.pyi | 3 +- .../algorithms/community/divisive.pyi | 7 +- .../networkx/algorithms/community/kclique.pyi | 3 +- .../algorithms/community/kernighan_lin.pyi | 6 +- .../community/label_propagation.pyi | 6 +- .../networkx/algorithms/community/leiden.pyi | 14 +- .../networkx/algorithms/community/louvain.pyi | 15 ++- .../networkx/algorithms/community/lukes.pyi | 5 +- .../algorithms/community/modularity_max.pyi | 7 +- .../networkx/algorithms/community/quality.pyi | 5 +- .../algorithms/components/biconnected.pyi | 9 +- .../algorithms/components/connected.pyi | 9 +- .../algorithms/components/semiconnected.pyi | 5 +- .../components/strongly_connected.pyi | 10 +- .../components/weakly_connected.pyi | 6 +- .../algorithms/connectivity/connectivity.pyi | 44 +++---- .../networkx/algorithms/connectivity/cuts.pyi | 22 +++- .../connectivity/disjoint_paths.pyi | 32 ++--- .../connectivity/edge_augmentation.pyi | 10 +- .../connectivity/edge_kcomponents.pyi | 11 +- .../algorithms/connectivity/kcomponents.pyi | 5 +- .../algorithms/connectivity/kcutsets.pyi | 5 +- .../algorithms/connectivity/stoerwagner.pyi | 3 +- stubs/networkx/networkx/algorithms/core.pyi | 17 ++- .../networkx/networkx/algorithms/covering.pyi | 7 +- stubs/networkx/networkx/algorithms/cuts.pyi | 19 +-- stubs/networkx/networkx/algorithms/cycles.pyi | 14 +- .../networkx/algorithms/d_separation.pyi | 4 +- stubs/networkx/networkx/algorithms/dag.pyi | 21 ++- .../networkx/algorithms/distance_measures.pyi | 17 ++- .../networkx/algorithms/distance_regular.pyi | 7 +- .../networkx/algorithms/dominance.pyi | 5 +- .../networkx/algorithms/dominating.pyi | 7 +- stubs/networkx/networkx/algorithms/euler.pyi | 13 +- .../algorithms/flow/boykovkolmogorov.pyi | 13 +- .../algorithms/flow/capacityscaling.pyi | 5 +- .../networkx/algorithms/flow/dinitz_alg.pyi | 13 +- .../networkx/algorithms/flow/edmondskarp.pyi | 13 +- .../networkx/algorithms/flow/gomory_hu.pyi | 5 +- .../networkx/algorithms/flow/maxflow.pyi | 15 ++- .../networkx/algorithms/flow/mincost.pyi | 9 +- .../algorithms/flow/networksimplex.pyi | 3 +- .../networkx/algorithms/flow/preflowpush.pyi | 11 +- .../flow/shortestaugmentingpath.pyi | 13 +- .../networkx/algorithms/graph_hashing.pyi | 16 ++- .../networkx/algorithms/graphical.pyi | 14 +- .../networkx/algorithms/hierarchy.pyi | 4 +- stubs/networkx/networkx/algorithms/hybrid.pyi | 5 +- .../networkx/networkx/algorithms/isolate.pyi | 7 +- .../algorithms/isomorphism/isomorph.pyi | 4 +- .../isomorphism/tree_isomorphism.pyi | 3 +- .../networkx/algorithms/isomorphism/vf2pp.pyi | 6 +- .../algorithms/link_analysis/hits_alg.pyi | 7 +- .../algorithms/link_analysis/pagerank_alg.pyi | 29 ++--- .../networkx/algorithms/link_prediction.pyi | 19 ++- .../algorithms/lowest_common_ancestors.pyi | 9 +- .../networkx/networkx/algorithms/matching.pyi | 13 +- .../algorithms/minors/contraction.pyi | 18 +-- stubs/networkx/networkx/algorithms/mis.pyi | 6 +- stubs/networkx/networkx/algorithms/moral.pyi | 3 +- .../algorithms/node_classification.pyi | 5 +- .../networkx/algorithms/non_randomness.pyi | 5 +- .../networkx/algorithms/operators/all.pyi | 10 +- .../networkx/algorithms/operators/binary.pyi | 6 +- .../networkx/algorithms/operators/product.pyi | 5 +- .../networkx/algorithms/operators/unary.pyi | 7 +- .../networkx/algorithms/planarity.pyi | 6 +- .../networkx/algorithms/polynomials.pyi | 5 +- .../networkx/algorithms/reciprocity.pyi | 7 +- .../networkx/networkx/algorithms/regular.pyi | 7 +- .../networkx/networkx/algorithms/richclub.pyi | 6 +- .../algorithms/shortest_paths/astar.pyi | 24 +++- .../algorithms/shortest_paths/dense.pyi | 11 +- .../algorithms/shortest_paths/generic.pyi | 39 ++++-- .../algorithms/shortest_paths/unweighted.pyi | 17 +-- .../algorithms/shortest_paths/weighted.pyi | 120 ++++++++++++++---- .../networkx/algorithms/similarity.pyi | 106 +++++++++------- .../networkx/algorithms/simple_paths.pyi | 13 +- .../networkx/algorithms/smallworld.pyi | 12 +- .../networkx/networkx/algorithms/smetric.pyi | 3 +- .../networkx/algorithms/sparsifiers.pyi | 6 +- .../networkx/algorithms/structuralholes.pyi | 9 +- .../networkx/algorithms/summarization.pyi | 9 +- stubs/networkx/networkx/algorithms/swap.pyi | 13 +- .../networkx/algorithms/threshold.pyi | 7 +- .../networkx/algorithms/time_dependent.pyi | 5 +- .../networkx/algorithms/tournament.pyi | 16 +-- .../algorithms/traversal/beamsearch.pyi | 7 +- .../traversal/breadth_first_search.pyi | 17 ++- .../traversal/depth_first_search.pyi | 19 +-- .../networkx/algorithms/traversal/edgebfs.pyi | 5 +- .../networkx/algorithms/traversal/edgedfs.pyi | 5 +- .../networkx/algorithms/tree/branchings.pyi | 17 ++- .../networkx/algorithms/tree/coding.pyi | 9 +- .../networkx/networkx/algorithms/tree/mst.pyi | 24 +++- .../networkx/algorithms/tree/operations.pyi | 4 +- .../networkx/algorithms/tree/recognition.pyi | 10 +- stubs/networkx/networkx/algorithms/triads.pyi | 17 ++- .../networkx/networkx/algorithms/vitality.pyi | 7 +- .../networkx/networkx/algorithms/voronoi.pyi | 8 +- stubs/networkx/networkx/algorithms/walks.pyi | 3 +- stubs/networkx/networkx/algorithms/wiener.pyi | 5 +- 164 files changed, 1072 insertions(+), 911 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/approximation/clique.pyi b/stubs/networkx/networkx/algorithms/approximation/clique.pyi index 886ec93f7c02..99c86b3a1c87 100644 --- a/stubs/networkx/networkx/algorithms/approximation/clique.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/clique.pyi @@ -1,10 +1,11 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def maximum_independent_set(G): ... +def maximum_independent_set(G: Graph[_Node]): ... @_dispatchable -def max_clique(G): ... +def max_clique(G: Graph[_Node]): ... @_dispatchable -def clique_removal(G): ... +def clique_removal(G: Graph[_Node]): ... @_dispatchable -def large_clique_size(G): ... +def large_clique_size(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi b/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi index b18a813d1192..b02ea8144d50 100644 --- a/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi @@ -1,6 +1,6 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable -def average_clustering(G, trials: int = 1000, seed: Incomplete | None = None): ... +def average_clustering(G: Graph[_Node], trials: int = 1000, seed: int | RandomState | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi b/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi index 8a431a9acb00..568ba5f86224 100644 --- a/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi @@ -1,10 +1,11 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def local_node_connectivity(G, source, target, cutoff: Incomplete | None = None): ... +def local_node_connectivity(G: Graph[_Node], source: _Node, target: _Node, cutoff: int = None): ... @_dispatchable -def node_connectivity(G, s: Incomplete | None = None, t: Incomplete | None = None): ... +def node_connectivity(G: Graph[_Node], s: _Node = None, t: _Node = None): ... @_dispatchable -def all_pairs_node_connectivity(G, nbunch: Incomplete | None = None, cutoff: Incomplete | None = None): ... +def all_pairs_node_connectivity(G: Graph[_Node], nbunch: Iterable = None, cutoff: int = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/density.pyi b/stubs/networkx/networkx/algorithms/approximation/density.pyi index 309e46909ae7..64c1cf79ae25 100644 --- a/stubs/networkx/networkx/algorithms/approximation/density.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/density.pyi @@ -1,4 +1,5 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def densest_subgraph(G, iterations=1, *, method="greedy++"): ... +def densest_subgraph(G: Graph[_Node], iterations: int | None = 1, *, method: str | None = "greedy++"): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/distance_measures.pyi b/stubs/networkx/networkx/algorithms/approximation/distance_measures.pyi index 75b45b52003e..08662306c401 100644 --- a/stubs/networkx/networkx/algorithms/approximation/distance_measures.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/distance_measures.pyi @@ -1,6 +1,6 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable -def diameter(G, seed: Incomplete | None = None): ... +def diameter(G: Graph[_Node], seed: int | RandomState | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi b/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi index b08dc451db96..7ce548203b14 100644 --- a/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi @@ -1,8 +1,7 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def min_weighted_dominating_set(G, weight: Incomplete | None = None): ... +def min_weighted_dominating_set(G: Graph[_Node], weight: str = None): ... @_dispatchable -def min_edge_dominating_set(G): ... +def min_edge_dominating_set(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi index 46d89ff537d3..27bdc9efc106 100644 --- a/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi @@ -1,4 +1,5 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def k_components(G, min_density: float = 0.95): ... +def k_components(G: Graph[_Node], min_density: float = 0.95): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/matching.pyi b/stubs/networkx/networkx/algorithms/approximation/matching.pyi index 310ef31b91bf..798b8f0ac6be 100644 --- a/stubs/networkx/networkx/algorithms/approximation/matching.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/matching.pyi @@ -1,4 +1,5 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def min_maximal_matching(G): ... +def min_maximal_matching(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi b/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi index 760c114b4a41..d7b34635176e 100644 --- a/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi @@ -1,8 +1,8 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable -def randomized_partitioning(G, seed: Incomplete | None = None, p: float = 0.5, weight: Incomplete | None = None): ... +def randomized_partitioning(G: Graph[_Node], seed: int | RandomState | None = None, p: float = 0.5, weight: str = None): ... @_dispatchable -def one_exchange(G, initial_cut: Incomplete | None = None, seed: Incomplete | None = None, weight: Incomplete | None = None): ... +def one_exchange(G: Graph[_Node], initial_cut: set = None, seed: int | RandomState | None = None, weight: str = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/ramsey.pyi b/stubs/networkx/networkx/algorithms/approximation/ramsey.pyi index 5b85df65d7bb..1769ec99285b 100644 --- a/stubs/networkx/networkx/algorithms/approximation/ramsey.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/ramsey.pyi @@ -1,4 +1,5 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def ramsey_R2(G): ... +def ramsey_R2(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi b/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi index 03d0f6742be6..3c7e02bd889e 100644 --- a/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi @@ -1,8 +1,7 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def metric_closure(G, weight: str = "weight"): ... +def metric_closure(G: Graph[_Node], weight="weight"): ... @_dispatchable -def steiner_tree(G, terminal_nodes, weight: str = "weight", method: Incomplete | None = None): ... +def steiner_tree(G: Graph[_Node], terminal_nodes: list, weight: str = "weight", method: str | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi index c7775c382562..0d2178806b48 100644 --- a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi @@ -1,40 +1,45 @@ -from _typeshed import Incomplete +from collections.abc import Callable +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable -def christofides(G, weight: str = "weight", tree: Incomplete | None = None): ... +def christofides(G: Graph[_Node], weight: str | None = "weight", tree: Graph[_Node] = None): ... @_dispatchable def traveling_salesman_problem( - G, weight: str = "weight", nodes: Incomplete | None = None, cycle: bool = True, method: Incomplete | None = None, **kwargs + G: Graph[_Node], weight: str | None = "weight", nodes=None, cycle: bool = True, method: Callable = None, **kwargs ): ... @_dispatchable -def asadpour_atsp(G, weight: str = "weight", seed: Incomplete | None = None, source: Incomplete | None = None): ... +def asadpour_atsp( + G: DiGraph[_Node], weight: str | None = "weight", seed: int | RandomState | None = None, source: str = None +): ... @_dispatchable -def greedy_tsp(G, weight: str = "weight", source: Incomplete | None = None): ... +def greedy_tsp(G: Graph[_Node], weight: str | None = "weight", source=None): ... @_dispatchable def simulated_annealing_tsp( - G, + G: Graph[_Node], init_cycle, - weight: str = "weight", - source: Incomplete | None = None, - temp: float = 100, - move: str = "1-1", - max_iterations: int = 10, - N_inner: int = 100, - alpha: float = 0.01, - seed: Incomplete | None = None, + weight: str | None = "weight", + source=None, + temp: int | None = 100, + move="1-1", + max_iterations: int | None = 10, + N_inner: int | None = 100, + alpha=0.01, + seed: int | RandomState | None = None, ): ... @_dispatchable def threshold_accepting_tsp( - G, + G: Graph[_Node], init_cycle, - weight: str = "weight", - source: Incomplete | None = None, - threshold: float = 1, - move: str = "1-1", - max_iterations: int = 10, - N_inner: int = 100, - alpha: float = 0.1, - seed: Incomplete | None = None, + weight: str | None = "weight", + source=None, + threshold: int | None = 1, + move="1-1", + max_iterations: int | None = 10, + N_inner: int | None = 100, + alpha=0.1, + seed: int | RandomState | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi index 837a9ca4d87d..0b970f4c5cc1 100644 --- a/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi @@ -1,13 +1,14 @@ from _typeshed import Incomplete +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["treewidth_min_degree", "treewidth_min_fill_in"] @_dispatchable -def treewidth_min_degree(G): ... +def treewidth_min_degree(G: Graph[_Node]): ... @_dispatchable -def treewidth_min_fill_in(G): ... +def treewidth_min_fill_in(G: Graph[_Node]): ... class MinDegreeHeuristic: count: Incomplete diff --git a/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi b/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi index 22c5787bf983..26d3fb82b1bb 100644 --- a/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi @@ -1,6 +1,5 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def min_weighted_vertex_cover(G, weight: Incomplete | None = None): ... +def min_weighted_vertex_cover(G: Graph[_Node], weight: str | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi b/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi index 36c7f64e46e2..09b00989cb73 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi @@ -1,8 +1,9 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def average_degree_connectivity( - G, source: str = "in+out", target: str = "in+out", nodes: Incomplete | None = None, weight: Incomplete | None = None + G: Graph[_Node], source="in+out", target="in+out", nodes: Iterable = None, weight: str | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi index dec6b0595556..811177ed7d9d 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi @@ -1,16 +1,17 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def degree_assortativity_coefficient( - G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None + G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable = None ): ... @_dispatchable def degree_pearson_correlation_coefficient( - G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None + G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable = None ): ... @_dispatchable -def attribute_assortativity_coefficient(G, attribute, nodes: Incomplete | None = None): ... +def attribute_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable = None): ... @_dispatchable -def numeric_assortativity_coefficient(G, attribute, nodes: Incomplete | None = None): ... +def numeric_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable = None): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi index 06e19e1f68d5..c5ceb475d584 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi @@ -1,26 +1,27 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def attribute_mixing_dict(G, attribute, nodes: Incomplete | None = None, normalized: bool = False): ... +def attribute_mixing_dict(G: Graph[_Node], attribute: str, nodes: Iterable = None, normalized: bool = False): ... @_dispatchable def attribute_mixing_matrix( - G, attribute, nodes: Incomplete | None = None, mapping: Incomplete | None = None, normalized: bool = True + G: Graph[_Node], attribute: str, nodes: Iterable = None, mapping: dict | None = None, normalized: bool = True ): ... @_dispatchable def degree_mixing_dict( - G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None, normalized: bool = False + G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes=None, normalized: bool = False ): ... @_dispatchable def degree_mixing_matrix( - G, + G: Graph[_Node], x: str = "out", y: str = "in", - weight: Incomplete | None = None, - nodes: Incomplete | None = None, + weight: str | None = None, + nodes: Iterable = None, normalized: bool = True, - mapping: Incomplete | None = None, + mapping: dict | None = None, ): ... @_dispatchable 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 6cc1b1322d2a..95338ebe82cc 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi @@ -1,8 +1,13 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def average_neighbor_degree( - G, source: str = "out", target: str = "out", nodes: Incomplete | None = None, weight: Incomplete | None = None + G: Graph[_Node], + source: str | None = "out", + target: str | None = "out", + nodes: Iterable | None = None, + weight: str | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi b/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi index 569d52653ee5..36a97d6acd2f 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi @@ -1,11 +1,12 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Generator, Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def node_attribute_xy(G, attribute, nodes: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... +def node_attribute_xy(G: Graph[_Node], attribute, nodes: Iterable = None) -> Generator[Incomplete, None, None]: ... @_dispatchable def node_degree_xy( - G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None + G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable = None ) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/asteroidal.pyi b/stubs/networkx/networkx/algorithms/asteroidal.pyi index 4d12ecadaecd..21fdc6879686 100644 --- a/stubs/networkx/networkx/algorithms/asteroidal.pyi +++ b/stubs/networkx/networkx/algorithms/asteroidal.pyi @@ -1,6 +1,7 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def find_asteroidal_triple(G): ... +def find_asteroidal_triple(G: Graph[_Node]): ... @_dispatchable -def is_at_free(G): ... +def is_at_free(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/basic.pyi b/stubs/networkx/networkx/algorithms/bipartite/basic.pyi index f7fd955bb524..23bf3ef5ffba 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/basic.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/basic.pyi @@ -1,16 +1,17 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def color(G): ... +def color(G: Graph[_Node]): ... @_dispatchable -def is_bipartite(G): ... +def is_bipartite(G: Graph[_Node]): ... @_dispatchable -def is_bipartite_node_set(G, nodes): ... +def is_bipartite_node_set(G: Graph[_Node], nodes): ... @_dispatchable -def sets(G, top_nodes: Incomplete | None = None): ... +def sets(G: Graph[_Node], top_nodes: Iterable | None = None): ... @_dispatchable -def density(B, nodes): ... +def density(B: Graph[_Node], nodes): ... @_dispatchable -def degrees(B, nodes, weight: Incomplete | None = None): ... +def degrees(B: Graph[_Node], nodes, weight: str | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi b/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi index 9d011ac139c2..fdd6212831f1 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi @@ -1,8 +1,9 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def degree_centrality(G, nodes): ... +def degree_centrality(G: Graph[_Node], nodes): ... @_dispatchable -def betweenness_centrality(G, nodes): ... +def betweenness_centrality(G: Graph[_Node], nodes): ... @_dispatchable -def closeness_centrality(G, nodes, normalized: bool = True): ... +def closeness_centrality(G: Graph[_Node], nodes, normalized: bool | None = True): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi b/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi index e6d15445c985..e8d96845edf9 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi @@ -1,13 +1,14 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def latapy_clustering(G, nodes: Incomplete | None = None, mode: str = "dot"): ... +def latapy_clustering(G: Graph[_Node], nodes: Iterable = None, mode: str = "dot"): ... clustering = latapy_clustering @_dispatchable -def average_clustering(G, nodes: Incomplete | None = None, mode: str = "dot"): ... +def average_clustering(G: Graph[_Node], nodes: Iterable | None = None, mode: str = "dot"): ... @_dispatchable -def robins_alexander_clustering(G): ... +def robins_alexander_clustering(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/covering.pyi b/stubs/networkx/networkx/algorithms/bipartite/covering.pyi index 521e6d4956af..0ba573e44da6 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/covering.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/covering.pyi @@ -1,6 +1,7 @@ -from _typeshed import Incomplete +from collections.abc import Callable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def min_edge_cover(G, matching_algorithm: Incomplete | None = None): ... +def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable = None): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi b/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi index 009222121126..73ca8035db9e 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable @@ -10,20 +11,20 @@ def generate_edgelist(G, delimiter: str = " ", data: bool = True) -> Generator[I @_dispatchable def parse_edgelist( lines, - comments: str = "#", - delimiter: Incomplete | None = None, - create_using: Incomplete | None = None, - nodetype: Incomplete | None = None, - data: bool = True, + comments: str | None = "#", + delimiter: str | None = None, + create_using: Graph[_Node] | None = None, + nodetype=None, + data=True, ): ... @_dispatchable def read_edgelist( path, - comments: str = "#", - delimiter: Incomplete | None = None, - create_using: Incomplete | None = None, - nodetype: Incomplete | None = None, - data: bool = True, - edgetype: Incomplete | None = None, - encoding: str = "utf-8", + comments: str | None = "#", + delimiter: str | None = None, + create_using=None, + nodetype=None, + data=True, + edgetype=None, + encoding: str | None = "utf-8", ): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/extendability.pyi b/stubs/networkx/networkx/algorithms/bipartite/extendability.pyi index 36f3e6775c91..9bfee7872513 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/extendability.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/extendability.pyi @@ -1,4 +1,5 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def maximal_extendability(G): ... +def maximal_extendability(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/generators.pyi b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi index 9e1914567a50..a0cb2a039f9e 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/generators.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi @@ -1,20 +1,24 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable -def complete_bipartite_graph(n1, n2, create_using: Incomplete | None = None): ... +def complete_bipartite_graph(n1, n2, create_using: Graph[_Node] = None): ... @_dispatchable -def configuration_model(aseq, bseq, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... +def configuration_model( + aseq: list, bseq: list, create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None +): ... @_dispatchable -def havel_hakimi_graph(aseq, bseq, create_using: Incomplete | None = None): ... +def havel_hakimi_graph(aseq: list, bseq: list, create_using: Graph[_Node] | None = None): ... @_dispatchable -def reverse_havel_hakimi_graph(aseq, bseq, create_using: Incomplete | None = None): ... +def reverse_havel_hakimi_graph(aseq: list, bseq: list, create_using: Graph[_Node] | None = None): ... @_dispatchable -def alternating_havel_hakimi_graph(aseq, bseq, create_using: Incomplete | None = None): ... +def alternating_havel_hakimi_graph(aseq: list, bseq: list, create_using: Graph[_Node] | None = None): ... @_dispatchable -def preferential_attachment_graph(aseq, p, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... +def preferential_attachment_graph( + aseq: list, p: float, create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None +): ... @_dispatchable -def random_graph(n, m, p, seed: Incomplete | None = None, directed: bool = False): ... +def random_graph(n: int, m: int, p: float, seed: int | RandomState | None = None, directed: bool | None = False): ... @_dispatchable -def gnmk_random_graph(n, m, k, seed: Incomplete | None = None, directed: bool = False): ... +def gnmk_random_graph(n: int, m: int, k: int, seed: int | RandomState | None = None, directed: bool | None = False): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi index a731c33b88d2..2233cba25d15 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi @@ -1,15 +1,16 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def hopcroft_karp_matching(G, top_nodes: Incomplete | None = None): ... +def hopcroft_karp_matching(G: Graph[_Node], top_nodes: Iterable[_Node] = None): ... @_dispatchable -def eppstein_matching(G, top_nodes: Incomplete | None = None): ... +def eppstein_matching(G: Graph[_Node], top_nodes: Iterable = None): ... @_dispatchable -def to_vertex_cover(G, matching, top_nodes: Incomplete | None = None): ... +def to_vertex_cover(G: Graph[_Node], matching: dict, top_nodes: Iterable = None): ... maximum_matching = hopcroft_karp_matching @_dispatchable -def minimum_weight_full_matching(G, top_nodes: Incomplete | None = None, weight: str = "weight"): ... +def minimum_weight_full_matching(G: Graph[_Node], top_nodes: Iterable = None, weight: str | None = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi index 51a032fff0d8..558333db2319 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi @@ -1,15 +1,14 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def biadjacency_matrix( - G, - row_order, - column_order: Incomplete | None = None, - dtype: Incomplete | None = None, - weight: str = "weight", - format: str = "csr", + G: Graph[_Node], + row_order: list[_Node], + column_order: list | None = None, + dtype=None, + weight: str | None = "weight", + format="csr", ): ... @_dispatchable -def from_biadjacency_matrix(A, create_using: Incomplete | None = None, edge_attribute: str = "weight"): ... +def from_biadjacency_matrix(A, create_using: Graph[_Node] = None, edge_attribute: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/projection.pyi b/stubs/networkx/networkx/algorithms/bipartite/projection.pyi index 37712b7840a4..3ed76739f3f9 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/projection.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/projection.pyi @@ -1,14 +1,15 @@ -from _typeshed import Incomplete +from collections.abc import Callable, Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def projected_graph(B, nodes, multigraph: bool = False): ... +def projected_graph(B: Graph[_Node], nodes: Iterable, multigraph: bool = False): ... @_dispatchable -def weighted_projected_graph(B, nodes, ratio: bool = False): ... +def weighted_projected_graph(B: Graph[_Node], nodes: Iterable, ratio: bool = False): ... @_dispatchable -def collaboration_weighted_projected_graph(B, nodes): ... +def collaboration_weighted_projected_graph(B: Graph[_Node], nodes: Iterable): ... @_dispatchable -def overlap_weighted_projected_graph(B, nodes, jaccard: bool = True): ... +def overlap_weighted_projected_graph(B: Graph[_Node], nodes: Iterable, jaccard: bool = True): ... @_dispatchable -def generic_weighted_projected_graph(B, nodes, weight_function: Incomplete | None = None): ... +def generic_weighted_projected_graph(B: Graph[_Node], nodes: Iterable, weight_function: Callable = None): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi b/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi index 8c66512fc95a..12b023a7b43f 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi @@ -1,6 +1,7 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def node_redundancy(G, nodes: Incomplete | None = None): ... +def node_redundancy(G: Graph[_Node], nodes: Iterable = None): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi b/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi index 4a81f118acbf..c3060cce5cda 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi @@ -1,6 +1,5 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def spectral_bipartivity(G, nodes: Incomplete | None = None, weight: str = "weight"): ... +def spectral_bipartivity(G: Graph[_Node], nodes=None, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/boundary.pyi b/stubs/networkx/networkx/algorithms/boundary.pyi index 3b5cfa511a38..e746bd1182e5 100644 --- a/stubs/networkx/networkx/algorithms/boundary.pyi +++ b/stubs/networkx/networkx/algorithms/boundary.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from collections.abc import Generator, Iterable -from typing import Literal, TypeVar, overload +from typing import TypeVar, overload from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -9,107 +9,47 @@ _U = TypeVar("_U") @overload def edge_boundary( - G: Graph[_Node], - nbunch1: Iterable[_Node], - nbunch2: Iterable[_Node] | None = None, - data: Literal[False] = False, - keys: Literal[False] = False, - default=None, + G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None ) -> Generator[tuple[_Node, _Node], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], - nbunch1: Iterable[_Node], - nbunch2: Iterable[_Node] | None, - data: Literal[True], - keys: Literal[False] = False, - default=None, + G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None ) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], - nbunch1: Iterable[_Node], - nbunch2: Iterable[_Node] | None = None, - *, - data: Literal[True], - keys: Literal[False] = False, - default=None, + G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None ) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], - nbunch1: Iterable[_Node], - nbunch2: Iterable[_Node] | None, - data: str, - keys: Literal[False] = False, - default: _U | None = None, + G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None ) -> Generator[tuple[_Node, _Node, dict[str, _U]], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], - nbunch1: Iterable[_Node], - nbunch2: Iterable[_Node] | None = None, - *, - data: str, - keys: Literal[False] = False, - default: _U | None = None, + G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None ) -> Generator[tuple[_Node, _Node, dict[str, _U]], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], - nbunch1: Iterable[_Node], - nbunch2: Iterable[_Node] | None, - data: Literal[False], - keys: Literal[True], - default=None, + G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None ) -> Generator[tuple[_Node, _Node, int], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], - nbunch1: Iterable[_Node], - nbunch2: Iterable[_Node] | None = None, - data: Literal[False] = False, - *, - keys: Literal[True], - default=None, + G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None ) -> Generator[tuple[_Node, _Node, int], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], - nbunch1: Iterable[_Node], - nbunch2: Iterable[_Node] | None, - data: Literal[True], - keys: Literal[True], - default=None, + G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None ) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], - nbunch1: Iterable[_Node], - nbunch2: Iterable[_Node] | None = None, - *, - data: Literal[True], - keys: Literal[True], - default=None, + G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None ) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], - nbunch1: Iterable[_Node], - nbunch2: Iterable[_Node] | None, - data: str, - keys: Literal[True], - default: _U | None = None, + G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None ) -> Generator[tuple[_Node, _Node, int, dict[str, _U]], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], - nbunch1: Iterable[_Node], - nbunch2: Iterable[_Node] | None = None, - *, - data: str, - keys: Literal[True], - default: _U | None = None, + G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None ) -> Generator[tuple[_Node, _Node, int, dict[str, _U]], None, None]: ... @_dispatchable -def node_boundary(G: Graph[_Node], nbunch1: Iterable[_Node], nbunch2: Iterable[_Node] | None = None) -> set[_Node]: ... +def node_boundary(G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None) -> set[_Node]: ... diff --git a/stubs/networkx/networkx/algorithms/bridges.pyi b/stubs/networkx/networkx/algorithms/bridges.pyi index 35fa914d6f90..5a05424bf1ca 100644 --- a/stubs/networkx/networkx/algorithms/bridges.pyi +++ b/stubs/networkx/networkx/algorithms/bridges.pyi @@ -1,19 +1,16 @@ -from _typeshed import Incomplete -from collections.abc import Callable, Generator -from typing import Literal, overload +from collections.abc import Generator +from typing import overload from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def bridges(G: Graph[_Node], root: _Node | None = None) -> Generator[_Node, None, None]: ... +def bridges(G: Graph[_Node], root: _Node = None) -> Generator[_Node, None, None]: ... @_dispatchable -def has_bridges(G: Graph[_Node], root: Incomplete | None = None) -> bool: ... +def has_bridges(G: Graph[_Node], root: _Node = None) -> bool: ... @overload -def local_bridges( - G: Graph[_Node], with_span: Literal[False], weight: str | Callable[[_Node], float] | None = None -) -> Generator[tuple[_Node, _Node], None, None]: ... +def local_bridges(G: Graph[_Node], with_span: bool = True, weight: str = None) -> Generator[tuple[_Node, _Node], None, None]: ... @overload def local_bridges( - G: Graph[_Node], with_span: Literal[True] = True, weight: str | Callable[[_Node], float] | None = None + G: Graph[_Node], with_span: bool = True, weight: str = None ) -> Generator[tuple[_Node, _Node, int], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/betweenness.pyi b/stubs/networkx/networkx/algorithms/centrality/betweenness.pyi index 5475cfecb789..7d8351a67c5a 100644 --- a/stubs/networkx/networkx/algorithms/centrality/betweenness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/betweenness.pyi @@ -1,5 +1,3 @@ -from _typeshed import Incomplete - from networkx.classes.graph import Graph, _Edge, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState @@ -8,12 +6,16 @@ from numpy.random import RandomState def betweenness_centrality( G: Graph[_Node], k: int | None = None, - normalized: bool = True, + normalized: bool | None = True, weight: str | None = None, - endpoints: bool = False, + endpoints: bool | None = False, seed: int | RandomState | None = None, ) -> dict[_Node, float]: ... @_dispatchable def edge_betweenness_centrality( - G: Graph[_Node], k: int | None = None, normalized: bool = True, weight: str | None = None, seed: Incomplete | None = None + G: Graph[_Node], + k: int | None = None, + normalized: bool | None = True, + weight: str | None = None, + seed: int | RandomState | None = None, ) -> dict[_Edge[_Node], float]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi b/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi index 66abb8533ad4..1d183c8cc0de 100644 --- a/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi @@ -1,13 +1,11 @@ -from collections.abc import Iterable - from networkx.classes.graph import Graph, _Edge, _Node from networkx.utils.backends import _dispatchable @_dispatchable def betweenness_centrality_subset( - G: Graph[_Node], sources: Iterable[_Node], targets: Iterable[_Node], normalized: bool = False, weight: str | None = None + G: Graph[_Node], sources: list[_Node], targets: list[_Node], normalized: bool | None = False, weight: str | None = None ) -> dict[_Node, float]: ... @_dispatchable def edge_betweenness_centrality_subset( - G: Graph[_Node], sources: Iterable[_Node], targets: Iterable[_Node], normalized: bool = False, weight: str | None = None + G: Graph[_Node], sources: list[_Node], targets: list[_Node], normalized: bool | None = False, weight: str | None = None ) -> dict[_Edge[_Node], float]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi index 210e88bc7218..5735553ed4ef 100644 --- a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi @@ -1,17 +1,11 @@ -from _typeshed import SupportsKeysAndGetItem - -from networkx.classes.graph import Graph, _Edge, _Node +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def closeness_centrality( - G: Graph[_Node], u: _Node | None = None, distance: str | None = None, wf_improved: bool = True + G: Graph[_Node], u: _Node | None = None, distance=None, wf_improved: bool | None = True ) -> dict[_Node, float]: ... @_dispatchable def incremental_closeness_centrality( - G: Graph[_Node], - edge: _Edge[_Node], - prev_cc: SupportsKeysAndGetItem[_Node, float] | None = None, - insertion: bool = True, - wf_improved: bool = True, + G: Graph[_Node], edge: tuple, prev_cc: dict = None, insertion: bool | None = True, wf_improved: bool | None = True ) -> dict[_Node, float]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi index 612702be5b69..3995a217fefc 100644 --- a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi @@ -1,23 +1,23 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable def approximate_current_flow_betweenness_centrality( - G, - normalized: bool = True, - weight: Incomplete | None = None, - dtype=..., + G: Graph[_Node], + normalized: bool | None = True, + weight: str | None = None, + dtype: type = ..., solver: str = "full", epsilon: float = 0.5, kmax: int = 10000, - seed: Incomplete | None = None, + seed: int | RandomState | None = None, ): ... @_dispatchable def current_flow_betweenness_centrality( - G, normalized: bool = True, weight: Incomplete | None = None, dtype=..., solver: str = "full" + G: Graph[_Node], normalized: bool | None = True, weight: str | None = None, dtype: type = ..., solver: str = "full" ): ... @_dispatchable def edge_current_flow_betweenness_centrality( - G, normalized: bool = True, weight: Incomplete | None = None, dtype=..., solver: str = "full" + G: Graph[_Node], normalized: bool | None = True, weight: str | None = None, dtype: type = ..., 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 a34c8461d5c4..a0725bf6d757 100644 --- a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi @@ -1,12 +1,23 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def current_flow_betweenness_centrality_subset( - G, sources, targets, normalized: bool = True, weight: Incomplete | None = None, dtype=..., solver: str = "lu" + G: Graph[_Node], + sources: list[_Node], + targets: list[_Node], + normalized: bool | None = True, + weight: str | None = None, + dtype: type = ..., + solver: str = "lu", ): ... @_dispatchable def edge_current_flow_betweenness_centrality_subset( - G, sources, targets, normalized: bool = True, weight: Incomplete | None = None, dtype=..., solver: str = "lu" + G: Graph[_Node], + sources: list[_Node], + targets: list[_Node], + normalized: bool | None = True, + weight: str | None = None, + dtype: type = ..., + 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 81587a748915..534c06845d13 100644 --- a/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi @@ -1,8 +1,7 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def current_flow_closeness_centrality(G, weight: Incomplete | None = None, dtype=..., solver: str = "lu"): ... +def current_flow_closeness_centrality(G: Graph[_Node], weight: str | None = None, dtype: type = ..., solver: str = "lu"): ... information_centrality = current_flow_closeness_centrality diff --git a/stubs/networkx/networkx/algorithms/centrality/dispersion.pyi b/stubs/networkx/networkx/algorithms/centrality/dispersion.pyi index b673beb8778b..b2c9a9d5cb0e 100644 --- a/stubs/networkx/networkx/algorithms/centrality/dispersion.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/dispersion.pyi @@ -3,11 +3,5 @@ from networkx.utils.backends import _dispatchable @_dispatchable def dispersion( - G: Graph[_Node], - u: _Node | None = None, - v: _Node | None = None, - normalized: bool = True, - alpha: float = 1.0, - b: float = 0.0, - c: float = 0.0, + G: Graph[_Node], u: _Node | None = None, v: _Node | None = None, normalized: bool = True, alpha=1.0, b=0.0, c=0.0 ) -> dict[_Node, float] | dict[_Node, dict[_Node, float]]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi index cb0736e69f93..352ed9481992 100644 --- a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi @@ -1,10 +1,11 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def eigenvector_centrality( - G, max_iter: int = 100, tol: float = 1e-06, nstart: Incomplete | None = None, weight: Incomplete | None = None + G: Graph[_Node], max_iter: int | None = 100, tol: float | None = 1e-06, nstart: dict | None = None, weight: str | None = None ): ... @_dispatchable -def eigenvector_centrality_numpy(G, weight: Incomplete | None = None, max_iter: int = 50, tol: float = 0): ... +def eigenvector_centrality_numpy( + G: Graph[_Node], weight: str | None = None, max_iter: int | None = 50, tol: float | None = 0 +): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/group.pyi b/stubs/networkx/networkx/algorithms/centrality/group.pyi index a7cfa7a7c58a..f239ffabca7e 100644 --- a/stubs/networkx/networkx/algorithms/centrality/group.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/group.pyi @@ -1,24 +1,25 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def group_betweenness_centrality(G, C, normalized: bool = True, weight: Incomplete | None = None, endpoints: bool = False): ... +def group_betweenness_centrality( + G: Graph[_Node], C, normalized: bool | None = True, weight: str | None = None, endpoints: bool | None = False +): ... @_dispatchable def prominent_group( - G, - k, - weight: Incomplete | None = None, - C: Incomplete | None = None, - endpoints: bool = False, - normalized: bool = True, - greedy: bool = False, + G: Graph[_Node], + k: int, + weight: str | None = None, + C: list | set | None = None, + endpoints: bool | None = False, + normalized: bool | None = True, + greedy: bool | None = False, ): ... @_dispatchable -def group_closeness_centrality(G, S, weight: Incomplete | None = None): ... +def group_closeness_centrality(G: Graph[_Node], S: list | set, weight: str | None = None): ... @_dispatchable -def group_degree_centrality(G, S): ... +def group_degree_centrality(G: Graph[_Node], S: list | set): ... @_dispatchable -def group_in_degree_centrality(G, S): ... +def group_in_degree_centrality(G: Graph[_Node], S: list | set): ... @_dispatchable -def group_out_degree_centrality(G, S): ... +def group_out_degree_centrality(G: Graph[_Node], S: list | set): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi b/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi index cd2aa8ca1747..c8130c4a2306 100644 --- a/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi @@ -1,8 +1,7 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def harmonic_centrality( - G, nbunch: Incomplete | None = None, distance: Incomplete | None = None, sources: Incomplete | None = None -): ... +def harmonic_centrality(G: Graph[_Node], nbunch: Iterable = None, distance=None, sources: Iterable = None): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/katz.pyi b/stubs/networkx/networkx/algorithms/centrality/katz.pyi index 509456ff0ef9..069a2b4e4017 100644 --- a/stubs/networkx/networkx/algorithms/centrality/katz.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/katz.pyi @@ -1,19 +1,18 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def katz_centrality( - G, - alpha: float = 0.1, - beta: float = 1.0, - max_iter: int = 1000, - tol: float = 1e-06, - nstart: Incomplete | None = None, - normalized: bool = True, - weight: Incomplete | None = None, + G: Graph[_Node], + alpha: float | None = 0.1, + beta: float | dict | None = 1.0, + max_iter: int | None = 1000, + tol: float | None = 1e-06, + nstart: dict | None = None, + normalized: bool | None = True, + weight: str | None = None, ): ... @_dispatchable def katz_centrality_numpy( - G, alpha: float = 0.1, beta: float = 1.0, normalized: bool = True, weight: Incomplete | None = None + G: Graph[_Node], alpha: float = 0.1, beta: float | dict | None = 1.0, normalized: bool = True, weight: str | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi b/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi index a1a79318dcb2..53f022baff5d 100644 --- a/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi @@ -1,13 +1,12 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def laplacian_centrality( - G, + G: Graph[_Node], normalized: bool = True, - nodelist: Incomplete | None = None, - weight: str = "weight", - walk_type: Incomplete | None = None, + nodelist: list | None = None, + weight: str | None = "weight", + walk_type: str | None = None, alpha: float = 0.95, ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/load.pyi b/stubs/networkx/networkx/algorithms/centrality/load.pyi index a3cb20b97eae..cdec3b843e77 100644 --- a/stubs/networkx/networkx/algorithms/centrality/load.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/load.pyi @@ -1,15 +1,14 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["load_centrality", "edge_load_centrality"] @_dispatchable def newman_betweenness_centrality( - G, v: Incomplete | None = None, cutoff: Incomplete | None = None, normalized: bool = True, weight: Incomplete | None = None + G: Graph[_Node], v=None, cutoff: bool | None = None, normalized: bool | None = True, weight: str | None = None ): ... load_centrality = newman_betweenness_centrality @_dispatchable -def edge_load_centrality(G, cutoff: bool = False): ... +def edge_load_centrality(G: Graph[_Node], cutoff: bool | None = False): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/percolation.pyi b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi index b64230f68108..64a55fee3ef0 100644 --- a/stubs/networkx/networkx/algorithms/centrality/percolation.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi @@ -1,8 +1,7 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def percolation_centrality( - G, attribute: str = "percolation", states: Incomplete | None = None, weight: Incomplete | None = None + G: Graph[_Node], attribute: str | None = "percolation", states: dict | None = None, weight: str | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/reaching.pyi b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi index 4cb0a9ef7a59..ec9b7440f822 100644 --- a/stubs/networkx/networkx/algorithms/centrality/reaching.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi @@ -1,10 +1,10 @@ -from _typeshed import Incomplete - +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import _Node from networkx.utils.backends import _dispatchable @_dispatchable -def global_reaching_centrality(G, weight: Incomplete | None = None, normalized: bool = True): ... +def global_reaching_centrality(G: DiGraph[_Node], weight: str | None = None, normalized: bool | None = True): ... @_dispatchable def local_reaching_centrality( - G, v, paths: Incomplete | None = None, weight: Incomplete | None = None, normalized: bool = True + G: DiGraph[_Node], v: _Node, paths: dict = None, weight: str | None = None, normalized: bool | None = True ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/second_order.pyi b/stubs/networkx/networkx/algorithms/centrality/second_order.pyi index 32f37fabeabf..df8b706360c8 100644 --- a/stubs/networkx/networkx/algorithms/centrality/second_order.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/second_order.pyi @@ -1,4 +1,5 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def second_order_centrality(G): ... +def second_order_centrality(G: Graph[_Node], weight: str | None = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi b/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi index f826a0b38022..4035e39ea41d 100644 --- a/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi @@ -1,10 +1,11 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def subgraph_centrality_exp(G): ... +def subgraph_centrality_exp(G: Graph[_Node]): ... @_dispatchable -def subgraph_centrality(G): ... +def subgraph_centrality(G: Graph[_Node]): ... @_dispatchable -def communicability_betweenness_centrality(G): ... +def communicability_betweenness_centrality(G: Graph[_Node]): ... @_dispatchable -def estrada_index(G): ... +def estrada_index(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/trophic.pyi b/stubs/networkx/networkx/algorithms/centrality/trophic.pyi index efbd8e54f2a6..654ecef945be 100644 --- a/stubs/networkx/networkx/algorithms/centrality/trophic.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/trophic.pyi @@ -1,8 +1,10 @@ +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import _Node from networkx.utils.backends import _dispatchable @_dispatchable -def trophic_levels(G, weight: str = "weight"): ... +def trophic_levels(G: DiGraph[_Node], weight="weight"): ... @_dispatchable -def trophic_differences(G, weight: str = "weight"): ... +def trophic_differences(G: DiGraph[_Node], weight="weight"): ... @_dispatchable -def trophic_incoherence_parameter(G, weight: str = "weight", cannibalism: bool = False): ... +def trophic_incoherence_parameter(G: DiGraph[_Node], weight="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 c25d90ce7ea2..c313b9c8e60d 100644 --- a/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi @@ -1,6 +1,5 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def voterank(G, number_of_nodes: Incomplete | None = None): ... +def voterank(G: Graph[_Node], number_of_nodes: int | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/chains.pyi b/stubs/networkx/networkx/algorithms/chains.pyi index e7f99119c9d4..446a8896b241 100644 --- a/stubs/networkx/networkx/algorithms/chains.pyi +++ b/stubs/networkx/networkx/algorithms/chains.pyi @@ -4,4 +4,4 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def chain_decomposition(G: Graph[_Node], root: _Node | None = None) -> Generator[list[tuple[_Node, _Node]], None, None]: ... +def chain_decomposition(G: Graph[_Node], root: _Node = 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 ba37c5b35b58..264e5c769a5d 100644 --- a/stubs/networkx/networkx/algorithms/chordal.pyi +++ b/stubs/networkx/networkx/algorithms/chordal.pyi @@ -1,5 +1,5 @@ import sys -from collections.abc import Generator, Hashable +from collections.abc import Generator from networkx.classes.graph import Graph, _Node from networkx.exception import NetworkXException @@ -8,10 +8,10 @@ from networkx.utils.backends import _dispatchable class NetworkXTreewidthBoundExceeded(NetworkXException): ... @_dispatchable -def is_chordal(G: Graph[Hashable]) -> bool: ... +def is_chordal(G: Graph[_Node]) -> bool: ... @_dispatchable def find_induced_nodes(G: Graph[_Node], s: _Node, t: _Node, treewidth_bound: float = sys.maxsize) -> set[_Node]: ... @_dispatchable def chordal_graph_cliques(G: Graph[_Node]) -> Generator[frozenset[_Node], None, None]: ... @_dispatchable -def chordal_graph_treewidth(G: Graph[Hashable]) -> int: ... +def chordal_graph_treewidth(G: Graph[_Node]) -> int: ... diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi index bacc2dbe5522..e6e1204ac8e0 100644 --- a/stubs/networkx/networkx/algorithms/clique.pyi +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -1,5 +1,4 @@ -from _typeshed import SupportsGetItem, Unused -from collections.abc import Generator, Iterable, Iterator, Sized +from collections.abc import Generator, Iterator from typing import overload from networkx.classes.graph import Graph, _Node @@ -8,23 +7,16 @@ from networkx.utils.backends import _dispatchable @_dispatchable def enumerate_all_cliques(G: Graph[_Node]) -> Generator[list[_Node], None, None]: ... @_dispatchable -def find_cliques(G: Graph[_Node], nodes: SupportsGetItem[slice, _Node] | None = None) -> Generator[list[_Node], None, None]: ... +def find_cliques(G: Graph[_Node], nodes: list | None = None) -> Generator[list[_Node], None, None]: ... @_dispatchable -def find_cliques_recursive(G: Graph[_Node], nodes: SupportsGetItem[slice, _Node] | None = None) -> Iterator[list[_Node]]: ... +def find_cliques_recursive(G: Graph[_Node], nodes: list | None = None) -> Iterator[list[_Node]]: ... @_dispatchable -def make_max_clique_graph(G: Graph[_Node], create_using: type[Graph[_Node]] | None = None) -> Graph[_Node]: ... +def make_max_clique_graph(G: Graph[_Node], create_using: Graph[_Node] | None = None) -> Graph[_Node]: ... @_dispatchable def make_clique_bipartite( - G: Graph[_Node], fpos: Unused = None, create_using: type[Graph[_Node]] | None = None, name: Unused = None + G: Graph[_Node], fpos: bool = None, create_using: Graph[_Node] | None = None, name=None ) -> Graph[_Node]: ... @overload -def node_clique_number( - G: Graph[_Node], - nodes: Iterable[_Node] | None = None, - cliques: Iterable[Iterable[_Node]] | None = None, - separate_nodes: Unused = False, -) -> dict[_Node, int]: ... +def node_clique_number(G: Graph[_Node], nodes=None, cliques: list | None = None, separate_nodes=False) -> dict[_Node, int]: ... @overload -def node_clique_number( - G: Graph[_Node], nodes: _Node, cliques: Iterable[Sized] | None = None, separate_nodes: Unused = False -) -> int: ... +def node_clique_number(G: Graph[_Node], nodes=None, cliques: list | None = None, separate_nodes=False) -> int: ... diff --git a/stubs/networkx/networkx/algorithms/cluster.pyi b/stubs/networkx/networkx/algorithms/cluster.pyi index d0dc06de3ce9..4558712c7761 100644 --- a/stubs/networkx/networkx/algorithms/cluster.pyi +++ b/stubs/networkx/networkx/algorithms/cluster.pyi @@ -1,16 +1,19 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def triangles(G, nodes: Incomplete | None = None): ... +def triangles(G: Graph[_Node], nodes=None): ... @_dispatchable -def average_clustering(G, nodes: Incomplete | None = None, weight: Incomplete | None = None, count_zeros: bool = True): ... +def average_clustering( + G: Graph[_Node], nodes: Iterable[_Node] | None = None, weight: str | None = None, count_zeros: bool = True +): ... @_dispatchable -def clustering(G, nodes: Incomplete | None = None, weight: Incomplete | None = None): ... +def clustering(G: Graph[_Node], nodes=None, weight: str | None = None): ... @_dispatchable -def transitivity(G): ... +def transitivity(G: Graph[_Node]): ... @_dispatchable -def square_clustering(G, nodes: Incomplete | None = None): ... +def square_clustering(G: Graph[_Node], nodes: Iterable[_Node] | None = None): ... @_dispatchable -def generalized_degree(G, nodes: Incomplete | None = None): ... +def generalized_degree(G: Graph[_Node], nodes: Iterable[_Node] | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi b/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi index 94f61af53c5b..488bcd7fa6ba 100644 --- a/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi +++ b/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi @@ -1,4 +1,5 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def equitable_color(G, num_colors): ... +def equitable_color(G: Graph[_Node], num_colors): ... diff --git a/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi b/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi index f6e9b68a3fae..0ce06b531e84 100644 --- a/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi +++ b/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = [ @@ -32,25 +33,4 @@ def strategy_connected_sequential(G, colors, traversal: str = "bfs") -> Generato @_dispatchable def strategy_saturation_largest_first(G, colors) -> Generator[Incomplete, None, Incomplete]: ... @_dispatchable -def greedy_color(G, strategy: str = "largest_first", interchange: bool = False): ... - -class _Node: - node_id: Incomplete - color: int - adj_list: Incomplete - adj_color: Incomplete - - def __init__(self, node_id, n) -> None: ... - def assign_color(self, adj_entry, color) -> None: ... - def clear_color(self, adj_entry, color) -> None: ... - def iter_neighbors(self) -> Generator[Incomplete, None, None]: ... - def iter_neighbors_color(self, color) -> Generator[Incomplete, None, None]: ... - -class _AdjEntry: - node_id: Incomplete - next: Incomplete - mate: Incomplete - col_next: Incomplete - col_prev: Incomplete - - def __init__(self, node_id) -> None: ... +def greedy_color(G: Graph[_Node], strategy="largest_first", interchange: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/communicability_alg.pyi b/stubs/networkx/networkx/algorithms/communicability_alg.pyi index 9eede08f8535..a36df0c93379 100644 --- a/stubs/networkx/networkx/algorithms/communicability_alg.pyi +++ b/stubs/networkx/networkx/algorithms/communicability_alg.pyi @@ -1,6 +1,7 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def communicability(G): ... +def communicability(G: Graph[_Node]): ... @_dispatchable -def communicability_exp(G): ... +def communicability_exp(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi b/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi index d78fdc2db5e5..17a087cd6ce5 100644 --- a/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi +++ b/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi @@ -1,6 +1,6 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable -def asyn_fluidc(G, k, max_iter: int = 100, seed: Incomplete | None = None): ... +def asyn_fluidc(G: Graph[_Node], k: int, max_iter: int = 100, seed: int | RandomState | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/community/centrality.pyi b/stubs/networkx/networkx/algorithms/community/centrality.pyi index b6b2712c1f62..6d84d21bc781 100644 --- a/stubs/networkx/networkx/algorithms/community/centrality.pyi +++ b/stubs/networkx/networkx/algorithms/community/centrality.pyi @@ -1,7 +1,8 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Callable, Generator +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def girvan_newman(G, most_valuable_edge: Incomplete | None = None) -> Generator[Incomplete, None, Incomplete]: ... +def girvan_newman(G: Graph[_Node], most_valuable_edge: Callable = 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 882dbf8ab1bf..2528f102b3b6 100644 --- a/stubs/networkx/networkx/algorithms/community/community_utils.pyi +++ b/stubs/networkx/networkx/algorithms/community/community_utils.pyi @@ -1,4 +1,5 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def is_partition(G, communities): ... +def is_partition(G: Graph[_Node], communities): ... diff --git a/stubs/networkx/networkx/algorithms/community/divisive.pyi b/stubs/networkx/networkx/algorithms/community/divisive.pyi index 6eeed32d21ab..ee026d06003a 100644 --- a/stubs/networkx/networkx/algorithms/community/divisive.pyi +++ b/stubs/networkx/networkx/algorithms/community/divisive.pyi @@ -1,10 +1,13 @@ from _typeshed import Incomplete import networkx as nx +from networkx.classes.graph import Graph, _Node __all__ = ["edge_betweenness_partition", "edge_current_flow_betweenness_partition"] @nx._dispatchable -def edge_betweenness_partition(G, number_of_sets: int, *, weight: Incomplete | None = None) -> list[Incomplete]: ... +def edge_betweenness_partition(G: Graph[_Node], number_of_sets: int, *, weight: str = None) -> list[Incomplete]: ... @nx._dispatchable -def edge_current_flow_betweenness_partition(G, number_of_sets: int, *, weight: Incomplete | None = None) -> list[Incomplete]: ... +def edge_current_flow_betweenness_partition( + G: Graph[_Node], number_of_sets: int, *, weight: str | None = None +) -> list[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/community/kclique.pyi b/stubs/networkx/networkx/algorithms/community/kclique.pyi index 39bc56a86fad..13c777be295e 100644 --- a/stubs/networkx/networkx/algorithms/community/kclique.pyi +++ b/stubs/networkx/networkx/algorithms/community/kclique.pyi @@ -1,7 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def k_clique_communities(G, k, cliques: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... +def k_clique_communities(G: Graph[_Node], k: int, cliques=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 cd15c6541079..5518aabdbd14 100644 --- a/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi +++ b/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi @@ -1,8 +1,8 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable def kernighan_lin_bisection( - G, partition: Incomplete | None = None, max_iter: int = 10, weight: str = "weight", seed: Incomplete | None = None + G: Graph[_Node], partition: tuple = None, max_iter: int = 10, weight: str = "weight", seed: int | RandomState | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/community/label_propagation.pyi b/stubs/networkx/networkx/algorithms/community/label_propagation.pyi index c79a95fd2829..094de0795753 100644 --- a/stubs/networkx/networkx/algorithms/community/label_propagation.pyi +++ b/stubs/networkx/networkx/algorithms/community/label_propagation.pyi @@ -1,11 +1,13 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable def asyn_lpa_communities( - G, weight: Incomplete | None = None, seed: Incomplete | None = None + G: Graph[_Node], weight: str = None, seed: int | RandomState | None = None ) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable -def label_propagation_communities(G): ... +def label_propagation_communities(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/community/leiden.pyi b/stubs/networkx/networkx/algorithms/community/leiden.pyi index 2aa7eace3cf2..d3365cb63f4c 100644 --- a/stubs/networkx/networkx/algorithms/community/leiden.pyi +++ b/stubs/networkx/networkx/algorithms/community/leiden.pyi @@ -1,6 +1,16 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable -def leiden_communities(G, weight="weight", resolution=1, max_level=None, seed=None): ... +def leiden_communities( + G: Graph[_Node], + weight: str | None = "weight", + resolution: float | None = 1, + max_level: int | None = None, + seed: int | RandomState | None = None, +): ... @_dispatchable -def leiden_partitions(G, weight="weight", resolution=1, seed=None): ... +def leiden_partitions( + G: Graph[_Node], weight: str | None = "weight", resolution: float | None = 1, seed: int | RandomState | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/community/louvain.pyi b/stubs/networkx/networkx/algorithms/community/louvain.pyi index e086829b451e..be5194a9174a 100644 --- a/stubs/networkx/networkx/algorithms/community/louvain.pyi +++ b/stubs/networkx/networkx/algorithms/community/louvain.pyi @@ -1,13 +1,24 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable def louvain_communities( - G, weight: str = "weight", resolution: float = 1, threshold: float = 1e-07, seed: Incomplete | None = None + G: Graph[_Node], + weight: str | None = "weight", + resolution: float | None = 1, + threshold: float | None = 1e-07, + max_level: int | None = None, + seed: int | RandomState | None = None, ): ... @_dispatchable def louvain_partitions( - G, weight: str = "weight", resolution: float = 1, threshold: float = 1e-07, seed: Incomplete | None = None + G: Graph[_Node], + weight: str | None = "weight", + resolution: float | None = 1, + threshold: float | None = 1e-07, + seed: int | RandomState | 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 0044043faf7c..81a7a1335170 100644 --- a/stubs/networkx/networkx/algorithms/community/lukes.pyi +++ b/stubs/networkx/networkx/algorithms/community/lukes.pyi @@ -1,6 +1,5 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def lukes_partitioning(G, max_size, node_weight: Incomplete | None = None, edge_weight: Incomplete | None = None): ... +def lukes_partitioning(G: Graph[_Node], max_size: int, node_weight=None, edge_weight=None): ... diff --git a/stubs/networkx/networkx/algorithms/community/modularity_max.pyi b/stubs/networkx/networkx/algorithms/community/modularity_max.pyi index 9842451eaba9..b93dbf52033a 100644 --- a/stubs/networkx/networkx/algorithms/community/modularity_max.pyi +++ b/stubs/networkx/networkx/algorithms/community/modularity_max.pyi @@ -1,10 +1,9 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def greedy_modularity_communities( - G, weight: Incomplete | None = None, resolution: float = 1, cutoff: int = 1, best_n: Incomplete | None = None + G: Graph[_Node], weight: str | None = None, resolution: float | None = 1, cutoff: int | None = 1, best_n: int | None = None ): ... @_dispatchable -def naive_greedy_modularity_communities(G, resolution: float = 1, weight: Incomplete | None = None): ... +def naive_greedy_modularity_communities(G: Graph[_Node], resolution: float = 1, weight: str | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/community/quality.pyi b/stubs/networkx/networkx/algorithms/community/quality.pyi index 12f9e93f2f50..2ce826f6e83e 100644 --- a/stubs/networkx/networkx/algorithms/community/quality.pyi +++ b/stubs/networkx/networkx/algorithms/community/quality.pyi @@ -1,3 +1,4 @@ +from networkx.classes.graph import Graph, _Node from networkx.exception import NetworkXError from networkx.utils.backends import _dispatchable @@ -7,6 +8,6 @@ class NotAPartition(NetworkXError): def __init__(self, G, collection) -> None: ... @_dispatchable -def modularity(G, communities, weight: str = "weight", resolution: float = 1): ... +def modularity(G: Graph[_Node], communities, weight: str | None = "weight", resolution: float = 1): ... @_dispatchable -def partition_quality(G, partition): ... +def partition_quality(G: Graph[_Node], partition): ... diff --git a/stubs/networkx/networkx/algorithms/components/biconnected.pyi b/stubs/networkx/networkx/algorithms/components/biconnected.pyi index 1f58e5d23192..782f1c69014b 100644 --- a/stubs/networkx/networkx/algorithms/components/biconnected.pyi +++ b/stubs/networkx/networkx/algorithms/components/biconnected.pyi @@ -1,13 +1,14 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def is_biconnected(G): ... +def is_biconnected(G: Graph[_Node]): ... @_dispatchable -def biconnected_component_edges(G) -> Generator[Incomplete, Incomplete, None]: ... +def biconnected_component_edges(G: Graph[_Node]) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable -def biconnected_components(G) -> Generator[Incomplete, None, None]: ... +def biconnected_components(G: Graph[_Node]) -> Generator[Incomplete, None, None]: ... @_dispatchable -def articulation_points(G) -> Generator[Incomplete, None, None]: ... +def articulation_points(G: Graph[_Node]) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/components/connected.pyi b/stubs/networkx/networkx/algorithms/components/connected.pyi index 240517110407..67a380977343 100644 --- a/stubs/networkx/networkx/algorithms/components/connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/connected.pyi @@ -1,13 +1,14 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def connected_components(G) -> Generator[Incomplete, None, None]: ... +def connected_components(G: Graph[_Node]) -> Generator[Incomplete, None, None]: ... @_dispatchable -def number_connected_components(G): ... +def number_connected_components(G: Graph[_Node]): ... @_dispatchable -def is_connected(G): ... +def is_connected(G: Graph[_Node]): ... @_dispatchable -def node_connected_component(G, n): ... +def node_connected_component(G: Graph[_Node], n: str): ... diff --git a/stubs/networkx/networkx/algorithms/components/semiconnected.pyi b/stubs/networkx/networkx/algorithms/components/semiconnected.pyi index 2a65d32221aa..178a602e4e47 100644 --- a/stubs/networkx/networkx/algorithms/components/semiconnected.pyi +++ b/stubs/networkx/networkx/algorithms/components/semiconnected.pyi @@ -1,6 +1,5 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def is_semiconnected(G, topo_order: Incomplete | None = None): ... +def is_semiconnected(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi index 93d76806aed3..4747f4950e01 100644 --- a/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi @@ -1,4 +1,4 @@ -from collections.abc import Generator, Hashable, Iterable +from collections.abc import Generator from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node @@ -7,10 +7,10 @@ from networkx.utils.backends import _dispatchable @_dispatchable def strongly_connected_components(G: Graph[_Node]) -> Generator[set[_Node], None, None]: ... @_dispatchable -def kosaraju_strongly_connected_components(G: Graph[_Node], source: _Node | None = None) -> Generator[set[_Node], None, None]: ... +def kosaraju_strongly_connected_components(G: Graph[_Node], source=None) -> Generator[set[_Node], None, None]: ... @_dispatchable -def number_strongly_connected_components(G: Graph[Hashable]) -> int: ... +def number_strongly_connected_components(G: Graph[_Node]) -> int: ... @_dispatchable -def is_strongly_connected(G: Graph[Hashable]) -> bool: ... +def is_strongly_connected(G: Graph[_Node]) -> bool: ... @_dispatchable -def condensation(G: DiGraph[_Node], scc: Iterable[Iterable[_Node]] | None = None) -> DiGraph[int]: ... +def condensation(G: DiGraph[_Node], scc=None) -> DiGraph[int]: ... diff --git a/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi b/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi index 66c4f7b61dfe..84cccf2f0250 100644 --- a/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi @@ -1,4 +1,4 @@ -from collections.abc import Generator, Hashable +from collections.abc import Generator from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -6,6 +6,6 @@ from networkx.utils.backends import _dispatchable @_dispatchable def weakly_connected_components(G: Graph[_Node]) -> Generator[set[_Node], None, None]: ... @_dispatchable -def number_weakly_connected_components(G: Graph[Hashable]) -> int: ... +def number_weakly_connected_components(G: Graph[_Node]) -> int: ... @_dispatchable -def is_weakly_connected(G: Graph[Hashable]) -> bool: ... +def is_weakly_connected(G: Graph[_Node]) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi index 3840e14a1dc0..511c953ab8bf 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi @@ -1,6 +1,8 @@ -from _typeshed import Incomplete +from collections.abc import Callable, Iterable from networkx.algorithms.flow import edmonds_karp +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = [ @@ -15,35 +17,31 @@ default_flow_func = edmonds_karp @_dispatchable def local_node_connectivity( - G, - s, - t, - flow_func: Incomplete | None = None, - auxiliary: Incomplete | None = None, - residual: Incomplete | None = None, - cutoff: Incomplete | None = None, + G: Graph[_Node], + s: _Node, + t: _Node, + flow_func: Callable = None, + auxiliary: DiGraph[_Node] = None, + residual: DiGraph[_Node] = None, + cutoff: float | None = None, ): ... @_dispatchable -def node_connectivity(G, s: Incomplete | None = None, t: Incomplete | None = None, flow_func: Incomplete | None = None): ... +def node_connectivity(G: Graph[_Node], s: _Node = None, t: _Node = None, flow_func: Callable = None): ... @_dispatchable -def average_node_connectivity(G, flow_func: Incomplete | None = None): ... +def average_node_connectivity(G: Graph[_Node], flow_func: Callable = None): ... @_dispatchable -def all_pairs_node_connectivity(G, nbunch: Incomplete | None = None, flow_func: Incomplete | None = None): ... +def all_pairs_node_connectivity(G: Graph[_Node], nbunch: Iterable = None, flow_func: Callable = None): ... @_dispatchable def local_edge_connectivity( - G, - s, - t, - flow_func: Incomplete | None = None, - auxiliary: Incomplete | None = None, - residual: Incomplete | None = None, - cutoff: Incomplete | None = None, + G: Graph[_Node], + s: _Node, + t: _Node, + flow_func: Callable = None, + auxiliary: DiGraph[_Node] = None, + residual: DiGraph[_Node] = None, + cutoff: float | None = None, ): ... @_dispatchable def edge_connectivity( - G, - s: Incomplete | None = None, - t: Incomplete | None = None, - flow_func: Incomplete | None = None, - cutoff: Incomplete | None = None, + G: Graph[_Node], s: _Node = None, t: _Node = None, flow_func: Callable = None, cutoff: float | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi index b50cc37f60c4..6e889357726f 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi @@ -1,6 +1,8 @@ -from _typeshed import Incomplete +from collections.abc import Callable from networkx.algorithms.flow import edmonds_karp +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["minimum_st_node_cut", "minimum_node_cut", "minimum_st_edge_cut", "minimum_edge_cut"] @@ -8,13 +10,23 @@ default_flow_func = edmonds_karp @_dispatchable def minimum_st_edge_cut( - G, s, t, flow_func: Incomplete | None = None, auxiliary: Incomplete | None = None, residual: Incomplete | None = None + G: Graph[_Node], + s: _Node, + t: _Node, + flow_func: Callable = None, + auxiliary: DiGraph[_Node] = None, + residual: DiGraph[_Node] = None, ): ... @_dispatchable def minimum_st_node_cut( - G, s, t, flow_func: Incomplete | None = None, auxiliary: Incomplete | None = None, residual: Incomplete | None = None + G: Graph[_Node], + s: _Node, + t: _Node, + flow_func: Callable = None, + auxiliary: DiGraph[_Node] = None, + residual: DiGraph[_Node] = None, ): ... @_dispatchable -def minimum_node_cut(G, s: Incomplete | None = None, t: Incomplete | None = None, flow_func: Incomplete | None = None): ... +def minimum_node_cut(G: Graph[_Node], s: _Node = None, t: _Node = None, flow_func: Callable = None): ... @_dispatchable -def minimum_edge_cut(G, s: Incomplete | None = None, t: Incomplete | None = None, flow_func: Incomplete | None = None): ... +def minimum_edge_cut(G: Graph[_Node], s: _Node = None, t: _Node = None, flow_func: Callable = None): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi b/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi index 79e7f7e4e18f..bbb80f8e94ab 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi @@ -1,7 +1,9 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Callable, Generator from networkx.algorithms.flow import edmonds_karp +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["edge_disjoint_paths", "node_disjoint_paths"] @@ -9,21 +11,21 @@ default_flow_func = edmonds_karp @_dispatchable def edge_disjoint_paths( - G, - s, - t, - flow_func: Incomplete | None = None, - cutoff: Incomplete | None = None, - auxiliary: Incomplete | None = None, - residual: Incomplete | None = None, + G: Graph[_Node], + s: _Node, + t: _Node, + flow_func: Callable = None, + cutoff: int | None = None, + auxiliary: DiGraph[_Node] = None, + residual: DiGraph[_Node] = None, ) -> Generator[Incomplete, None, None]: ... @_dispatchable def node_disjoint_paths( - G, - s, - t, - flow_func: Incomplete | None = None, - cutoff: Incomplete | None = None, - auxiliary: Incomplete | None = None, - residual: Incomplete | None = None, + G: Graph[_Node], + s: _Node, + t: _Node, + flow_func: Callable = None, + cutoff: int | None = None, + auxiliary: DiGraph[_Node] = None, + residual: DiGraph[_Node] = None, ) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi index fe32ff99d112..0c90a95e874a 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -1,17 +1,17 @@ -from collections.abc import Generator, Hashable +from collections.abc import Generator from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def is_k_edge_connected(G: Graph[Hashable], k: int): ... +def is_k_edge_connected(G: Graph[_Node], k: int): ... @_dispatchable -def is_locally_k_edge_connected(G, s, t, k): ... +def is_locally_k_edge_connected(G: Graph[_Node], s: _Node, t: _Node, k: int): ... @_dispatchable def k_edge_augmentation( G: Graph[_Node], k: int, - avail: tuple[_Node, _Node] | tuple[_Node, _Node, dict[str, int]] | None = None, - weight: str | None = None, + avail: set[tuple[int, int]] | set[tuple[int, int, float]] | dict[tuple[int, int], float] = None, + weight: str = None, partial: bool = False, ) -> Generator[tuple[_Node, _Node], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi index 68b1f8d0adb3..60544bc7a79c 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi @@ -1,14 +1,15 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def k_edge_components(G, k): ... +def k_edge_components(G: Graph[_Node], k: int): ... @_dispatchable -def k_edge_subgraphs(G, k): ... +def k_edge_subgraphs(G: Graph[_Node], k: int): ... @_dispatchable -def bridge_components(G) -> Generator[Incomplete, Incomplete, None]: ... +def bridge_components(G: Graph[_Node]) -> Generator[Incomplete, Incomplete, None]: ... class EdgeComponentAuxGraph: A: Incomplete @@ -16,5 +17,5 @@ class EdgeComponentAuxGraph: @classmethod def construct(cls, G): ... - def k_edge_components(self, k) -> Generator[Incomplete, Incomplete, None]: ... - def k_edge_subgraphs(self, k) -> Generator[Incomplete, Incomplete, None]: ... + def k_edge_components(G: Graph[_Node], k: int) -> Generator[Incomplete, Incomplete, None]: ... + def k_edge_subgraphs(G: Graph[_Node], k: int) -> Generator[Incomplete, Incomplete, None]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi index 694a28cb3c5f..713096bd55eb 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi @@ -1,10 +1,11 @@ -from _typeshed import Incomplete +from collections.abc import Callable from networkx.algorithms.flow import edmonds_karp +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["k_components"] default_flow_func = edmonds_karp @_dispatchable -def k_components(G, flow_func: Incomplete | None = None): ... +def k_components(G: Graph[_Node], flow_func: Callable = None): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi b/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi index 21ccb3525415..22bfca236a9c 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi @@ -1,11 +1,12 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Callable, Generator from networkx.algorithms.flow import edmonds_karp +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["all_node_cuts"] default_flow_func = edmonds_karp @_dispatchable -def all_node_cuts(G, k: Incomplete | None = None, flow_func: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... +def all_node_cuts(G: Graph[_Node], k: int = None, flow_func: Callable = None) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/stoerwagner.pyi b/stubs/networkx/networkx/algorithms/connectivity/stoerwagner.pyi index 1bd01705dec3..c0b8cd3a733c 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/stoerwagner.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/stoerwagner.pyi @@ -1,4 +1,5 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def stoer_wagner(G, weight: str = "weight", heap=...): ... +def stoer_wagner(G: Graph[_Node], weight: str = "weight", heap: type = ...): ... diff --git a/stubs/networkx/networkx/algorithms/core.pyi b/stubs/networkx/networkx/algorithms/core.pyi index 44bde570425a..93a85034524b 100644 --- a/stubs/networkx/networkx/algorithms/core.pyi +++ b/stubs/networkx/networkx/algorithms/core.pyi @@ -1,18 +1,17 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def core_number(G): ... +def core_number(G: Graph[_Node]): ... @_dispatchable -def k_core(G, k: Incomplete | None = None, core_number: Incomplete | None = None): ... +def k_core(G: Graph[_Node], k: int | None = None, core_number: dict | None = None): ... @_dispatchable -def k_shell(G, k: Incomplete | None = None, core_number: Incomplete | None = None): ... +def k_shell(G: Graph[_Node], k: int | None = None, core_number: dict | None = None): ... @_dispatchable -def k_crust(G, k: Incomplete | None = None, core_number: Incomplete | None = None): ... +def k_crust(G: Graph[_Node], k: int | None = None, core_number: dict | None = None): ... @_dispatchable -def k_corona(G, k, core_number: Incomplete | None = None): ... +def k_corona(G: Graph[_Node], k: int, core_number: dict | None = None): ... @_dispatchable -def k_truss(G, k): ... +def k_truss(G: Graph[_Node], k: int): ... @_dispatchable -def onion_layers(G): ... +def onion_layers(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/covering.pyi b/stubs/networkx/networkx/algorithms/covering.pyi index 8b50c52a1b37..6518f4362ac8 100644 --- a/stubs/networkx/networkx/algorithms/covering.pyi +++ b/stubs/networkx/networkx/algorithms/covering.pyi @@ -1,8 +1,9 @@ -from _typeshed import Incomplete +from collections.abc import Callable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def min_edge_cover(G, matching_algorithm: Incomplete | None = None): ... +def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable = None): ... @_dispatchable -def is_edge_cover(G, cover): ... +def is_edge_cover(G: Graph[_Node], cover: set): ... diff --git a/stubs/networkx/networkx/algorithms/cuts.pyi b/stubs/networkx/networkx/algorithms/cuts.pyi index 11ef7637a259..a3302d16a8b8 100644 --- a/stubs/networkx/networkx/algorithms/cuts.pyi +++ b/stubs/networkx/networkx/algorithms/cuts.pyi @@ -1,20 +1,21 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def cut_size(G, S, T: Incomplete | None = None, weight: Incomplete | None = None): ... +def cut_size(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] = None, weight: str = None): ... @_dispatchable -def volume(G, S, weight: Incomplete | None = None): ... +def volume(G: Graph[_Node], S: Iterable[_Node], weight: str = None): ... @_dispatchable -def normalized_cut_size(G, S, T: Incomplete | None = None, weight: Incomplete | None = None): ... +def normalized_cut_size(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] = None, weight: str = None): ... @_dispatchable -def conductance(G, S, T: Incomplete | None = None, weight: Incomplete | None = None): ... +def conductance(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] = None, weight: str = None): ... @_dispatchable -def edge_expansion(G, S, T: Incomplete | None = None, weight: Incomplete | None = None): ... +def edge_expansion(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] = None, weight: str = None): ... @_dispatchable -def mixing_expansion(G, S, T: Incomplete | None = None, weight: Incomplete | None = None): ... +def mixing_expansion(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] = None, weight: str = None): ... @_dispatchable -def node_expansion(G, S): ... +def node_expansion(G: Graph[_Node], S: Iterable[_Node]): ... @_dispatchable -def boundary_expansion(G, S): ... +def boundary_expansion(G: Graph[_Node], S: Iterable[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/cycles.pyi b/stubs/networkx/networkx/algorithms/cycles.pyi index be263e37302f..5a32c2f03a6a 100644 --- a/stubs/networkx/networkx/algorithms/cycles.pyi +++ b/stubs/networkx/networkx/algorithms/cycles.pyi @@ -1,12 +1,14 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def cycle_basis(G, root: Incomplete | None = None): ... +def cycle_basis(G: Graph[_Node], root: _Node | None = None): ... @_dispatchable -def simple_cycles(G, length_bound: Incomplete | None = None) -> Generator[Incomplete, Incomplete, None]: ... +def simple_cycles(G: Graph[_Node], length_bound: int | None = None) -> Generator[Incomplete, Incomplete, None]: ... class _NeighborhoodCache(dict[Incomplete, Incomplete]): G: Incomplete @@ -15,10 +17,10 @@ class _NeighborhoodCache(dict[Incomplete, Incomplete]): def __missing__(self, v): ... @_dispatchable -def chordless_cycles(G, length_bound: Incomplete | None = None) -> Generator[Incomplete, Incomplete, None]: ... +def chordless_cycles(G: DiGraph[_Node], length_bound: int | None = None) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable -def recursive_simple_cycles(G): ... +def recursive_simple_cycles(G: DiGraph[_Node]): ... @_dispatchable -def find_cycle(G, source: Incomplete | None = None, orientation: Incomplete | None = None): ... +def find_cycle(G: Graph[_Node], source=None, orientation=None): ... @_dispatchable -def minimum_cycle_basis(G, weight: Incomplete | None = None): ... +def minimum_cycle_basis(G: Graph[_Node], weight: str = None): ... diff --git a/stubs/networkx/networkx/algorithms/d_separation.pyi b/stubs/networkx/networkx/algorithms/d_separation.pyi index c672127feb42..e1eb575409fd 100644 --- a/stubs/networkx/networkx/algorithms/d_separation.pyi +++ b/stubs/networkx/networkx/algorithms/d_separation.pyi @@ -1,3 +1,5 @@ +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import _Node from networkx.utils.backends import _dispatchable @_dispatchable @@ -5,4 +7,4 @@ def d_separated(G, x, y, z): ... @_dispatchable def minimal_d_separator(G, u, v): ... @_dispatchable -def is_minimal_d_separator(G, u, v, z): ... +def is_minimal_d_separator(G: DiGraph[_Node], x, y, z, *, included=None, restricted=None): ... diff --git a/stubs/networkx/networkx/algorithms/dag.pyi b/stubs/networkx/networkx/algorithms/dag.pyi index b85fff5cb09b..746f90429d14 100644 --- a/stubs/networkx/networkx/algorithms/dag.pyi +++ b/stubs/networkx/networkx/algorithms/dag.pyi @@ -1,14 +1,13 @@ -from _typeshed import SupportsRichComparison -from collections.abc import Callable, Generator, Iterable, Reversible +from collections.abc import Callable, Generator from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def descendants(G: Graph[_Node], source: _Node) -> set[_Node]: ... +def descendants(G: Graph[_Node], source) -> set[_Node]: ... @_dispatchable -def ancestors(G: Graph[_Node], source: _Node) -> set[_Node]: ... +def ancestors(G: Graph[_Node], source) -> set[_Node]: ... @_dispatchable def is_directed_acyclic_graph(G: Graph[_Node]) -> bool: ... @_dispatchable @@ -16,26 +15,24 @@ def topological_generations(G: DiGraph[_Node]) -> Generator[list[_Node], None, N @_dispatchable def topological_sort(G: DiGraph[_Node]) -> Generator[_Node, None, None]: ... @_dispatchable -def lexicographical_topological_sort( - G: DiGraph[_Node], key: Callable[[_Node], SupportsRichComparison] | None = None -) -> Generator[_Node, None, None]: ... +def lexicographical_topological_sort(G: DiGraph[_Node], key: Callable | None = None) -> Generator[_Node, None, None]: ... @_dispatchable def all_topological_sorts(G: DiGraph[_Node]) -> Generator[list[_Node], None, None]: ... @_dispatchable def is_aperiodic(G: DiGraph[_Node]) -> bool: ... @_dispatchable -def transitive_closure(G: Graph[_Node], reflexive: bool = False) -> Graph[_Node]: ... +def transitive_closure(G: Graph[_Node], reflexive=False) -> Graph[_Node]: ... @_dispatchable -def transitive_closure_dag(G: DiGraph[_Node], reflexive: bool = False) -> DiGraph[_Node]: ... +def transitive_closure_dag(G: DiGraph[_Node], topo_order: list | tuple | None = None) -> DiGraph[_Node]: ... @_dispatchable def transitive_reduction(G: DiGraph[_Node]) -> DiGraph[_Node]: ... @_dispatchable -def antichains(G: DiGraph[_Node], topo_order: Reversible[_Node] | None = None) -> Generator[list[_Node], None, None]: ... +def antichains(G: DiGraph[_Node], topo_order: list | tuple | None = None) -> Generator[list[_Node], None, None]: ... @_dispatchable def dag_longest_path( - G: DiGraph[_Node], weight: str = "weight", default_weight: int = 1, topo_order: Iterable[_Node] | None = None + G: DiGraph[_Node], weight: str | None = "weight", default_weight: int | None = 1, topo_order: list | tuple | None = None ) -> list[_Node]: ... @_dispatchable -def dag_longest_path_length(G: DiGraph[_Node], weight: str = "weight", default_weight: int = 1) -> int: ... +def dag_longest_path_length(G: DiGraph[_Node], weight: str | None = "weight", default_weight: int | None = 1) -> int: ... @_dispatchable def dag_to_branching(G: Graph[_Node]) -> Graph[_Node]: ... diff --git a/stubs/networkx/networkx/algorithms/distance_measures.pyi b/stubs/networkx/networkx/algorithms/distance_measures.pyi index 35e356e71cb7..8a38bbafb98a 100644 --- a/stubs/networkx/networkx/algorithms/distance_measures.pyi +++ b/stubs/networkx/networkx/algorithms/distance_measures.pyi @@ -1,18 +1,17 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def eccentricity(G, v: Incomplete | None = None, sp: Incomplete | None = None, weight: Incomplete | None = None): ... +def eccentricity(G: Graph[_Node], v: _Node | None = None, sp=None, weight: str = None): ... @_dispatchable -def diameter(G, e: Incomplete | None = None, usebounds: bool = False, weight: Incomplete | None = None): ... +def diameter(G: Graph[_Node], e=None, usebounds=False, weight: str = None): ... @_dispatchable -def periphery(G, e: Incomplete | None = None, usebounds: bool = False, weight: Incomplete | None = None): ... +def periphery(G: Graph[_Node], e=None, usebounds=False, weight: str = None): ... @_dispatchable -def radius(G, e: Incomplete | None = None, usebounds: bool = False, weight: Incomplete | None = None): ... +def radius(G: Graph[_Node], e=None, usebounds=False, weight: str = None): ... @_dispatchable -def center(G, e: Incomplete | None = None, usebounds: bool = False, weight: Incomplete | None = None): ... +def center(G: Graph[_Node], e=None, usebounds=False, weight: str = None): ... @_dispatchable -def barycenter(G, weight: Incomplete | None = None, attr: Incomplete | None = None, sp: Incomplete | None = None): ... +def barycenter(G, weight: str | None = None, attr=None, sp=None): ... @_dispatchable -def resistance_distance(G, nodeA, nodeB, weight: Incomplete | None = None, invert_weight: bool = True): ... +def resistance_distance(G: Graph[_Node], nodeA=None, nodeB=None, weight: str | 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 e477deb4a0cb..182d37110f07 100644 --- a/stubs/networkx/networkx/algorithms/distance_regular.pyi +++ b/stubs/networkx/networkx/algorithms/distance_regular.pyi @@ -1,10 +1,11 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def is_distance_regular(G): ... +def is_distance_regular(G: Graph[_Node]): ... @_dispatchable def global_parameters(b, c): ... @_dispatchable -def intersection_array(G): ... +def intersection_array(G: Graph[_Node]): ... @_dispatchable -def is_strongly_regular(G): ... +def is_strongly_regular(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/dominance.pyi b/stubs/networkx/networkx/algorithms/dominance.pyi index a87b0172e7da..415485b28b8c 100644 --- a/stubs/networkx/networkx/algorithms/dominance.pyi +++ b/stubs/networkx/networkx/algorithms/dominance.pyi @@ -1,6 +1,7 @@ +from networkx.classes.graph import _Node from networkx.utils.backends import _dispatchable @_dispatchable -def immediate_dominators(G, start): ... +def immediate_dominators(G, start: _Node): ... @_dispatchable -def dominance_frontiers(G, start): ... +def dominance_frontiers(G, start: _Node): ... diff --git a/stubs/networkx/networkx/algorithms/dominating.pyi b/stubs/networkx/networkx/algorithms/dominating.pyi index 0f9535464f32..3ff16c116ee5 100644 --- a/stubs/networkx/networkx/algorithms/dominating.pyi +++ b/stubs/networkx/networkx/algorithms/dominating.pyi @@ -1,8 +1,9 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def dominating_set(G, start_with: Incomplete | None = None): ... +def dominating_set(G: Graph[_Node], start_with: _Node = None): ... @_dispatchable -def is_dominating_set(G, nbunch): ... +def is_dominating_set(G: Graph[_Node], nbunch: Iterable): ... diff --git a/stubs/networkx/networkx/algorithms/euler.pyi b/stubs/networkx/networkx/algorithms/euler.pyi index b88b278cc30e..0e8552402c8d 100644 --- a/stubs/networkx/networkx/algorithms/euler.pyi +++ b/stubs/networkx/networkx/algorithms/euler.pyi @@ -1,17 +1,20 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def is_eulerian(G): ... +def is_eulerian(G: Graph[_Node]): ... @_dispatchable def is_semieulerian(G): ... @_dispatchable -def eulerian_circuit(G, source: Incomplete | None = None, keys: bool = False) -> Generator[Incomplete, Incomplete, None]: ... +def eulerian_circuit( + G: Graph[_Node], source: _Node | None = None, keys: bool = False +) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable -def has_eulerian_path(G, source: Incomplete | None = None): ... +def has_eulerian_path(G: Graph[_Node], source: _Node | None = None): ... @_dispatchable -def eulerian_path(G, source: Incomplete | None = None, keys: bool = False) -> Generator[Incomplete, Incomplete, None]: ... +def eulerian_path(G: Graph[_Node], source=None, keys: bool = False) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable -def eulerize(G): ... +def eulerize(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi b/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi index f5a6c21b3f23..62ffa03704f1 100644 --- a/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi +++ b/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi @@ -1,14 +1,13 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def boykov_kolmogorov( - G, - s, - t, + G: Graph[_Node], + s: _Node, + t: _Node, capacity: str = "capacity", - residual: Incomplete | None = None, + residual: Graph[_Node] = None, value_only: bool = False, - cutoff: Incomplete | None = None, + cutoff: float = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi b/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi index 36918442e80e..8f5b3bef312a 100644 --- a/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi +++ b/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi @@ -1,4 +1,7 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def capacity_scaling(G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight", heap=...): ... +def capacity_scaling( + G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight", heap: type = ... +): ... diff --git a/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi b/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi index 2a37c2973077..9dc076e68ad4 100644 --- a/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi +++ b/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi @@ -1,14 +1,13 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def dinitz( - G, - s, - t, + G: Graph[_Node], + s: _Node, + t: _Node, capacity: str = "capacity", - residual: Incomplete | None = None, + residual: Graph[_Node] = None, value_only: bool = False, - cutoff: Incomplete | None = None, + cutoff: float = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi b/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi index 0989f90f39d3..e444eeaf285a 100644 --- a/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi +++ b/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi @@ -1,14 +1,13 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def edmonds_karp( - G, - s, - t, + G: Graph[_Node], + s: _Node, + t: _Node, capacity: str = "capacity", - residual: Incomplete | None = None, + residual: Graph[_Node] = None, value_only: bool = False, - cutoff: Incomplete | None = None, + cutoff: float = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi b/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi index 86dbddc3c2b1..880e39f72fc0 100644 --- a/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi +++ b/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi @@ -1,5 +1,6 @@ -from _typeshed import Incomplete +from collections.abc import Callable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from .edmondskarp import edmonds_karp @@ -8,4 +9,4 @@ __all__ = ["gomory_hu_tree"] default_flow_func = edmonds_karp @_dispatchable -def gomory_hu_tree(G, capacity: str = "capacity", flow_func: Incomplete | None = None): ... +def gomory_hu_tree(G: Graph[_Node], capacity: str = "capacity", flow_func: Callable = None): ... diff --git a/stubs/networkx/networkx/algorithms/flow/maxflow.pyi b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi index ac77657c0ead..6f38269c5d02 100644 --- a/stubs/networkx/networkx/algorithms/flow/maxflow.pyi +++ b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi @@ -1,5 +1,6 @@ -from _typeshed import Incomplete +from collections.abc import Callable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from .preflowpush import preflow_push @@ -8,10 +9,14 @@ __all__ = ["maximum_flow", "maximum_flow_value", "minimum_cut", "minimum_cut_val default_flow_func = preflow_push @_dispatchable -def maximum_flow(flowG, _s, _t, capacity: str = "capacity", flow_func: Incomplete | None = None, **kwargs): ... +def maximum_flow(flowG: Graph[_Node], _s: _Node, _t: _Node, capacity: str = "capacity", flow_func: Callable = None, **kwargs): ... @_dispatchable -def maximum_flow_value(flowG, _s, _t, capacity: str = "capacity", flow_func: Incomplete | None = None, **kwargs): ... +def maximum_flow_value( + flowG: Graph[_Node], _s: _Node, _t: _Node, capacity: str = "capacity", flow_func: Callable = None, **kwargs +): ... @_dispatchable -def minimum_cut(flowG, _s, _t, capacity: str = "capacity", flow_func: Incomplete | None = None, **kwargs): ... +def minimum_cut(flowG: Graph[_Node], _s: _Node, _t: _Node, capacity: str = "capacity", flow_func: Callable = None, **kwargs): ... @_dispatchable -def minimum_cut_value(flowG, _s, _t, capacity: str = "capacity", flow_func: Incomplete | None = None, **kwargs): ... +def minimum_cut_value( + flowG: Graph[_Node], _s: _Node, _t: _Node, capacity: str = "capacity", flow_func: Callable = None, **kwargs +): ... diff --git a/stubs/networkx/networkx/algorithms/flow/mincost.pyi b/stubs/networkx/networkx/algorithms/flow/mincost.pyi index 41f70569369b..4433ed4761f4 100644 --- a/stubs/networkx/networkx/algorithms/flow/mincost.pyi +++ b/stubs/networkx/networkx/algorithms/flow/mincost.pyi @@ -1,10 +1,11 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def min_cost_flow_cost(G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... +def min_cost_flow_cost(G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... @_dispatchable -def min_cost_flow(G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... +def min_cost_flow(G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... @_dispatchable -def cost_of_flow(G, flowDict, weight: str = "weight"): ... +def cost_of_flow(G: Graph[_Node], flowDict: dict, weight: str = "weight"): ... @_dispatchable -def max_flow_min_cost(G, s, t, capacity: str = "capacity", weight: str = "weight"): ... +def max_flow_min_cost(G: Graph[_Node], s: str, t: str, 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 36573daa7ade..b9cf6bae5b18 100644 --- a/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi +++ b/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable class _DataEssentialsAndFunctions: @@ -40,4 +41,4 @@ class _DataEssentialsAndFunctions: def find_leaving_edge(self, Wn, We): ... @_dispatchable -def network_simplex(G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... +def network_simplex(G: Graph[_Node], 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 51547a1c03a1..bb57ff3c3de9 100644 --- a/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi +++ b/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi @@ -1,14 +1,13 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def preflow_push( - G, - s, - t, + G: Graph[_Node], + s: _Node, + t: _Node, capacity: str = "capacity", - residual: Incomplete | None = None, + residual: Graph[_Node] = None, global_relabel_freq: float = 1, value_only: bool = False, ): ... diff --git a/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi b/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi index 93fdf09f637c..51502388deb3 100644 --- a/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi +++ b/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi @@ -1,15 +1,14 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def shortest_augmenting_path( - G, - s, - t, + G: Graph[_Node], + s: _Node, + t: _Node, capacity: str = "capacity", - residual: Incomplete | None = None, + residual: Graph[_Node] = None, value_only: bool = False, two_phase: bool = False, - cutoff: Incomplete | None = None, + cutoff: float = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/graph_hashing.pyi b/stubs/networkx/networkx/algorithms/graph_hashing.pyi index 218bf2f6a0d5..98b93f08f7b1 100644 --- a/stubs/networkx/networkx/algorithms/graph_hashing.pyi +++ b/stubs/networkx/networkx/algorithms/graph_hashing.pyi @@ -1,12 +1,20 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def weisfeiler_lehman_graph_hash( - G, edge_attr: Incomplete | None = None, node_attr: Incomplete | None = None, iterations: int = 3, digest_size: int = 16 + G: Graph[_Node], + edge_attr: str | None = None, + node_attr: str | None = None, + iterations: int | None = 3, + digest_size: int | None = 16, ): ... @_dispatchable def weisfeiler_lehman_subgraph_hashes( - G, edge_attr: Incomplete | None = None, node_attr: Incomplete | None = None, iterations: int = 3, digest_size: int = 16 + G: Graph[_Node], + edge_attr: str | None = None, + node_attr: str | None = None, + iterations: int | None = 3, + digest_size: int | None = 16, + include_initial_labels: bool | None = False, ): ... diff --git a/stubs/networkx/networkx/algorithms/graphical.pyi b/stubs/networkx/networkx/algorithms/graphical.pyi index 5f886377b9b7..51d9b3628577 100644 --- a/stubs/networkx/networkx/algorithms/graphical.pyi +++ b/stubs/networkx/networkx/algorithms/graphical.pyi @@ -1,14 +1,16 @@ +from collections.abc import Iterable + from networkx.utils.backends import _dispatchable @_dispatchable -def is_graphical(sequence, method: str = "eg"): ... +def is_graphical(sequence: Iterable, method="eg"): ... @_dispatchable -def is_valid_degree_sequence_havel_hakimi(deg_sequence): ... +def is_valid_degree_sequence_havel_hakimi(deg_sequence: list): ... @_dispatchable -def is_valid_degree_sequence_erdos_gallai(deg_sequence): ... +def is_valid_degree_sequence_erdos_gallai(deg_sequence: list): ... @_dispatchable -def is_multigraphical(sequence): ... +def is_multigraphical(sequence: list): ... @_dispatchable -def is_pseudographical(sequence): ... +def is_pseudographical(sequence: Iterable): ... @_dispatchable -def is_digraphical(in_sequence, out_sequence): ... +def is_digraphical(in_sequence: Iterable, out_sequence: Iterable): ... diff --git a/stubs/networkx/networkx/algorithms/hierarchy.pyi b/stubs/networkx/networkx/algorithms/hierarchy.pyi index 09f4dc139b70..e747ffc5109e 100644 --- a/stubs/networkx/networkx/algorithms/hierarchy.pyi +++ b/stubs/networkx/networkx/algorithms/hierarchy.pyi @@ -1,6 +1,4 @@ -from _typeshed import Incomplete - from networkx.utils.backends import _dispatchable @_dispatchable -def flow_hierarchy(G, weight: Incomplete | None = None): ... +def flow_hierarchy(G, weight: str | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/hybrid.pyi b/stubs/networkx/networkx/algorithms/hybrid.pyi index 3bbc857d1feb..171162022da3 100644 --- a/stubs/networkx/networkx/algorithms/hybrid.pyi +++ b/stubs/networkx/networkx/algorithms/hybrid.pyi @@ -1,6 +1,7 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def kl_connected_subgraph(G, k, l, low_memory: bool = False, same_as_graph: bool = False): ... +def kl_connected_subgraph(G: Graph[_Node], k: int, l: int, low_memory: bool = False, same_as_graph: bool = False): ... @_dispatchable -def is_kl_connected(G, k, l, low_memory: bool = False): ... +def is_kl_connected(G: Graph[_Node], k: int, l: int, low_memory: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/isolate.pyi b/stubs/networkx/networkx/algorithms/isolate.pyi index 1030cb1c5bb4..d08ac5b19588 100644 --- a/stubs/networkx/networkx/algorithms/isolate.pyi +++ b/stubs/networkx/networkx/algorithms/isolate.pyi @@ -1,8 +1,9 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def is_isolate(G, n): ... +def is_isolate(G: Graph[_Node], n: _Node): ... @_dispatchable -def isolates(G): ... +def isolates(G: Graph[_Node]): ... @_dispatchable -def number_of_isolates(G): ... +def number_of_isolates(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi b/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi index 895b71cb59af..7e09b7b20ccf 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi @@ -1,4 +1,4 @@ -from _typeshed import Incomplete +from collections.abc import Callable from networkx.utils.backends import _dispatchable @@ -20,4 +20,4 @@ def faster_could_be_isomorphic(G1, G2): ... faster_graph_could_be_isomorphic = faster_could_be_isomorphic @_dispatchable -def is_isomorphic(G1, G2, node_match: Incomplete | None = None, edge_match: Incomplete | None = None): ... +def is_isomorphic(G1, G2, node_match: Callable = None, edge_match: Callable = None): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi b/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi index 8c56107e1774..5cfad7cd15cd 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi @@ -1,6 +1,7 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def rooted_tree_isomorphism(t1, root1, t2, root2): ... @_dispatchable -def tree_isomorphism(t1, t2): ... +def tree_isomorphism(t1: Graph[_Node], t2: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi b/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi index d8916fbadba8..0725e20af60c 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi @@ -26,10 +26,10 @@ class _StateParameters(NamedTuple): T2_tilde_in: Incomplete @_dispatchable -def vf2pp_isomorphism(G1, G2, node_label: Incomplete | None = None, default_label: Incomplete | None = None): ... +def vf2pp_isomorphism(G1, G2, node_label: str | None = None, default_label: float = None): ... @_dispatchable -def vf2pp_is_isomorphic(G1, G2, node_label: Incomplete | None = None, default_label: Incomplete | None = None): ... +def vf2pp_is_isomorphic(G1, G2, node_label: str | None = None, default_label: float = None): ... @_dispatchable def vf2pp_all_isomorphisms( - G1, G2, node_label: Incomplete | None = None, default_label: Incomplete | None = None + G1, G2, node_label: str | None = None, default_label: float = 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 d2dba97399b5..98b41a0cde94 100644 --- a/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi +++ b/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi @@ -1,6 +1,7 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def hits(G, max_iter: int = 100, tol: float = 1e-08, nstart: Incomplete | None = None, normalized: bool = True): ... +def hits( + G: Graph[_Node], max_iter: int | None = 100, tol: float | None = 1e-08, nstart: dict | 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 2ed3765aecce..ba00ec654cfb 100644 --- a/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi +++ b/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi @@ -1,24 +1,23 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def pagerank( - G, - alpha: float = 0.85, - personalization: Incomplete | None = None, - max_iter: int = 100, - tol: float = 1e-06, - nstart: Incomplete | None = None, - weight: str = "weight", - dangling: Incomplete | None = None, + G: Graph[_Node], + alpha: float | None = 0.85, + personalization: dict | None = None, + max_iter: int | None = 100, + tol: float | None = 1e-06, + nstart: dict | None = None, + weight: str | None = "weight", + dangling: dict | None = None, ): ... @_dispatchable def google_matrix( - G, + G: Graph[_Node], alpha: float = 0.85, - personalization: Incomplete | None = None, - nodelist: Incomplete | None = None, - weight: str = "weight", - dangling: Incomplete | None = None, + personalization: dict | None = None, + nodelist: list | None = None, + weight: str | None = "weight", + dangling: dict | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/link_prediction.pyi b/stubs/networkx/networkx/algorithms/link_prediction.pyi index 1ef94518386e..6c298d3ca531 100644 --- a/stubs/networkx/networkx/algorithms/link_prediction.pyi +++ b/stubs/networkx/networkx/algorithms/link_prediction.pyi @@ -1,20 +1,19 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def resource_allocation_index(G, ebunch: Incomplete | None = None): ... +def resource_allocation_index(G: Graph[_Node], ebunch=None): ... @_dispatchable -def jaccard_coefficient(G, ebunch: Incomplete | None = None): ... +def jaccard_coefficient(G: Graph[_Node], ebunch=None): ... @_dispatchable -def adamic_adar_index(G, ebunch: Incomplete | None = None): ... +def adamic_adar_index(G: Graph[_Node], ebunch=None): ... @_dispatchable -def common_neighbor_centrality(G, ebunch: Incomplete | None = None, alpha: float = 0.8): ... +def common_neighbor_centrality(G: Graph[_Node], ebunch=None, alpha=0.8): ... @_dispatchable -def preferential_attachment(G, ebunch: Incomplete | None = None): ... +def preferential_attachment(G: Graph[_Node], ebunch=None): ... @_dispatchable -def cn_soundarajan_hopcroft(G, ebunch: Incomplete | None = None, community: str = "community"): ... +def cn_soundarajan_hopcroft(G: Graph[_Node], ebunch=None, community: str | None = "community"): ... @_dispatchable -def ra_index_soundarajan_hopcroft(G, ebunch: Incomplete | None = None, community: str = "community"): ... +def ra_index_soundarajan_hopcroft(G: Graph[_Node], ebunch=None, community: str | None = "community"): ... @_dispatchable -def within_inter_cluster(G, ebunch: Incomplete | None = None, delta: float = 0.001, community: str = "community"): ... +def within_inter_cluster(G: Graph[_Node], ebunch=None, delta: float | None = 0.001, community: str | None = "community"): ... diff --git a/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi b/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi index 700a7fce8c73..20bc7e989578 100644 --- a/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi +++ b/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi @@ -1,13 +1,12 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.classes.graph import _Node from networkx.utils.backends import _dispatchable @_dispatchable -def all_pairs_lowest_common_ancestor(G, pairs: Incomplete | None = None): ... +def all_pairs_lowest_common_ancestor(G, pairs=None): ... @_dispatchable -def lowest_common_ancestor(G, node1, node2, default: Incomplete | None = None): ... +def lowest_common_ancestor(G, node1, node2, default: object = None): ... @_dispatchable -def tree_all_pairs_lowest_common_ancestor( - G, root: Incomplete | None = None, pairs: Incomplete | None = None -) -> Generator[Incomplete, None, None]: ... +def tree_all_pairs_lowest_common_ancestor(G, root: _Node | None = None, pairs=None) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/matching.pyi b/stubs/networkx/networkx/algorithms/matching.pyi index ba797a5a12b3..cf7301679632 100644 --- a/stubs/networkx/networkx/algorithms/matching.pyi +++ b/stubs/networkx/networkx/algorithms/matching.pyi @@ -1,14 +1,15 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def maximal_matching(G): ... +def maximal_matching(G: Graph[_Node]): ... @_dispatchable -def is_matching(G, matching): ... +def is_matching(G: Graph[_Node], matching): ... @_dispatchable -def is_maximal_matching(G, matching): ... +def is_maximal_matching(G: Graph[_Node], matching): ... @_dispatchable -def is_perfect_matching(G, matching): ... +def is_perfect_matching(G: Graph[_Node], matching): ... @_dispatchable -def min_weight_matching(G, weight: str = "weight"): ... +def min_weight_matching(G: Graph[_Node], weight: str | None = "weight"): ... @_dispatchable -def max_weight_matching(G, maxcardinality: bool = False, weight: str = "weight"): ... +def max_weight_matching(G: Graph[_Node], maxcardinality: bool | None = False, weight: str | None = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/minors/contraction.pyi b/stubs/networkx/networkx/algorithms/minors/contraction.pyi index c76c1b1b5d48..541e0a955e6b 100644 --- a/stubs/networkx/networkx/algorithms/minors/contraction.pyi +++ b/stubs/networkx/networkx/algorithms/minors/contraction.pyi @@ -1,23 +1,25 @@ -from _typeshed import Incomplete +from collections.abc import Callable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def equivalence_classes(iterable, relation): ... @_dispatchable def quotient_graph( - G, + G: Graph[_Node], partition, - edge_relation: Incomplete | None = None, - node_data: Incomplete | None = None, - edge_data: Incomplete | None = None, + edge_relation=None, + node_data: Callable = None, + edge_data: Callable = None, + weight: str | None = "weight", relabel: bool = False, - create_using: Incomplete | None = None, + create_using: Graph[_Node] | None = None, ): ... @_dispatchable -def contracted_nodes(G, u, v, self_loops: bool = True, copy: bool = True): ... +def contracted_nodes(G: Graph[_Node], u, v, self_loops: bool = True, copy: bool = True): ... identified_nodes = contracted_nodes @_dispatchable -def contracted_edge(G, edge, self_loops: bool = True, copy: bool = True): ... +def contracted_edge(G: Graph[_Node], edge: tuple, self_loops: bool = True, copy: bool = True): ... diff --git a/stubs/networkx/networkx/algorithms/mis.pyi b/stubs/networkx/networkx/algorithms/mis.pyi index 1d4b262dde29..a876fbb3eb17 100644 --- a/stubs/networkx/networkx/algorithms/mis.pyi +++ b/stubs/networkx/networkx/algorithms/mis.pyi @@ -1,6 +1,8 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable -def maximal_independent_set(G, nodes: Incomplete | None = None, seed: Incomplete | None = None): ... +def maximal_independent_set(G: Graph[_Node], nodes: Iterable = None, seed: int | RandomState | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/moral.pyi b/stubs/networkx/networkx/algorithms/moral.pyi index 570061651f86..626c6c3f0393 100644 --- a/stubs/networkx/networkx/algorithms/moral.pyi +++ b/stubs/networkx/networkx/algorithms/moral.pyi @@ -1,4 +1,5 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def moral_graph(G): ... +def moral_graph(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/node_classification.pyi b/stubs/networkx/networkx/algorithms/node_classification.pyi index 510c72a25e3d..45f0e4df7886 100644 --- a/stubs/networkx/networkx/algorithms/node_classification.pyi +++ b/stubs/networkx/networkx/algorithms/node_classification.pyi @@ -1,6 +1,7 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def harmonic_function(G, max_iter: int = 30, label_name: str = "label"): ... +def harmonic_function(G: Graph[_Node], max_iter: int = 30, label_name: str = "label"): ... @_dispatchable -def local_and_global_consistency(G, alpha: float = 0.99, max_iter: int = 30, label_name: str = "label"): ... +def local_and_global_consistency(G: Graph[_Node], 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 5e0941436883..8955afa75810 100644 --- a/stubs/networkx/networkx/algorithms/non_randomness.pyi +++ b/stubs/networkx/networkx/algorithms/non_randomness.pyi @@ -1,6 +1,5 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def non_randomness(G, k: Incomplete | None = None, weight: str = "weight"): ... +def non_randomness(G: Graph[_Node], k: int = None, weight: str | None = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/operators/all.pyi b/stubs/networkx/networkx/algorithms/operators/all.pyi index a595296a7853..d33ac3a5f2d5 100644 --- a/stubs/networkx/networkx/algorithms/operators/all.pyi +++ b/stubs/networkx/networkx/algorithms/operators/all.pyi @@ -1,10 +1,12 @@ +from collections.abc import Iterable + from networkx.utils.backends import _dispatchable @_dispatchable -def union_all(graphs, rename=()): ... +def union_all(graphs: Iterable, rename: Iterable | None = ()): ... @_dispatchable -def disjoint_union_all(graphs): ... +def disjoint_union_all(graphs: Iterable): ... @_dispatchable -def compose_all(graphs): ... +def compose_all(graphs: Iterable): ... @_dispatchable -def intersection_all(graphs): ... +def intersection_all(graphs: Iterable): ... diff --git a/stubs/networkx/networkx/algorithms/operators/binary.pyi b/stubs/networkx/networkx/algorithms/operators/binary.pyi index 536ab75240a2..cacb64396c87 100644 --- a/stubs/networkx/networkx/algorithms/operators/binary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/binary.pyi @@ -1,4 +1,4 @@ -from collections.abc import Hashable +from collections.abc import Hashable, Iterable from typing import TypeVar from networkx.classes.digraph import DiGraph @@ -17,6 +17,6 @@ _X = TypeVar("_X", bound=Hashable, covariant=True) _Y = TypeVar("_Y", bound=Hashable, covariant=True) @_dispatchable -def compose(G: DiGraph[_X], H: DiGraph[_Y]) -> DiGraph[_X | _Y]: ... +def compose(G, H) -> DiGraph[_X | _Y]: ... @_dispatchable -def union(G: DiGraph[_X], H: DiGraph[_Y], rename=()) -> DiGraph[_X | _Y]: ... +def union(G, H, rename: Iterable | None = ()) -> DiGraph[_X | _Y]: ... diff --git a/stubs/networkx/networkx/algorithms/operators/product.pyi b/stubs/networkx/networkx/algorithms/operators/product.pyi index 96b54b2d4275..d128745334c3 100644 --- a/stubs/networkx/networkx/algorithms/operators/product.pyi +++ b/stubs/networkx/networkx/algorithms/operators/product.pyi @@ -1,3 +1,4 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable @@ -9,8 +10,8 @@ def lexicographic_product(G, H): ... @_dispatchable def strong_product(G, H): ... @_dispatchable -def power(G, k): ... +def power(G: Graph[_Node], k): ... @_dispatchable -def rooted_product(G, H, root): ... +def rooted_product(G, H, root: _Node): ... @_dispatchable def corona_product(G, H): ... diff --git a/stubs/networkx/networkx/algorithms/operators/unary.pyi b/stubs/networkx/networkx/algorithms/operators/unary.pyi index b17f988839b3..6e5304605a69 100644 --- a/stubs/networkx/networkx/algorithms/operators/unary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/unary.pyi @@ -1,12 +1,13 @@ from collections.abc import Hashable from typing import TypeVar -from networkx.classes.graph import Graph +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable _G = TypeVar("_G", bound=Graph[Hashable]) @_dispatchable -def complement(G): ... +def complement(G: Graph[_Node]): ... @_dispatchable -def reverse(G: _G, copy: bool = True) -> _G: ... +def reverse(G: DiGraph[_Node], copy: bool = True) -> _G: ... diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index 9d7e58086962..9b1ba3b297fe 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -2,15 +2,15 @@ from _typeshed import Incomplete from collections.abc import Generator, Mapping, MutableSet, Reversible from networkx.classes.digraph import DiGraph -from networkx.classes.graph import _Node +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["check_planarity", "is_planar", "PlanarEmbedding"] @_dispatchable -def is_planar(G) -> bool: ... +def is_planar(G: Graph[_Node]) -> bool: ... @_dispatchable -def check_planarity(G, counterexample: bool = False): ... +def check_planarity(G: Graph[_Node], counterexample: bool = False): ... class Interval: low: Incomplete diff --git a/stubs/networkx/networkx/algorithms/polynomials.pyi b/stubs/networkx/networkx/algorithms/polynomials.pyi index 805beff63985..cadffc38a170 100644 --- a/stubs/networkx/networkx/algorithms/polynomials.pyi +++ b/stubs/networkx/networkx/algorithms/polynomials.pyi @@ -1,6 +1,7 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def tutte_polynomial(G): ... +def tutte_polynomial(G: Graph[_Node]): ... @_dispatchable -def chromatic_polynomial(G): ... +def chromatic_polynomial(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/reciprocity.pyi b/stubs/networkx/networkx/algorithms/reciprocity.pyi index 3af842628188..547dc885d5cc 100644 --- a/stubs/networkx/networkx/algorithms/reciprocity.pyi +++ b/stubs/networkx/networkx/algorithms/reciprocity.pyi @@ -1,8 +1,9 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def reciprocity(G, nodes: Incomplete | None = None): ... +def reciprocity(G: Graph[_Node], nodes: Iterable[_Node] | None = None): ... @_dispatchable -def overall_reciprocity(G): ... +def overall_reciprocity(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/regular.pyi b/stubs/networkx/networkx/algorithms/regular.pyi index 1e66cfe1c92d..61a19ea04a3b 100644 --- a/stubs/networkx/networkx/algorithms/regular.pyi +++ b/stubs/networkx/networkx/algorithms/regular.pyi @@ -1,8 +1,9 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def is_regular(G): ... +def is_regular(G: Graph[_Node]): ... @_dispatchable -def is_k_regular(G, k): ... +def is_k_regular(G: Graph[_Node], k): ... @_dispatchable -def k_factor(G, k, matching_weight: str = "weight"): ... +def k_factor(G: Graph[_Node], k, matching_weight: str | None = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/richclub.pyi b/stubs/networkx/networkx/algorithms/richclub.pyi index fa8f1f06df26..2b7b8b21fb2c 100644 --- a/stubs/networkx/networkx/algorithms/richclub.pyi +++ b/stubs/networkx/networkx/algorithms/richclub.pyi @@ -1,6 +1,6 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable -def rich_club_coefficient(G, normalized: bool = True, Q: float = 100, seed: Incomplete | None = None): ... +def rich_club_coefficient(G: Graph[_Node], normalized: bool = True, Q: float = 100, seed: int | RandomState | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi index 6b5160269014..9b8401eded55 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi @@ -1,8 +1,26 @@ -from _typeshed import Incomplete +from collections.abc import Callable +from typing import Any +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def astar_path(G, source, target, heuristic: Incomplete | None = None, weight: str = "weight"): ... +def astar_path( + G: Graph[_Node], + source: _Node, + target: _Node, + heuristic: Callable = None, + weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", + *, + cutoff: float | None = None, +): ... @_dispatchable -def astar_path_length(G, source, target, heuristic: Incomplete | None = None, weight: str = "weight"): ... +def astar_path_length( + G: Graph[_Node], + source: _Node, + target: _Node, + heuristic: Callable = None, + weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", + *, + cutoff: float | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi index 355782732342..e6c465bb999d 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi @@ -1,12 +1,11 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def floyd_warshall_numpy(G, nodelist: Incomplete | None = None, weight: str = "weight"): ... +def floyd_warshall_numpy(G: Graph[_Node], nodelist: list | None = None, weight: str | None = "weight"): ... @_dispatchable -def floyd_warshall_predecessor_and_distance(G, weight: str = "weight"): ... +def floyd_warshall_predecessor_and_distance(G: Graph[_Node], weight: str | None = "weight"): ... @_dispatchable -def reconstruct_path(source, target, predecessors): ... +def reconstruct_path(source: _Node, target: _Node, predecessors: dict): ... @_dispatchable -def floyd_warshall(G, weight: str = "weight"): ... +def floyd_warshall(G: Graph[_Node], weight: str | None = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi index 82723d3eb9e8..60e3b219e26a 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi @@ -1,5 +1,4 @@ -from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Callable, Generator from typing import overload from networkx.classes.graph import Graph, _Node @@ -9,23 +8,39 @@ from networkx.utils.backends import _dispatchable def has_path(G: Graph[_Node], source: _Node, target: _Node) -> bool: ... @overload def shortest_path( - G: Graph[_Node], source: _Node, target: _Node, weight: Incomplete | None = None, method: str = "dijkstra" + G: Graph[_Node], + source: _Node | None = None, + target: _Node | None = None, + weight: str | Callable | None = None, + method: str | None = "dijkstra", ) -> list[_Node]: ... @overload -def shortest_path(G: Graph[_Node], target: _Node, method: str = "dijkstra") -> dict[_Node, list[_Node]]: ... +def shortest_path( + G: Graph[_Node], + source: _Node | None = None, + target: _Node | None = None, + weight: str | Callable | None = None, + method: str | None = "dijkstra", +) -> dict[_Node, list[_Node]]: ... @overload -def shortest_path(G: Graph[_Node], source: _Node, method: str = "dijkstra") -> dict[_Node, list[_Node]]: ... +def shortest_path( + G: Graph[_Node], + source: _Node | None = None, + target: _Node | None = None, + weight: str | Callable | None = None, + method: str | None = "dijkstra", +) -> dict[_Node, list[_Node]]: ... @_dispatchable def shortest_path_length( - G, - source: Incomplete | None = None, - target: Incomplete | None = None, - weight: Incomplete | None = None, - method: str = "dijkstra", + G: Graph[_Node], + source: _Node | None = None, + target: _Node | None = None, + weight: str | Callable | None = None, + method: str | None = "dijkstra", ): ... @_dispatchable -def average_shortest_path_length(G, weight: Incomplete | None = None, method: str | None = None): ... +def average_shortest_path_length(G: Graph[_Node], weight: str | Callable | None = None, method: str | None = None): ... @_dispatchable def all_shortest_paths( - G: Graph[_Node], source: _Node, target: _Node, weight: Incomplete | None = None, method: str = "dijkstra" + G: Graph[_Node], source: _Node, target: _Node, weight: str | Callable | None = None, method: str | None = "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 cb4eeab99d23..8250e0f2c229 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi @@ -1,23 +1,24 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def single_source_shortest_path_length(G, source, cutoff: Incomplete | None = None): ... +def single_source_shortest_path_length(G: Graph[_Node], source: _Node, cutoff: int | None = None): ... @_dispatchable -def single_target_shortest_path_length(G, target, cutoff: Incomplete | None = None): ... +def single_target_shortest_path_length(G: Graph[_Node], target: _Node, cutoff: int | None = None): ... @_dispatchable -def all_pairs_shortest_path_length(G, cutoff: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... +def all_pairs_shortest_path_length(G: Graph[_Node], cutoff: int | None = None) -> Generator[Incomplete, None, None]: ... @_dispatchable -def bidirectional_shortest_path(G, source, target): ... +def bidirectional_shortest_path(G: Graph[_Node], source: str, target: str): ... @_dispatchable -def single_source_shortest_path(G, source, cutoff: Incomplete | None = None): ... +def single_source_shortest_path(G: Graph[_Node], source: str, cutoff: int | None = None): ... @_dispatchable -def single_target_shortest_path(G, target, cutoff: Incomplete | None = None): ... +def single_target_shortest_path(G: Graph[_Node], target: str, cutoff: int | None = None): ... @_dispatchable -def all_pairs_shortest_path(G, cutoff: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... +def all_pairs_shortest_path(G: Graph[_Node], cutoff: int | None = None) -> Generator[Incomplete, None, None]: ... @_dispatchable def predecessor( - G, source, target: Incomplete | None = None, cutoff: Incomplete | None = None, return_seen: Incomplete | None = None + G: Graph[_Node], source: str, target: str | None = None, cutoff: int | None = None, return_seen: bool | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi index 7eebe73c0c36..79a63961d90a 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi @@ -1,71 +1,135 @@ from _typeshed import Incomplete from collections.abc import Callable, Generator from typing import Any -from typing_extensions import TypeAlias +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable -_WeightFunction: TypeAlias = Callable[[Any, Any, dict[str, Any]], float | None] - @_dispatchable -def dijkstra_path(G, source, target, weight: str | _WeightFunction = "weight"): ... +def dijkstra_path( + G: Graph[_Node], source: _Node, target: _Node, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" +): ... @_dispatchable -def dijkstra_path_length(G, source, target, weight: str | _WeightFunction = "weight"): ... +def dijkstra_path_length( + G: Graph[_Node], source: str, target: str, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" +): ... @_dispatchable -def single_source_dijkstra_path(G, source, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight"): ... +def single_source_dijkstra_path( + G: Graph[_Node], + source: _Node, + cutoff: float | None = None, + weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", +): ... @_dispatchable -def single_source_dijkstra_path_length(G, source, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight"): ... +def single_source_dijkstra_path_length( + G: Graph[_Node], + source: str, + cutoff: float | None = None, + weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", +): ... @_dispatchable def single_source_dijkstra( - G, source, target: Incomplete | None = None, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight" + G: Graph[_Node], + source: str, + target: str | None = None, + cutoff: float | None = None, + weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", ): ... @_dispatchable -def multi_source_dijkstra_path(G, sources, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight"): ... +def multi_source_dijkstra_path( + G: Graph[_Node], + sources, + cutoff: float | None = None, + weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", +): ... @_dispatchable -def multi_source_dijkstra_path_length(G, sources, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight"): ... +def multi_source_dijkstra_path_length( + G: Graph[_Node], + sources, + cutoff: float | None = None, + weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", +): ... @_dispatchable def multi_source_dijkstra( - G, sources, target: Incomplete | None = None, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight" + G: Graph[_Node], + sources, + target: str | None = None, + cutoff: float | None = None, + weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", ): ... @_dispatchable -def dijkstra_predecessor_and_distance(G, source, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight"): ... +def dijkstra_predecessor_and_distance( + G: Graph[_Node], + source: str, + cutoff: float | None = None, + weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", +): ... @_dispatchable def all_pairs_dijkstra( - G, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight" + G: Graph[_Node], cutoff: float | None = None, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" ) -> Generator[Incomplete, None, None]: ... @_dispatchable def all_pairs_dijkstra_path_length( - G, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight" + G: Graph[_Node], cutoff: float | None = None, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" ) -> Generator[Incomplete, None, None]: ... @_dispatchable def all_pairs_dijkstra_path( - G, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight" + G: Graph[_Node], cutoff: float | None = None, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" ) -> Generator[Incomplete, None, None]: ... @_dispatchable def bellman_ford_predecessor_and_distance( - G, source, target: Incomplete | None = None, weight: str | _WeightFunction = "weight", heuristic: bool = False + G: Graph[_Node], + source: str, + target: str | None = None, + weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", + heuristic: bool = False, ): ... @_dispatchable -def bellman_ford_path(G, source, target, weight: str | _WeightFunction = "weight"): ... +def bellman_ford_path( + G: Graph[_Node], source: _Node, target: _Node, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" +): ... @_dispatchable -def bellman_ford_path_length(G, source, target, weight: str | _WeightFunction = "weight"): ... +def bellman_ford_path_length( + G: Graph[_Node], source: str, target: str, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" +): ... @_dispatchable -def single_source_bellman_ford_path(G, source, weight: str | _WeightFunction = "weight"): ... +def single_source_bellman_ford_path( + G: Graph[_Node], source: _Node, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" +): ... @_dispatchable -def single_source_bellman_ford_path_length(G, source, weight: str | _WeightFunction = "weight"): ... +def single_source_bellman_ford_path_length( + G: Graph[_Node], source: str, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" +): ... @_dispatchable -def single_source_bellman_ford(G, source, target: Incomplete | None = None, weight: str | _WeightFunction = "weight"): ... +def single_source_bellman_ford( + G: Graph[_Node], + source: str, + target: str | None = None, + weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", +): ... @_dispatchable -def all_pairs_bellman_ford_path_length(G, weight: str | _WeightFunction = "weight") -> Generator[Incomplete, None, None]: ... +def all_pairs_bellman_ford_path_length( + G: Graph[_Node], weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" +) -> Generator[Incomplete, None, None]: ... @_dispatchable -def all_pairs_bellman_ford_path(G, weight: str | _WeightFunction = "weight") -> Generator[Incomplete, None, None]: ... +def all_pairs_bellman_ford_path( + G: Graph[_Node], weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" +) -> Generator[Incomplete, None, None]: ... @_dispatchable -def goldberg_radzik(G, source, weight: str | _WeightFunction = "weight"): ... +def goldberg_radzik( + G: Graph[_Node], source: str, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" +): ... @_dispatchable -def negative_edge_cycle(G, weight: str | _WeightFunction = "weight", heuristic: bool = True): ... +def negative_edge_cycle( + G: Graph[_Node], weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", heuristic: bool = True +): ... @_dispatchable -def find_negative_cycle(G, source, weight: str | _WeightFunction = "weight"): ... +def find_negative_cycle( + G: Graph[_Node], source: str, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" +): ... @_dispatchable -def bidirectional_dijkstra(G, source, target, weight: str | _WeightFunction = "weight"): ... +def bidirectional_dijkstra( + G: Graph[_Node], source: _Node, target: _Node, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" +): ... @_dispatchable -def johnson(G, weight: str | _WeightFunction = "weight"): ... +def johnson(G: Graph[_Node], weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/similarity.pyi b/stubs/networkx/networkx/algorithms/similarity.pyi index bec692662f97..40c44db74d8a 100644 --- a/stubs/networkx/networkx/algorithms/similarity.pyi +++ b/stubs/networkx/networkx/algorithms/similarity.pyi @@ -1,83 +1,97 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Callable, Generator +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable def graph_edit_distance( G1, G2, - node_match: Incomplete | None = None, - edge_match: Incomplete | None = None, - node_subst_cost: Incomplete | None = None, - node_del_cost: Incomplete | None = None, - node_ins_cost: Incomplete | None = None, - edge_subst_cost: Incomplete | None = None, - edge_del_cost: Incomplete | None = None, - edge_ins_cost: Incomplete | None = None, - roots: Incomplete | None = None, - upper_bound: Incomplete | None = None, - timeout: Incomplete | None = None, + node_match: Callable = None, + edge_match: Callable = None, + node_subst_cost=None, + node_del_cost=None, + node_ins_cost=None, + edge_subst_cost=None, + edge_del_cost=None, + edge_ins_cost=None, + roots=None, + upper_bound: float = None, + timeout: float = None, ): ... @_dispatchable def optimal_edit_paths( G1, G2, - node_match: Incomplete | None = None, - edge_match: Incomplete | None = None, - node_subst_cost: Incomplete | None = None, - node_del_cost: Incomplete | None = None, - node_ins_cost: Incomplete | None = None, - edge_subst_cost: Incomplete | None = None, - edge_del_cost: Incomplete | None = None, - edge_ins_cost: Incomplete | None = None, - upper_bound: Incomplete | None = None, + node_match: Callable = None, + edge_match: Callable = None, + node_subst_cost=None, + node_del_cost=None, + node_ins_cost=None, + edge_subst_cost=None, + edge_del_cost=None, + edge_ins_cost=None, + upper_bound: float = None, ): ... @_dispatchable def optimize_graph_edit_distance( G1, G2, - node_match: Incomplete | None = None, - edge_match: Incomplete | None = None, - node_subst_cost: Incomplete | None = None, - node_del_cost: Incomplete | None = None, - node_ins_cost: Incomplete | None = None, - edge_subst_cost: Incomplete | None = None, - edge_del_cost: Incomplete | None = None, - edge_ins_cost: Incomplete | None = None, - upper_bound: Incomplete | None = None, + node_match: Callable = None, + edge_match: Callable = None, + node_subst_cost=None, + node_del_cost=None, + node_ins_cost=None, + edge_subst_cost=None, + edge_del_cost=None, + edge_ins_cost=None, + upper_bound: float = None, ) -> Generator[Incomplete, None, None]: ... @_dispatchable def optimize_edit_paths( G1, G2, - node_match: Incomplete | None = None, - edge_match: Incomplete | None = None, - node_subst_cost: Incomplete | None = None, - node_del_cost: Incomplete | None = None, - node_ins_cost: Incomplete | None = None, - edge_subst_cost: Incomplete | None = None, - edge_del_cost: Incomplete | None = None, - edge_ins_cost: Incomplete | None = None, - upper_bound: Incomplete | None = None, + node_match: Callable = None, + edge_match: Callable = None, + node_subst_cost=None, + node_del_cost=None, + node_ins_cost=None, + edge_subst_cost=None, + edge_del_cost=None, + edge_ins_cost=None, + upper_bound: float = None, strictly_decreasing: bool = True, - roots: Incomplete | None = None, - timeout: Incomplete | None = None, + roots=None, + timeout: float = None, ) -> Generator[Incomplete, None, Incomplete]: ... @_dispatchable def simrank_similarity( - G, - source: Incomplete | None = None, - target: Incomplete | None = None, + G: Graph[_Node], + source: _Node = None, + target: _Node = None, importance_factor: float = 0.9, max_iterations: int = 1000, tolerance: float = 0.0001, ): ... @_dispatchable def panther_similarity( - G, source, k: int = 5, path_length: int = 5, c: float = 0.5, delta: float = 0.1, eps: Incomplete | None = None + G: Graph[_Node], + source: _Node, + k: int = 5, + path_length: int = 5, + c: float = 0.5, + delta: float = 0.1, + eps=None, + weight: str | None = "weight", ): ... @_dispatchable def generate_random_paths( - G, sample_size, path_length: int = 5, index_map: Incomplete | None = None + G: Graph[_Node], + sample_size: int, + path_length: int = 5, + index_map: dict | None = None, + weight: str | None = "weight", + seed: int | RandomState | 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 83bd0815252f..10190231494b 100644 --- a/stubs/networkx/networkx/algorithms/simple_paths.pyi +++ b/stubs/networkx/networkx/algorithms/simple_paths.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete -from collections.abc import Generator, Sequence +from collections.abc import Callable, Generator +from typing import Any from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -7,18 +8,16 @@ from networkx.utils.backends import _dispatchable __all__ = ["all_simple_paths", "is_simple_path", "shortest_simple_paths", "all_simple_edge_paths"] @_dispatchable -def is_simple_path(G: Graph[_Node], nodes: Sequence[_Node]): ... +def is_simple_path(G: Graph[_Node], nodes: list): ... @_dispatchable -def all_simple_paths( - G: Graph[_Node], source: _Node, target: _Node, cutoff: Incomplete | None = None -) -> Generator[list[_Node], None, None]: ... +def all_simple_paths(G: Graph[_Node], source: _Node, target, cutoff: int | None = None) -> Generator[list[_Node], None, None]: ... @_dispatchable def all_simple_edge_paths( - G: Graph[_Node], source: _Node, target: _Node, cutoff: Incomplete | None = None + G: Graph[_Node], source: _Node, target, cutoff: int | None = None ) -> Generator[list[_Node] | list[tuple[_Node, _Node]], None, list[_Node] | None]: ... @_dispatchable def shortest_simple_paths( - G: Graph[_Node], source: _Node, target: _Node, weight: Incomplete | None = None + G: Graph[_Node], source: _Node, target: _Node, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = None ) -> Generator[list[_Node], None, None]: ... class PathBuffer: diff --git a/stubs/networkx/networkx/algorithms/smallworld.pyi b/stubs/networkx/networkx/algorithms/smallworld.pyi index cb9c7b252e04..1489f56198ae 100644 --- a/stubs/networkx/networkx/algorithms/smallworld.pyi +++ b/stubs/networkx/networkx/algorithms/smallworld.pyi @@ -1,14 +1,14 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable -def random_reference(G, niter: int = 1, connectivity: bool = True, seed: Incomplete | None = None): ... +def random_reference(G: Graph[_Node], niter: int = 1, connectivity: bool = True, seed: int | RandomState | None = None): ... @_dispatchable def lattice_reference( - G, niter: int = 5, D: Incomplete | None = None, connectivity: bool = True, seed: Incomplete | None = None + G: Graph[_Node], niter: int = 5, D=None, connectivity: bool = True, seed: int | RandomState | None = None ): ... @_dispatchable -def sigma(G, niter: int = 100, nrand: int = 10, seed: Incomplete | None = None): ... +def sigma(G: Graph[_Node], niter: int = 100, nrand: int = 10, seed: int | RandomState | None = None): ... @_dispatchable -def omega(G, niter: int = 5, nrand: int = 10, seed: Incomplete | None = None): ... +def omega(G: Graph[_Node], niter: int = 5, nrand: int = 10, seed: int | RandomState | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/smetric.pyi b/stubs/networkx/networkx/algorithms/smetric.pyi index 61eb1aebdb14..ee2e7115e94a 100644 --- a/stubs/networkx/networkx/algorithms/smetric.pyi +++ b/stubs/networkx/networkx/algorithms/smetric.pyi @@ -1,4 +1,5 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def s_metric(G, normalized: bool = True): ... +def s_metric(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/sparsifiers.pyi b/stubs/networkx/networkx/algorithms/sparsifiers.pyi index e556626f172a..a334a5e5ad42 100644 --- a/stubs/networkx/networkx/algorithms/sparsifiers.pyi +++ b/stubs/networkx/networkx/algorithms/sparsifiers.pyi @@ -1,6 +1,6 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable -def spanner(G, stretch, weight: Incomplete | None = None, seed: Incomplete | None = None): ... +def spanner(G: Graph[_Node], stretch: float, weight: str = None, seed: int | RandomState | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/structuralholes.pyi b/stubs/networkx/networkx/algorithms/structuralholes.pyi index bc396853a637..d83dc63aae46 100644 --- a/stubs/networkx/networkx/algorithms/structuralholes.pyi +++ b/stubs/networkx/networkx/algorithms/structuralholes.pyi @@ -1,10 +1,11 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def effective_size(G, nodes: Incomplete | None = None, weight: Incomplete | None = None): ... +def effective_size(G: Graph[_Node], nodes: Iterable | None = None, weight: str | None = None): ... @_dispatchable -def constraint(G, nodes: Incomplete | None = None, weight: Incomplete | None = None): ... +def constraint(G: Graph[_Node], nodes: Iterable | None = None, weight: str | None = None): ... @_dispatchable -def local_constraint(G, u, v, weight: Incomplete | None = None): ... +def local_constraint(G: Graph[_Node], u: _Node, v: _Node, weight: str | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/summarization.pyi b/stubs/networkx/networkx/algorithms/summarization.pyi index e1a359b8c72d..996d709bcb25 100644 --- a/stubs/networkx/networkx/algorithms/summarization.pyi +++ b/stubs/networkx/networkx/algorithms/summarization.pyi @@ -1,14 +1,15 @@ -from _typeshed import Incomplete +from collections.abc import Iterable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def dedensify(G, threshold, prefix: Incomplete | None = None, copy: bool = True): ... +def dedensify(G: Graph[_Node], threshold: int, prefix=None, copy: bool | None = True): ... @_dispatchable def snap_aggregation( - G, + G: Graph[_Node], node_attributes, - edge_attributes=(), + edge_attributes: Iterable | None = (), prefix: str = "Supernode-", supernode_attribute: str = "group", superedge_attribute: str = "types", diff --git a/stubs/networkx/networkx/algorithms/swap.pyi b/stubs/networkx/networkx/algorithms/swap.pyi index be15bb2236fd..006bb38c9cd0 100644 --- a/stubs/networkx/networkx/algorithms/swap.pyi +++ b/stubs/networkx/networkx/algorithms/swap.pyi @@ -1,10 +1,13 @@ -from _typeshed import Incomplete - +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable -def directed_edge_swap(G, *, nswap: int = 1, max_tries: int = 100, seed: Incomplete | None = None): ... +def directed_edge_swap(G: DiGraph[_Node], *, nswap: int = 1, max_tries: int = 100, seed: int | RandomState | None = None): ... @_dispatchable -def double_edge_swap(G, nswap: int = 1, max_tries: int = 100, seed: Incomplete | None = None): ... +def double_edge_swap(G: Graph[_Node], nswap: int = 1, max_tries: int = 100, seed: int | RandomState | None = None): ... @_dispatchable -def connected_double_edge_swap(G, nswap: int = 1, _window_threshold: int = 3, seed: Incomplete | None = None): ... +def connected_double_edge_swap( + G: Graph[_Node], nswap: int = 1, _window_threshold: int = 3, seed: int | RandomState | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/threshold.pyi b/stubs/networkx/networkx/algorithms/threshold.pyi index 4649c6638d33..8a06957f891a 100644 --- a/stubs/networkx/networkx/algorithms/threshold.pyi +++ b/stubs/networkx/networkx/algorithms/threshold.pyi @@ -1,8 +1,7 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def is_threshold_graph(G): ... +def is_threshold_graph(G: Graph[_Node]): ... @_dispatchable -def find_threshold_graph(G, create_using: Incomplete | None = None): ... +def find_threshold_graph(G: Graph[_Node], create_using: Graph[_Node] | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/time_dependent.pyi b/stubs/networkx/networkx/algorithms/time_dependent.pyi index 195ca18840b9..43b49e9ae698 100644 --- a/stubs/networkx/networkx/algorithms/time_dependent.pyi +++ b/stubs/networkx/networkx/algorithms/time_dependent.pyi @@ -1,6 +1,5 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def cd_index(G, node, time_delta, *, time: str = "time", weight: Incomplete | None = None): ... +def cd_index(G: Graph[_Node], node: _Node, time_delta, *, time: str = "time", weight: str = None): ... diff --git a/stubs/networkx/networkx/algorithms/tournament.pyi b/stubs/networkx/networkx/algorithms/tournament.pyi index a8f06989d1a2..9d92b1a46429 100644 --- a/stubs/networkx/networkx/algorithms/tournament.pyi +++ b/stubs/networkx/networkx/algorithms/tournament.pyi @@ -1,16 +1,16 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable -def is_tournament(G): ... +def is_tournament(G: Graph[_Node]): ... @_dispatchable -def hamiltonian_path(G): ... +def hamiltonian_path(G: Graph[_Node]): ... @_dispatchable -def random_tournament(n, seed: Incomplete | None = None): ... +def random_tournament(n: int, seed: int | RandomState | None = None): ... @_dispatchable -def score_sequence(G): ... +def score_sequence(G: Graph[_Node]): ... @_dispatchable -def is_reachable(G, s, t): ... +def is_reachable(G: Graph[_Node], s: _Node, t: _Node): ... @_dispatchable -def is_strongly_connected(G): ... +def is_strongly_connected(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi b/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi index 057bc9e8972d..994640f2c396 100644 --- a/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi @@ -1,7 +1,10 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Callable, Generator +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def bfs_beam_edges(G, source, value, width: Incomplete | None = None) -> Generator[Incomplete, Incomplete, Incomplete]: ... +def bfs_beam_edges( + G: Graph[_Node], source: _Node, value: Callable, width: int = 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 dbcf268d599c..7e4ab110ae63 100644 --- a/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi @@ -1,25 +1,24 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Callable, Generator +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def bfs_edges( - G, source, reverse: bool = False, depth_limit: Incomplete | None = None, sort_neighbors: Incomplete | None = None + G: Graph[_Node], source: _Node, reverse: bool | None = False, depth_limit=None, sort_neighbors: Callable = None ) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable -def bfs_tree( - G, source, reverse: bool = False, depth_limit: Incomplete | None = None, sort_neighbors: Incomplete | None = None -): ... +def bfs_tree(G: Graph[_Node], source: _Node, reverse: bool | None = False, depth_limit=None, sort_neighbors: Callable = None): ... @_dispatchable def bfs_predecessors( - G, source, depth_limit: Incomplete | None = None, sort_neighbors: Incomplete | None = None + G: Graph[_Node], source: _Node, depth_limit=None, sort_neighbors: Callable = None ) -> Generator[Incomplete, None, None]: ... @_dispatchable def bfs_successors( - G, source, depth_limit: Incomplete | None = None, sort_neighbors: Incomplete | None = None + G: Graph[_Node], source: _Node, depth_limit=None, sort_neighbors: Callable = None ) -> Generator[Incomplete, None, None]: ... @_dispatchable -def bfs_layers(G, sources) -> Generator[Incomplete, None, None]: ... +def bfs_layers(G: Graph[_Node], sources) -> Generator[Incomplete, None, None]: ... @_dispatchable -def descendants_at_distance(G, source, distance): ... +def descendants_at_distance(G: Graph[_Node], 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 0b1abaedf280..2ef3654b0e4b 100644 --- a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi @@ -1,22 +1,23 @@ -from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Callable, Generator from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def dfs_edges( - G: Graph[_Node], source: _Node | None = None, depth_limit: int | None = None + G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable = None ) -> Generator[tuple[_Node, _Node], None, None]: ... @_dispatchable -def dfs_tree(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... +def dfs_tree(G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable = None): ... @_dispatchable -def dfs_predecessors(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... +def dfs_predecessors(G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable = None): ... @_dispatchable -def dfs_successors(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... +def dfs_successors(G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable = None): ... @_dispatchable -def dfs_postorder_nodes(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... +def dfs_postorder_nodes(G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable = None): ... @_dispatchable -def dfs_preorder_nodes(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... +def dfs_preorder_nodes(G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable = None): ... @_dispatchable -def dfs_labeled_edges(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None) -> None: ... +def dfs_labeled_edges( + G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable = None +) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi b/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi index 4999e56ee880..1829e0bbe401 100644 --- a/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi @@ -1,9 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def edge_bfs( - G, source: Incomplete | None = None, orientation: Incomplete | None = None -) -> Generator[Incomplete, None, Incomplete]: ... +def edge_bfs(G: Graph[_Node], source=None, orientation=None) -> Generator[Incomplete, None, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi b/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi index f2b11d4736f2..3e8b6485fd2d 100644 --- a/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi @@ -1,9 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def edge_dfs( - G, source: Incomplete | None = None, orientation: Incomplete | None = None -) -> Generator[Incomplete, None, Incomplete]: ... +def edge_dfs(G: Graph[_Node], source=None, orientation=None) -> Generator[Incomplete, None, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi index dcb6d2a8413a..fc71e4e20349 100644 --- a/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -2,7 +2,10 @@ from _typeshed import Incomplete from collections.abc import Iterator from dataclasses import dataclass +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState __all__ = [ "branching_weight", @@ -15,24 +18,26 @@ __all__ = [ ] @_dispatchable -def branching_weight(G, attr: str = "weight", default: float = 1): ... +def branching_weight(G: DiGraph[_Node], attr: str = "weight", default: float = 1): ... @_dispatchable -def greedy_branching(G, attr: str = "weight", default: float = 1, kind: str = "max", seed: Incomplete | None = None): ... +def greedy_branching( + G: DiGraph[_Node], attr: str = "weight", default: float = 1, kind: str = "max", seed: int | RandomState | None = None +): ... @_dispatchable def maximum_branching( - G, attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: Incomplete | None = None + G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str = None ): ... @_dispatchable def minimum_branching( - G, attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: Incomplete | None = None + G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str = None ): ... @_dispatchable def maximum_spanning_arborescence( - G, attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: Incomplete | None = None + G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str = None ): ... @_dispatchable def minimum_spanning_arborescence( - G, attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: Incomplete | None = None + G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str = None ): ... class ArborescenceIterator: diff --git a/stubs/networkx/networkx/algorithms/tree/coding.pyi b/stubs/networkx/networkx/algorithms/tree/coding.pyi index 180a04a7c1ac..5a575a4c9db4 100644 --- a/stubs/networkx/networkx/algorithms/tree/coding.pyi +++ b/stubs/networkx/networkx/algorithms/tree/coding.pyi @@ -1,13 +1,14 @@ +from networkx.classes.graph import Graph, _Node from networkx.exception import NetworkXException from networkx.utils.backends import _dispatchable class NotATree(NetworkXException): ... @_dispatchable -def to_nested_tuple(T, root, canonical_form: bool = False): ... +def to_nested_tuple(T: Graph[_Node], root: _Node, canonical_form: bool = False): ... @_dispatchable -def from_nested_tuple(sequence, sensible_relabeling: bool = False): ... +def from_nested_tuple(sequence: tuple, sensible_relabeling: bool = False): ... @_dispatchable -def to_prufer_sequence(T): ... +def to_prufer_sequence(T: Graph[_Node]): ... @_dispatchable -def from_prufer_sequence(sequence): ... +def from_prufer_sequence(sequence: list): ... diff --git a/stubs/networkx/networkx/algorithms/tree/mst.pyi b/stubs/networkx/networkx/algorithms/tree/mst.pyi index 065e6f178fc5..3f974df5bb91 100644 --- a/stubs/networkx/networkx/algorithms/tree/mst.pyi +++ b/stubs/networkx/networkx/algorithms/tree/mst.pyi @@ -3,7 +3,9 @@ from collections.abc import Iterator from dataclasses import dataclass from enum import Enum +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState class EdgePartition(Enum): OPEN = 0 @@ -12,22 +14,32 @@ class EdgePartition(Enum): @_dispatchable def minimum_spanning_edges( - G, algorithm: str = "kruskal", weight: str = "weight", keys: bool = True, data: bool = True, ignore_nan: bool = False + G: Graph[_Node], + algorithm: str = "kruskal", + weight: str = "weight", + keys: bool = True, + data: bool | None = True, + ignore_nan: bool = False, ): ... @_dispatchable def maximum_spanning_edges( - G, algorithm: str = "kruskal", weight: str = "weight", keys: bool = True, data: bool = True, ignore_nan: bool = False + G: Graph[_Node], + algorithm: str = "kruskal", + weight: str = "weight", + keys: bool = True, + data: bool | None = True, + ignore_nan: bool = False, ): ... @_dispatchable -def minimum_spanning_tree(G, weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False): ... +def minimum_spanning_tree(G: Graph[_Node], weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False): ... @_dispatchable def partition_spanning_tree( - G, minimum: bool = True, weight: str = "weight", partition: str = "partition", ignore_nan: bool = False + G: Graph[_Node], minimum: bool = True, weight: str = "weight", partition: str = "partition", ignore_nan: bool = False ): ... @_dispatchable -def maximum_spanning_tree(G, weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False): ... +def maximum_spanning_tree(G: Graph[_Node], weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False): ... @_dispatchable -def random_spanning_tree(G, weight: Incomplete | None = None, *, multiplicative: bool = True, seed: Incomplete | None = None): ... +def random_spanning_tree(G: Graph[_Node], weight: str = None, *, multiplicative=True, seed: int | RandomState | None = None): ... class SpanningTreeIterator: @dataclass diff --git a/stubs/networkx/networkx/algorithms/tree/operations.pyi b/stubs/networkx/networkx/algorithms/tree/operations.pyi index feab02594790..fa9c564763f2 100644 --- a/stubs/networkx/networkx/algorithms/tree/operations.pyi +++ b/stubs/networkx/networkx/algorithms/tree/operations.pyi @@ -1,6 +1,4 @@ -from _typeshed import Incomplete - from networkx.utils.backends import _dispatchable @_dispatchable -def join_trees(rooted_trees, label_attribute: Incomplete | None = None): ... +def join_trees(rooted_trees: list, *, label_attribute: str = None, first_label: int | None = 0): ... diff --git a/stubs/networkx/networkx/algorithms/tree/recognition.pyi b/stubs/networkx/networkx/algorithms/tree/recognition.pyi index b5b303b66c81..219e48d02f33 100644 --- a/stubs/networkx/networkx/algorithms/tree/recognition.pyi +++ b/stubs/networkx/networkx/algorithms/tree/recognition.pyi @@ -1,10 +1,12 @@ +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def is_arborescence(G): ... +def is_arborescence(G: Graph[_Node]): ... @_dispatchable -def is_branching(G): ... +def is_branching(G: DiGraph[_Node]): ... @_dispatchable -def is_forest(G): ... +def is_forest(G: Graph[_Node]): ... @_dispatchable -def is_tree(G): ... +def is_tree(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/triads.pyi b/stubs/networkx/networkx/algorithms/triads.pyi index 510b01cbdf2a..4516a221509b 100644 --- a/stubs/networkx/networkx/algorithms/triads.pyi +++ b/stubs/networkx/networkx/algorithms/triads.pyi @@ -1,19 +1,22 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +from numpy.random import RandomState @_dispatchable -def triadic_census(G, nodelist: Incomplete | None = None): ... +def triadic_census(G: DiGraph[_Node], nodelist: list = None): ... @_dispatchable -def is_triad(G): ... +def is_triad(G: Graph[_Node]): ... @_dispatchable -def all_triplets(G): ... +def all_triplets(G: DiGraph[_Node]): ... @_dispatchable -def all_triads(G) -> Generator[Incomplete, None, None]: ... +def all_triads(G: DiGraph[_Node]) -> Generator[Incomplete, None, None]: ... @_dispatchable -def triads_by_type(G): ... +def triads_by_type(G: DiGraph[_Node]): ... @_dispatchable -def triad_type(G): ... +def triad_type(G: DiGraph[_Node]): ... @_dispatchable -def random_triad(G, seed: Incomplete | None = None): ... +def random_triad(G: DiGraph[_Node], seed: int | RandomState | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/vitality.pyi b/stubs/networkx/networkx/algorithms/vitality.pyi index 9a7cfcb2b64a..533bf929a19c 100644 --- a/stubs/networkx/networkx/algorithms/vitality.pyi +++ b/stubs/networkx/networkx/algorithms/vitality.pyi @@ -1,8 +1,5 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def closeness_vitality( - G, node: Incomplete | None = None, weight: Incomplete | None = None, wiener_index: Incomplete | None = None -): ... +def closeness_vitality(G: Graph[_Node], node: object = None, weight: str = None, wiener_index: float = None): ... diff --git a/stubs/networkx/networkx/algorithms/voronoi.pyi b/stubs/networkx/networkx/algorithms/voronoi.pyi index 6713ec759232..a71219be1f5a 100644 --- a/stubs/networkx/networkx/algorithms/voronoi.pyi +++ b/stubs/networkx/networkx/algorithms/voronoi.pyi @@ -1,4 +1,10 @@ +from collections.abc import Callable +from typing import Any + +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def voronoi_cells(G, center_nodes, weight: str = "weight"): ... +def voronoi_cells( + G: Graph[_Node], center_nodes: set, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" +): ... diff --git a/stubs/networkx/networkx/algorithms/walks.pyi b/stubs/networkx/networkx/algorithms/walks.pyi index a9d4b94e5f55..9c5d25a38a22 100644 --- a/stubs/networkx/networkx/algorithms/walks.pyi +++ b/stubs/networkx/networkx/algorithms/walks.pyi @@ -1,4 +1,5 @@ +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def number_of_walks(G, walk_length): ... +def number_of_walks(G: Graph[_Node], walk_length: int): ... diff --git a/stubs/networkx/networkx/algorithms/wiener.pyi b/stubs/networkx/networkx/algorithms/wiener.pyi index 1cff8ccd0f76..e55f890203a8 100644 --- a/stubs/networkx/networkx/algorithms/wiener.pyi +++ b/stubs/networkx/networkx/algorithms/wiener.pyi @@ -1,6 +1,5 @@ -from _typeshed import Incomplete - +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def wiener_index(G, weight: Incomplete | None = None): ... +def wiener_index(G: Graph[_Node], weight: str | None = None): ... From 5eb8fcdbd85a49c632c1b3b9915e1fe7be9f5bb8 Mon Sep 17 00:00:00 2001 From: Daniel Darabos Date: Mon, 3 Feb 2025 17:34:16 +0100 Subject: [PATCH 4/7] Relax annotations. (list/dict -> Iterable/SupportsGetItem) --- .../algorithms/approximation/steinertree.pyi | 4 +- .../algorithms/assortativity/mixing.pyi | 5 +- .../algorithms/bipartite/generators.pyi | 12 +-- .../algorithms/bipartite/matching.pyi | 3 +- .../networkx/algorithms/bipartite/matrix.pyi | 6 +- .../centrality/betweenness_subset.pyi | 14 +++- .../algorithms/centrality/closeness.pyi | 4 +- .../current_flow_betweenness_subset.pyi | 10 ++- .../algorithms/centrality/eigenvector.pyi | 8 +- .../networkx/algorithms/centrality/group.pyi | 12 +-- .../networkx/algorithms/centrality/katz.pyi | 12 ++- .../algorithms/centrality/laplacian.pyi | 4 +- .../algorithms/centrality/percolation.pyi | 4 +- .../algorithms/centrality/reaching.pyi | 4 +- stubs/networkx/networkx/algorithms/clique.pyi | 12 +-- .../connectivity/edge_augmentation.pyi | 3 +- stubs/networkx/networkx/algorithms/core.pyi | 10 ++- stubs/networkx/networkx/algorithms/dag.pyi | 8 +- .../networkx/algorithms/flow/mincost.pyi | 4 +- .../networkx/algorithms/graphical.pyi | 6 +- .../algorithms/link_analysis/hits_alg.pyi | 8 +- .../algorithms/link_analysis/pagerank_alg.pyi | 15 ++-- .../algorithms/shortest_paths/astar.pyi | 5 +- .../algorithms/shortest_paths/dense.pyi | 7 +- .../algorithms/shortest_paths/weighted.pyi | 75 ++++++++++++------- .../networkx/algorithms/similarity.pyi | 4 +- .../networkx/algorithms/simple_paths.pyi | 11 ++- .../networkx/algorithms/tree/coding.pyi | 4 +- .../networkx/algorithms/tree/operations.pyi | 4 +- stubs/networkx/networkx/algorithms/triads.pyi | 4 +- .../networkx/networkx/algorithms/voronoi.pyi | 3 +- 31 files changed, 189 insertions(+), 96 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi b/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi index 3c7e02bd889e..6841c94bfc8d 100644 --- a/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi @@ -1,7 +1,9 @@ +from collections.abc import Iterable + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def metric_closure(G: Graph[_Node], weight="weight"): ... @_dispatchable -def steiner_tree(G: Graph[_Node], terminal_nodes: list, weight: str = "weight", method: str | None = None): ... +def steiner_tree(G: Graph[_Node], terminal_nodes: Iterable, weight: str = "weight", method: str | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi index c5ceb475d584..4c138e26a07f 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi @@ -1,3 +1,4 @@ +from _typeshed import SupportsGetItem from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -7,7 +8,7 @@ from networkx.utils.backends import _dispatchable def attribute_mixing_dict(G: Graph[_Node], attribute: str, nodes: Iterable = None, normalized: bool = False): ... @_dispatchable def attribute_mixing_matrix( - G: Graph[_Node], attribute: str, nodes: Iterable = None, mapping: dict | None = None, normalized: bool = True + G: Graph[_Node], attribute: str, nodes: Iterable = None, mapping: SupportsGetItem | None = None, normalized: bool = True ): ... @_dispatchable def degree_mixing_dict( @@ -21,7 +22,7 @@ def degree_mixing_matrix( weight: str | None = None, nodes: Iterable = None, normalized: bool = True, - mapping: dict | None = None, + mapping: SupportsGetItem | None = None, ): ... @_dispatchable def mixing_dict(xy, normalized: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/generators.pyi b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi index a0cb2a039f9e..01afd24638ff 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/generators.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi @@ -1,3 +1,5 @@ +from collections.abc import Iterable + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState @@ -6,17 +8,17 @@ from numpy.random import RandomState def complete_bipartite_graph(n1, n2, create_using: Graph[_Node] = None): ... @_dispatchable def configuration_model( - aseq: list, bseq: list, create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None + aseq: Iterable, bseq: Iterable, create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None ): ... @_dispatchable -def havel_hakimi_graph(aseq: list, bseq: list, create_using: Graph[_Node] | None = None): ... +def havel_hakimi_graph(aseq: Iterable, bseq: Iterable, create_using: Graph[_Node] | None = None): ... @_dispatchable -def reverse_havel_hakimi_graph(aseq: list, bseq: list, create_using: Graph[_Node] | None = None): ... +def reverse_havel_hakimi_graph(aseq: Iterable, bseq: Iterable, create_using: Graph[_Node] | None = None): ... @_dispatchable -def alternating_havel_hakimi_graph(aseq: list, bseq: list, create_using: Graph[_Node] | None = None): ... +def alternating_havel_hakimi_graph(aseq: Iterable, bseq: Iterable, create_using: Graph[_Node] | None = None): ... @_dispatchable def preferential_attachment_graph( - aseq: list, p: float, create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None + aseq: Iterable, p: float, create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None ): ... @_dispatchable def random_graph(n: int, m: int, p: float, seed: int | RandomState | None = None, directed: bool | None = False): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi index 2233cba25d15..3ece4ff64702 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi @@ -1,3 +1,4 @@ +from _typeshed import SupportsGetItem from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -8,7 +9,7 @@ def hopcroft_karp_matching(G: Graph[_Node], top_nodes: Iterable[_Node] = None): @_dispatchable def eppstein_matching(G: Graph[_Node], top_nodes: Iterable = None): ... @_dispatchable -def to_vertex_cover(G: Graph[_Node], matching: dict, top_nodes: Iterable = None): ... +def to_vertex_cover(G: Graph[_Node], matching: SupportsGetItem, top_nodes: Iterable = None): ... maximum_matching = hopcroft_karp_matching diff --git a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi index 558333db2319..03def09b99f0 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi @@ -1,11 +1,13 @@ +from collections.abc import Iterable + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def biadjacency_matrix( G: Graph[_Node], - row_order: list[_Node], - column_order: list | None = None, + row_order: Iterable[_Node], + column_order: Iterable | None = None, dtype=None, weight: str | None = "weight", format="csr", diff --git a/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi b/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi index 1d183c8cc0de..3f3af3e5bbae 100644 --- a/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi @@ -1,11 +1,21 @@ +from collections.abc import Iterable + from networkx.classes.graph import Graph, _Edge, _Node from networkx.utils.backends import _dispatchable @_dispatchable def betweenness_centrality_subset( - G: Graph[_Node], sources: list[_Node], targets: list[_Node], normalized: bool | None = False, weight: str | None = None + G: Graph[_Node], + sources: Iterable[_Node], + targets: Iterable[_Node], + normalized: bool | None = False, + weight: str | None = None, ) -> dict[_Node, float]: ... @_dispatchable def edge_betweenness_centrality_subset( - G: Graph[_Node], sources: list[_Node], targets: list[_Node], normalized: bool | None = False, weight: str | None = None + G: Graph[_Node], + sources: Iterable[_Node], + targets: Iterable[_Node], + normalized: bool | None = False, + weight: str | None = None, ) -> dict[_Edge[_Node], float]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi index 5735553ed4ef..bf4314aecda3 100644 --- a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi @@ -1,3 +1,5 @@ +from _typeshed import SupportsGetItem + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -7,5 +9,5 @@ def closeness_centrality( ) -> dict[_Node, float]: ... @_dispatchable def incremental_closeness_centrality( - G: Graph[_Node], edge: tuple, prev_cc: dict = None, insertion: bool | None = True, wf_improved: bool | None = True + G: Graph[_Node], edge: tuple, prev_cc: SupportsGetItem = None, insertion: bool | None = True, wf_improved: bool | None = True ) -> dict[_Node, float]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi index a0725bf6d757..7712c02ac954 100644 --- a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi @@ -1,11 +1,13 @@ +from collections.abc import Iterable + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def current_flow_betweenness_centrality_subset( G: Graph[_Node], - sources: list[_Node], - targets: list[_Node], + sources: Iterable[_Node], + targets: Iterable[_Node], normalized: bool | None = True, weight: str | None = None, dtype: type = ..., @@ -14,8 +16,8 @@ def current_flow_betweenness_centrality_subset( @_dispatchable def edge_current_flow_betweenness_centrality_subset( G: Graph[_Node], - sources: list[_Node], - targets: list[_Node], + sources: Iterable[_Node], + targets: Iterable[_Node], normalized: bool | None = True, weight: str | None = None, dtype: type = ..., diff --git a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi index 352ed9481992..f78d1b66c0bb 100644 --- a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi @@ -1,9 +1,15 @@ +from _typeshed import SupportsGetItem + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def eigenvector_centrality( - G: Graph[_Node], max_iter: int | None = 100, tol: float | None = 1e-06, nstart: dict | None = None, weight: str | None = None + G: Graph[_Node], + max_iter: int | None = 100, + tol: float | None = 1e-06, + nstart: SupportsGetItem | None = None, + weight: str | None = None, ): ... @_dispatchable def eigenvector_centrality_numpy( diff --git a/stubs/networkx/networkx/algorithms/centrality/group.pyi b/stubs/networkx/networkx/algorithms/centrality/group.pyi index f239ffabca7e..7654d1aa4381 100644 --- a/stubs/networkx/networkx/algorithms/centrality/group.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/group.pyi @@ -1,3 +1,5 @@ +from collections.abc import Iterable + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -10,16 +12,16 @@ def prominent_group( G: Graph[_Node], k: int, weight: str | None = None, - C: list | set | None = None, + C: Iterable | None = None, endpoints: bool | None = False, normalized: bool | None = True, greedy: bool | None = False, ): ... @_dispatchable -def group_closeness_centrality(G: Graph[_Node], S: list | set, weight: str | None = None): ... +def group_closeness_centrality(G: Graph[_Node], S: Iterable, weight: str | None = None): ... @_dispatchable -def group_degree_centrality(G: Graph[_Node], S: list | set): ... +def group_degree_centrality(G: Graph[_Node], S: Iterable): ... @_dispatchable -def group_in_degree_centrality(G: Graph[_Node], S: list | set): ... +def group_in_degree_centrality(G: Graph[_Node], S: Iterable): ... @_dispatchable -def group_out_degree_centrality(G: Graph[_Node], S: list | set): ... +def group_out_degree_centrality(G: Graph[_Node], S: Iterable): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/katz.pyi b/stubs/networkx/networkx/algorithms/centrality/katz.pyi index 069a2b4e4017..75e6c3fcf4d9 100644 --- a/stubs/networkx/networkx/algorithms/centrality/katz.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/katz.pyi @@ -1,3 +1,5 @@ +from _typeshed import SupportsGetItem + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -5,14 +7,18 @@ from networkx.utils.backends import _dispatchable def katz_centrality( G: Graph[_Node], alpha: float | None = 0.1, - beta: float | dict | None = 1.0, + beta: float | SupportsGetItem | None = 1.0, max_iter: int | None = 1000, tol: float | None = 1e-06, - nstart: dict | None = None, + nstart: SupportsGetItem | None = None, normalized: bool | None = True, weight: str | None = None, ): ... @_dispatchable def katz_centrality_numpy( - G: Graph[_Node], alpha: float = 0.1, beta: float | dict | None = 1.0, normalized: bool = True, weight: str | None = None + G: Graph[_Node], + alpha: float = 0.1, + beta: float | SupportsGetItem | None = 1.0, + normalized: bool = True, + weight: str | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi b/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi index 53f022baff5d..55cff9598fea 100644 --- a/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi @@ -1,3 +1,5 @@ +from collections.abc import Iterable + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -5,7 +7,7 @@ from networkx.utils.backends import _dispatchable def laplacian_centrality( G: Graph[_Node], normalized: bool = True, - nodelist: list | None = None, + nodelist: Iterable | None = None, weight: str | None = "weight", walk_type: str | None = None, alpha: float = 0.95, diff --git a/stubs/networkx/networkx/algorithms/centrality/percolation.pyi b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi index 64a55fee3ef0..9a0e45d84d01 100644 --- a/stubs/networkx/networkx/algorithms/centrality/percolation.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi @@ -1,7 +1,9 @@ +from _typeshed import SupportsGetItem + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def percolation_centrality( - G: Graph[_Node], attribute: str | None = "percolation", states: dict | None = None, weight: str | None = None + G: Graph[_Node], attribute: str | None = "percolation", states: SupportsGetItem | None = None, weight: str | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/reaching.pyi b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi index ec9b7440f822..f0d15b98224c 100644 --- a/stubs/networkx/networkx/algorithms/centrality/reaching.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi @@ -1,3 +1,5 @@ +from _typeshed import SupportsGetItem + from networkx.classes.digraph import DiGraph from networkx.classes.graph import _Node from networkx.utils.backends import _dispatchable @@ -6,5 +8,5 @@ from networkx.utils.backends import _dispatchable def global_reaching_centrality(G: DiGraph[_Node], weight: str | None = None, normalized: bool | None = True): ... @_dispatchable def local_reaching_centrality( - G: DiGraph[_Node], v: _Node, paths: dict = None, weight: str | None = None, normalized: bool | None = True + G: DiGraph[_Node], v: _Node, paths: SupportsGetItem = None, weight: str | None = None, normalized: bool | None = True ): ... diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi index e6e1204ac8e0..a911a0673050 100644 --- a/stubs/networkx/networkx/algorithms/clique.pyi +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -1,4 +1,4 @@ -from collections.abc import Generator, Iterator +from collections.abc import Generator, Iterable, Iterator from typing import overload from networkx.classes.graph import Graph, _Node @@ -7,9 +7,9 @@ from networkx.utils.backends import _dispatchable @_dispatchable def enumerate_all_cliques(G: Graph[_Node]) -> Generator[list[_Node], None, None]: ... @_dispatchable -def find_cliques(G: Graph[_Node], nodes: list | None = None) -> Generator[list[_Node], None, None]: ... +def find_cliques(G: Graph[_Node], nodes: Iterable | None = None) -> Generator[list[_Node], None, None]: ... @_dispatchable -def find_cliques_recursive(G: Graph[_Node], nodes: list | None = None) -> Iterator[list[_Node]]: ... +def find_cliques_recursive(G: Graph[_Node], nodes: Iterable | None = None) -> Iterator[list[_Node]]: ... @_dispatchable def make_max_clique_graph(G: Graph[_Node], create_using: Graph[_Node] | None = None) -> Graph[_Node]: ... @_dispatchable @@ -17,6 +17,8 @@ def make_clique_bipartite( G: Graph[_Node], fpos: bool = None, create_using: Graph[_Node] | None = None, name=None ) -> Graph[_Node]: ... @overload -def node_clique_number(G: Graph[_Node], nodes=None, cliques: list | None = None, separate_nodes=False) -> dict[_Node, int]: ... +def node_clique_number( + G: Graph[_Node], nodes=None, cliques: Iterable | None = None, separate_nodes=False +) -> dict[_Node, int]: ... @overload -def node_clique_number(G: Graph[_Node], nodes=None, cliques: list | None = None, separate_nodes=False) -> int: ... +def node_clique_number(G: Graph[_Node], nodes=None, cliques: Iterable | None = None, separate_nodes=False) -> int: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi index 0c90a95e874a..935fcc3a92bd 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -1,3 +1,4 @@ +from _typeshed import SupportsGetItem from collections.abc import Generator from networkx.classes.graph import Graph, _Node @@ -11,7 +12,7 @@ def is_locally_k_edge_connected(G: Graph[_Node], s: _Node, t: _Node, k: int): .. def k_edge_augmentation( G: Graph[_Node], k: int, - avail: set[tuple[int, int]] | set[tuple[int, int, float]] | dict[tuple[int, int], float] = None, + avail: set[tuple[int, int]] | set[tuple[int, int, float]] | SupportsGetItem[tuple[int, int], float] = None, weight: str = None, partial: bool = False, ) -> Generator[tuple[_Node, _Node], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/core.pyi b/stubs/networkx/networkx/algorithms/core.pyi index 93a85034524b..a4a196002962 100644 --- a/stubs/networkx/networkx/algorithms/core.pyi +++ b/stubs/networkx/networkx/algorithms/core.pyi @@ -1,16 +1,18 @@ +from _typeshed import SupportsGetItem + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def core_number(G: Graph[_Node]): ... @_dispatchable -def k_core(G: Graph[_Node], k: int | None = None, core_number: dict | None = None): ... +def k_core(G: Graph[_Node], k: int | None = None, core_number: SupportsGetItem | None = None): ... @_dispatchable -def k_shell(G: Graph[_Node], k: int | None = None, core_number: dict | None = None): ... +def k_shell(G: Graph[_Node], k: int | None = None, core_number: SupportsGetItem | None = None): ... @_dispatchable -def k_crust(G: Graph[_Node], k: int | None = None, core_number: dict | None = None): ... +def k_crust(G: Graph[_Node], k: int | None = None, core_number: SupportsGetItem | None = None): ... @_dispatchable -def k_corona(G: Graph[_Node], k: int, core_number: dict | None = None): ... +def k_corona(G: Graph[_Node], k: int, core_number: SupportsGetItem | None = None): ... @_dispatchable def k_truss(G: Graph[_Node], k: int): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/dag.pyi b/stubs/networkx/networkx/algorithms/dag.pyi index 746f90429d14..5458999646a4 100644 --- a/stubs/networkx/networkx/algorithms/dag.pyi +++ b/stubs/networkx/networkx/algorithms/dag.pyi @@ -1,4 +1,4 @@ -from collections.abc import Callable, Generator +from collections.abc import Callable, Generator, Iterable from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node @@ -23,14 +23,14 @@ def is_aperiodic(G: DiGraph[_Node]) -> bool: ... @_dispatchable def transitive_closure(G: Graph[_Node], reflexive=False) -> Graph[_Node]: ... @_dispatchable -def transitive_closure_dag(G: DiGraph[_Node], topo_order: list | tuple | None = None) -> DiGraph[_Node]: ... +def transitive_closure_dag(G: DiGraph[_Node], topo_order: Iterable | None = None) -> DiGraph[_Node]: ... @_dispatchable def transitive_reduction(G: DiGraph[_Node]) -> DiGraph[_Node]: ... @_dispatchable -def antichains(G: DiGraph[_Node], topo_order: list | tuple | None = None) -> Generator[list[_Node], None, None]: ... +def antichains(G: DiGraph[_Node], topo_order: Iterable | None = None) -> Generator[list[_Node], None, None]: ... @_dispatchable def dag_longest_path( - G: DiGraph[_Node], weight: str | None = "weight", default_weight: int | None = 1, topo_order: list | tuple | None = None + G: DiGraph[_Node], weight: str | None = "weight", default_weight: int | None = 1, topo_order: Iterable | None = None ) -> list[_Node]: ... @_dispatchable def dag_longest_path_length(G: DiGraph[_Node], weight: str | None = "weight", default_weight: int | None = 1) -> int: ... diff --git a/stubs/networkx/networkx/algorithms/flow/mincost.pyi b/stubs/networkx/networkx/algorithms/flow/mincost.pyi index 4433ed4761f4..f339371fe069 100644 --- a/stubs/networkx/networkx/algorithms/flow/mincost.pyi +++ b/stubs/networkx/networkx/algorithms/flow/mincost.pyi @@ -1,3 +1,5 @@ +from _typeshed import SupportsGetItem + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -6,6 +8,6 @@ def min_cost_flow_cost(G: Graph[_Node], demand: str = "demand", capacity: str = @_dispatchable def min_cost_flow(G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... @_dispatchable -def cost_of_flow(G: Graph[_Node], flowDict: dict, weight: str = "weight"): ... +def cost_of_flow(G: Graph[_Node], flowDict: SupportsGetItem, weight: str = "weight"): ... @_dispatchable def max_flow_min_cost(G: Graph[_Node], s: str, t: str, capacity: str = "capacity", weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/graphical.pyi b/stubs/networkx/networkx/algorithms/graphical.pyi index 51d9b3628577..2d5534b5de04 100644 --- a/stubs/networkx/networkx/algorithms/graphical.pyi +++ b/stubs/networkx/networkx/algorithms/graphical.pyi @@ -5,11 +5,11 @@ from networkx.utils.backends import _dispatchable @_dispatchable def is_graphical(sequence: Iterable, method="eg"): ... @_dispatchable -def is_valid_degree_sequence_havel_hakimi(deg_sequence: list): ... +def is_valid_degree_sequence_havel_hakimi(deg_sequence: Iterable): ... @_dispatchable -def is_valid_degree_sequence_erdos_gallai(deg_sequence: list): ... +def is_valid_degree_sequence_erdos_gallai(deg_sequence: Iterable): ... @_dispatchable -def is_multigraphical(sequence: list): ... +def is_multigraphical(sequence: Iterable): ... @_dispatchable def is_pseudographical(sequence: Iterable): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi b/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi index 98b41a0cde94..4d9f22dbe251 100644 --- a/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi +++ b/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi @@ -1,7 +1,13 @@ +from _typeshed import SupportsGetItem + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def hits( - G: Graph[_Node], max_iter: int | None = 100, tol: float | None = 1e-08, nstart: dict | None = None, normalized: bool = True + G: Graph[_Node], + max_iter: int | None = 100, + tol: float | None = 1e-08, + nstart: SupportsGetItem | 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 ba00ec654cfb..d7ae50732108 100644 --- a/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi +++ b/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi @@ -1,3 +1,6 @@ +from _typeshed import SupportsGetItem +from collections.abc import Iterable + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -5,19 +8,19 @@ from networkx.utils.backends import _dispatchable def pagerank( G: Graph[_Node], alpha: float | None = 0.85, - personalization: dict | None = None, + personalization: SupportsGetItem | None = None, max_iter: int | None = 100, tol: float | None = 1e-06, - nstart: dict | None = None, + nstart: SupportsGetItem | None = None, weight: str | None = "weight", - dangling: dict | None = None, + dangling: SupportsGetItem | None = None, ): ... @_dispatchable def google_matrix( G: Graph[_Node], alpha: float = 0.85, - personalization: dict | None = None, - nodelist: list | None = None, + personalization: SupportsGetItem | None = None, + nodelist: Iterable | None = None, weight: str | None = "weight", - dangling: dict | None = None, + dangling: SupportsGetItem | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi index 9b8401eded55..41ad9b80912f 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi @@ -1,3 +1,4 @@ +from _typeshed import SupportsGetItem from collections.abc import Callable from typing import Any @@ -10,7 +11,7 @@ def astar_path( source: _Node, target: _Node, heuristic: Callable = None, - weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", *, cutoff: float | None = None, ): ... @@ -20,7 +21,7 @@ def astar_path_length( source: _Node, target: _Node, heuristic: Callable = None, - weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", *, cutoff: float | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi index e6c465bb999d..56240411c4d5 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi @@ -1,11 +1,14 @@ +from _typeshed import SupportsGetItem +from collections.abc import Iterable + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def floyd_warshall_numpy(G: Graph[_Node], nodelist: list | None = None, weight: str | None = "weight"): ... +def floyd_warshall_numpy(G: Graph[_Node], nodelist: Iterable | None = None, weight: str | None = "weight"): ... @_dispatchable def floyd_warshall_predecessor_and_distance(G: Graph[_Node], weight: str | None = "weight"): ... @_dispatchable -def reconstruct_path(source: _Node, target: _Node, predecessors: dict): ... +def reconstruct_path(source: _Node, target: _Node, predecessors: SupportsGetItem): ... @_dispatchable def floyd_warshall(G: Graph[_Node], weight: str | None = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi index 79a63961d90a..0a0b0424d726 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi @@ -1,4 +1,4 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, SupportsGetItem from collections.abc import Callable, Generator from typing import Any @@ -7,25 +7,31 @@ from networkx.utils.backends import _dispatchable @_dispatchable def dijkstra_path( - G: Graph[_Node], source: _Node, target: _Node, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" + G: Graph[_Node], + source: _Node, + target: _Node, + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", ): ... @_dispatchable def dijkstra_path_length( - G: Graph[_Node], source: str, target: str, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" + G: Graph[_Node], + source: str, + target: str, + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", ): ... @_dispatchable def single_source_dijkstra_path( G: Graph[_Node], source: _Node, cutoff: float | None = None, - weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", ): ... @_dispatchable def single_source_dijkstra_path_length( G: Graph[_Node], source: str, cutoff: float | None = None, - weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", ): ... @_dispatchable def single_source_dijkstra( @@ -33,21 +39,21 @@ def single_source_dijkstra( source: str, target: str | None = None, cutoff: float | None = None, - weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", ): ... @_dispatchable def multi_source_dijkstra_path( G: Graph[_Node], sources, cutoff: float | None = None, - weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", ): ... @_dispatchable def multi_source_dijkstra_path_length( G: Graph[_Node], sources, cutoff: float | None = None, - weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", ): ... @_dispatchable def multi_source_dijkstra( @@ -55,81 +61,98 @@ def multi_source_dijkstra( sources, target: str | None = None, cutoff: float | None = None, - weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", ): ... @_dispatchable def dijkstra_predecessor_and_distance( G: Graph[_Node], source: str, cutoff: float | None = None, - weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", ): ... @_dispatchable def all_pairs_dijkstra( - G: Graph[_Node], cutoff: float | None = None, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" + G: Graph[_Node], + cutoff: float | None = None, + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", ) -> Generator[Incomplete, None, None]: ... @_dispatchable def all_pairs_dijkstra_path_length( - G: Graph[_Node], cutoff: float | None = None, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" + G: Graph[_Node], + cutoff: float | None = None, + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", ) -> Generator[Incomplete, None, None]: ... @_dispatchable def all_pairs_dijkstra_path( - G: Graph[_Node], cutoff: float | None = None, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" + G: Graph[_Node], + cutoff: float | None = None, + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", ) -> Generator[Incomplete, None, None]: ... @_dispatchable def bellman_ford_predecessor_and_distance( G: Graph[_Node], source: str, target: str | None = None, - weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", heuristic: bool = False, ): ... @_dispatchable def bellman_ford_path( - G: Graph[_Node], source: _Node, target: _Node, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" + G: Graph[_Node], + source: _Node, + target: _Node, + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", ): ... @_dispatchable def bellman_ford_path_length( - G: Graph[_Node], source: str, target: str, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" + G: Graph[_Node], + source: str, + target: str, + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", ): ... @_dispatchable def single_source_bellman_ford_path( - G: Graph[_Node], source: _Node, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" + G: Graph[_Node], source: _Node, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight" ): ... @_dispatchable def single_source_bellman_ford_path_length( - G: Graph[_Node], source: str, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" + G: Graph[_Node], source: str, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight" ): ... @_dispatchable def single_source_bellman_ford( G: Graph[_Node], source: str, target: str | None = None, - weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", ): ... @_dispatchable def all_pairs_bellman_ford_path_length( - G: Graph[_Node], weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" + G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight" ) -> Generator[Incomplete, None, None]: ... @_dispatchable def all_pairs_bellman_ford_path( - G: Graph[_Node], weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" + G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight" ) -> Generator[Incomplete, None, None]: ... @_dispatchable def goldberg_radzik( - G: Graph[_Node], source: str, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" + G: Graph[_Node], source: str, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight" ): ... @_dispatchable def negative_edge_cycle( - G: Graph[_Node], weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight", heuristic: bool = True + G: Graph[_Node], + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + heuristic: bool = True, ): ... @_dispatchable def find_negative_cycle( - G: Graph[_Node], source: str, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" + G: Graph[_Node], source: str, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight" ): ... @_dispatchable def bidirectional_dijkstra( - G: Graph[_Node], source: _Node, target: _Node, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" + G: Graph[_Node], + source: _Node, + target: _Node, + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", ): ... @_dispatchable -def johnson(G: Graph[_Node], weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight"): ... +def johnson(G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/similarity.pyi b/stubs/networkx/networkx/algorithms/similarity.pyi index 40c44db74d8a..c6c385bd9e80 100644 --- a/stubs/networkx/networkx/algorithms/similarity.pyi +++ b/stubs/networkx/networkx/algorithms/similarity.pyi @@ -1,4 +1,4 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, SupportsGetItem from collections.abc import Callable, Generator from networkx.classes.graph import Graph, _Node @@ -91,7 +91,7 @@ def generate_random_paths( G: Graph[_Node], sample_size: int, path_length: int = 5, - index_map: dict | None = None, + index_map: SupportsGetItem | None = None, weight: str | None = "weight", seed: int | RandomState | 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 10190231494b..a540d681c6fd 100644 --- a/stubs/networkx/networkx/algorithms/simple_paths.pyi +++ b/stubs/networkx/networkx/algorithms/simple_paths.pyi @@ -1,5 +1,5 @@ -from _typeshed import Incomplete -from collections.abc import Callable, Generator +from _typeshed import Incomplete, SupportsGetItem +from collections.abc import Callable, Generator, Iterable from typing import Any from networkx.classes.graph import Graph, _Node @@ -8,7 +8,7 @@ from networkx.utils.backends import _dispatchable __all__ = ["all_simple_paths", "is_simple_path", "shortest_simple_paths", "all_simple_edge_paths"] @_dispatchable -def is_simple_path(G: Graph[_Node], nodes: list): ... +def is_simple_path(G: Graph[_Node], nodes: Iterable): ... @_dispatchable def all_simple_paths(G: Graph[_Node], source: _Node, target, cutoff: int | None = None) -> Generator[list[_Node], None, None]: ... @_dispatchable @@ -17,7 +17,10 @@ def all_simple_edge_paths( ) -> Generator[list[_Node] | list[tuple[_Node, _Node]], None, list[_Node] | None]: ... @_dispatchable def shortest_simple_paths( - G: Graph[_Node], source: _Node, target: _Node, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = None + G: Graph[_Node], + source: _Node, + target: _Node, + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = None, ) -> Generator[list[_Node], None, None]: ... class PathBuffer: diff --git a/stubs/networkx/networkx/algorithms/tree/coding.pyi b/stubs/networkx/networkx/algorithms/tree/coding.pyi index 5a575a4c9db4..a8dcd0ab273d 100644 --- a/stubs/networkx/networkx/algorithms/tree/coding.pyi +++ b/stubs/networkx/networkx/algorithms/tree/coding.pyi @@ -1,3 +1,5 @@ +from collections.abc import Iterable + from networkx.classes.graph import Graph, _Node from networkx.exception import NetworkXException from networkx.utils.backends import _dispatchable @@ -11,4 +13,4 @@ def from_nested_tuple(sequence: tuple, sensible_relabeling: bool = False): ... @_dispatchable def to_prufer_sequence(T: Graph[_Node]): ... @_dispatchable -def from_prufer_sequence(sequence: list): ... +def from_prufer_sequence(sequence: Iterable): ... diff --git a/stubs/networkx/networkx/algorithms/tree/operations.pyi b/stubs/networkx/networkx/algorithms/tree/operations.pyi index fa9c564763f2..74fa5ffe1956 100644 --- a/stubs/networkx/networkx/algorithms/tree/operations.pyi +++ b/stubs/networkx/networkx/algorithms/tree/operations.pyi @@ -1,4 +1,6 @@ +from collections.abc import Iterable + from networkx.utils.backends import _dispatchable @_dispatchable -def join_trees(rooted_trees: list, *, label_attribute: str = None, first_label: int | None = 0): ... +def join_trees(rooted_trees: Iterable, *, label_attribute: str = None, first_label: int | None = 0): ... diff --git a/stubs/networkx/networkx/algorithms/triads.pyi b/stubs/networkx/networkx/algorithms/triads.pyi index 4516a221509b..0b0f94742e23 100644 --- a/stubs/networkx/networkx/algorithms/triads.pyi +++ b/stubs/networkx/networkx/algorithms/triads.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Generator, Iterable from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node @@ -7,7 +7,7 @@ from networkx.utils.backends import _dispatchable from numpy.random import RandomState @_dispatchable -def triadic_census(G: DiGraph[_Node], nodelist: list = None): ... +def triadic_census(G: DiGraph[_Node], nodelist: Iterable = None): ... @_dispatchable def is_triad(G: Graph[_Node]): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/voronoi.pyi b/stubs/networkx/networkx/algorithms/voronoi.pyi index a71219be1f5a..1a5c95ed07de 100644 --- a/stubs/networkx/networkx/algorithms/voronoi.pyi +++ b/stubs/networkx/networkx/algorithms/voronoi.pyi @@ -1,3 +1,4 @@ +from _typeshed import SupportsGetItem from collections.abc import Callable from typing import Any @@ -6,5 +7,5 @@ from networkx.utils.backends import _dispatchable @_dispatchable def voronoi_cells( - G: Graph[_Node], center_nodes: set, weight: str | Callable[[Any, Any, dict[str, Any]], float | None] = "weight" + G: Graph[_Node], center_nodes: set, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight" ): ... From c9ed6b4ce35b8b65ac6154a351ccb1855ace6aac Mon Sep 17 00:00:00 2001 From: Daniel Darabos Date: Mon, 3 Feb 2025 17:55:59 +0100 Subject: [PATCH 5/7] Add "| None" where the default value is None. --- .../algorithms/approximation/connectivity.pyi | 6 +- .../approximation/dominating_set.pyi | 2 +- .../algorithms/approximation/maxcut.pyi | 8 +- .../approximation/traveling_salesman.pyi | 6 +- .../algorithms/assortativity/connectivity.pyi | 2 +- .../algorithms/assortativity/correlation.pyi | 8 +- .../algorithms/assortativity/mixing.pyi | 10 ++- .../algorithms/assortativity/pairs.pyi | 4 +- .../networkx/algorithms/bipartite/cluster.pyi | 2 +- .../algorithms/bipartite/covering.pyi | 2 +- .../algorithms/bipartite/generators.pyi | 2 +- .../algorithms/bipartite/matching.pyi | 8 +- .../networkx/algorithms/bipartite/matrix.pyi | 2 +- .../algorithms/bipartite/projection.pyi | 2 +- .../algorithms/bipartite/redundancy.pyi | 2 +- .../networkx/networkx/algorithms/boundary.pyi | 79 ++++++++++++++++--- .../networkx/networkx/algorithms/bridges.pyi | 10 ++- .../algorithms/centrality/closeness.pyi | 6 +- .../algorithms/centrality/harmonic.pyi | 2 +- .../algorithms/centrality/reaching.pyi | 2 +- stubs/networkx/networkx/algorithms/chains.pyi | 2 +- stubs/networkx/networkx/algorithms/clique.pyi | 2 +- .../algorithms/community/centrality.pyi | 2 +- .../algorithms/community/divisive.pyi | 2 +- .../algorithms/community/kernighan_lin.pyi | 6 +- .../community/label_propagation.pyi | 2 +- .../algorithms/connectivity/connectivity.pyi | 24 +++--- .../networkx/algorithms/connectivity/cuts.pyi | 16 ++-- .../connectivity/disjoint_paths.pyi | 12 +-- .../connectivity/edge_augmentation.pyi | 4 +- .../connectivity/edge_kcomponents.pyi | 4 +- .../algorithms/connectivity/kcomponents.pyi | 2 +- .../algorithms/connectivity/kcutsets.pyi | 4 +- .../networkx/networkx/algorithms/covering.pyi | 2 +- stubs/networkx/networkx/algorithms/cuts.pyi | 12 +-- stubs/networkx/networkx/algorithms/cycles.pyi | 2 +- .../networkx/algorithms/distance_measures.pyi | 10 +-- .../networkx/algorithms/dominating.pyi | 2 +- .../algorithms/flow/boykovkolmogorov.pyi | 4 +- .../networkx/algorithms/flow/dinitz_alg.pyi | 4 +- .../networkx/algorithms/flow/edmondskarp.pyi | 4 +- .../networkx/algorithms/flow/gomory_hu.pyi | 2 +- .../networkx/algorithms/flow/maxflow.pyi | 12 ++- .../networkx/algorithms/flow/preflowpush.pyi | 2 +- .../flow/shortestaugmentingpath.pyi | 4 +- .../algorithms/isomorphism/isomorph.pyi | 2 +- .../networkx/algorithms/isomorphism/vf2pp.pyi | 6 +- .../algorithms/lowest_common_ancestors.pyi | 2 +- .../algorithms/minors/contraction.pyi | 4 +- stubs/networkx/networkx/algorithms/mis.pyi | 2 +- .../networkx/algorithms/non_randomness.pyi | 2 +- .../networkx/algorithms/operators/unary.pyi | 3 +- .../algorithms/shortest_paths/astar.pyi | 4 +- .../networkx/algorithms/similarity.pyi | 32 ++++---- .../networkx/algorithms/simple_paths.pyi | 2 +- .../networkx/algorithms/sparsifiers.pyi | 2 +- .../networkx/algorithms/time_dependent.pyi | 2 +- .../algorithms/traversal/beamsearch.pyi | 2 +- .../traversal/breadth_first_search.pyi | 10 ++- .../traversal/depth_first_search.pyi | 20 +++-- .../networkx/algorithms/tree/branchings.pyi | 8 +- .../networkx/networkx/algorithms/tree/mst.pyi | 4 +- .../networkx/algorithms/tree/operations.pyi | 2 +- stubs/networkx/networkx/algorithms/triads.pyi | 2 +- .../networkx/networkx/algorithms/vitality.pyi | 4 +- 65 files changed, 258 insertions(+), 164 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi b/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi index 568ba5f86224..3190564e2300 100644 --- a/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi @@ -4,8 +4,8 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def local_node_connectivity(G: Graph[_Node], source: _Node, target: _Node, cutoff: int = None): ... +def local_node_connectivity(G: Graph[_Node], source: _Node, target: _Node, cutoff: int | None = None): ... @_dispatchable -def node_connectivity(G: Graph[_Node], s: _Node = None, t: _Node = None): ... +def node_connectivity(G: Graph[_Node], s: _Node | None = None, t: _Node | None = None): ... @_dispatchable -def all_pairs_node_connectivity(G: Graph[_Node], nbunch: Iterable = None, cutoff: int = None): ... +def all_pairs_node_connectivity(G: Graph[_Node], nbunch: Iterable | None = None, cutoff: int | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi b/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi index 7ce548203b14..0eda30759ea1 100644 --- a/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi @@ -2,6 +2,6 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def min_weighted_dominating_set(G: Graph[_Node], weight: str = None): ... +def min_weighted_dominating_set(G: Graph[_Node], weight: str | None = None): ... @_dispatchable def min_edge_dominating_set(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi b/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi index d7b34635176e..4a52ac18f72c 100644 --- a/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi @@ -3,6 +3,10 @@ from networkx.utils.backends import _dispatchable from numpy.random import RandomState @_dispatchable -def randomized_partitioning(G: Graph[_Node], seed: int | RandomState | None = None, p: float = 0.5, weight: str = None): ... +def randomized_partitioning( + G: Graph[_Node], seed: int | RandomState | None = None, p: float = 0.5, weight: str | None = None +): ... @_dispatchable -def one_exchange(G: Graph[_Node], initial_cut: set = None, seed: int | RandomState | None = None, weight: str = None): ... +def one_exchange( + G: Graph[_Node], initial_cut: set | None = None, seed: int | RandomState | None = None, weight: str | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi index 0d2178806b48..86fb044fe50a 100644 --- a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi @@ -6,14 +6,14 @@ from networkx.utils.backends import _dispatchable from numpy.random import RandomState @_dispatchable -def christofides(G: Graph[_Node], weight: str | None = "weight", tree: Graph[_Node] = None): ... +def christofides(G: Graph[_Node], weight: str | None = "weight", tree: Graph[_Node] | None = None): ... @_dispatchable def traveling_salesman_problem( - G: Graph[_Node], weight: str | None = "weight", nodes=None, cycle: bool = True, method: Callable = None, **kwargs + G: Graph[_Node], weight: str | None = "weight", nodes=None, cycle: bool = True, method: Callable | None = None, **kwargs ): ... @_dispatchable def asadpour_atsp( - G: DiGraph[_Node], weight: str | None = "weight", seed: int | RandomState | None = None, source: str = None + G: DiGraph[_Node], weight: str | None = "weight", seed: int | RandomState | None = None, source: str | None = None ): ... @_dispatchable def greedy_tsp(G: Graph[_Node], weight: str | None = "weight", source=None): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi b/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi index 09b00989cb73..8d9dfa27a493 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi @@ -5,5 +5,5 @@ from networkx.utils.backends import _dispatchable @_dispatchable def average_degree_connectivity( - G: Graph[_Node], source="in+out", target="in+out", nodes: Iterable = None, weight: str | None = None + G: Graph[_Node], source="in+out", target="in+out", nodes: Iterable | None = None, weight: str | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi index 811177ed7d9d..41a4bcfe62b9 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi @@ -5,13 +5,13 @@ from networkx.utils.backends import _dispatchable @_dispatchable def degree_assortativity_coefficient( - G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable = None + G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable | None = None ): ... @_dispatchable def degree_pearson_correlation_coefficient( - G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable = None + G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable | None = None ): ... @_dispatchable -def attribute_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable = None): ... +def attribute_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable | None = None): ... @_dispatchable -def numeric_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable = None): ... +def numeric_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi index 4c138e26a07f..e3d30b765cf3 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi @@ -5,10 +5,14 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def attribute_mixing_dict(G: Graph[_Node], attribute: str, nodes: Iterable = None, normalized: bool = False): ... +def attribute_mixing_dict(G: Graph[_Node], attribute: str, nodes: Iterable | None = None, normalized: bool = False): ... @_dispatchable def attribute_mixing_matrix( - G: Graph[_Node], attribute: str, nodes: Iterable = None, mapping: SupportsGetItem | None = None, normalized: bool = True + G: Graph[_Node], + attribute: str, + nodes: Iterable | None = None, + mapping: SupportsGetItem | None = None, + normalized: bool = True, ): ... @_dispatchable def degree_mixing_dict( @@ -20,7 +24,7 @@ def degree_mixing_matrix( x: str = "out", y: str = "in", weight: str | None = None, - nodes: Iterable = None, + nodes: Iterable | None = None, normalized: bool = True, mapping: SupportsGetItem | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi b/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi index 36a97d6acd2f..4335d32c5738 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi @@ -5,8 +5,8 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def node_attribute_xy(G: Graph[_Node], attribute, nodes: Iterable = None) -> Generator[Incomplete, None, None]: ... +def node_attribute_xy(G: Graph[_Node], attribute, nodes: Iterable | None = None) -> Generator[Incomplete, None, None]: ... @_dispatchable def node_degree_xy( - G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable = None + G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable | None = None ) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi b/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi index e8d96845edf9..bd8ac0690126 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi @@ -4,7 +4,7 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def latapy_clustering(G: Graph[_Node], nodes: Iterable = None, mode: str = "dot"): ... +def latapy_clustering(G: Graph[_Node], nodes: Iterable | None = None, mode: str = "dot"): ... clustering = latapy_clustering diff --git a/stubs/networkx/networkx/algorithms/bipartite/covering.pyi b/stubs/networkx/networkx/algorithms/bipartite/covering.pyi index 0ba573e44da6..e0212be115a5 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/covering.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/covering.pyi @@ -4,4 +4,4 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable = None): ... +def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/generators.pyi b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi index 01afd24638ff..61a4a4e037b5 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/generators.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi @@ -5,7 +5,7 @@ from networkx.utils.backends import _dispatchable from numpy.random import RandomState @_dispatchable -def complete_bipartite_graph(n1, n2, create_using: Graph[_Node] = None): ... +def complete_bipartite_graph(n1, n2, create_using: Graph[_Node] | None = None): ... @_dispatchable def configuration_model( aseq: Iterable, bseq: Iterable, create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None diff --git a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi index 3ece4ff64702..abb3bc6a2a27 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi @@ -5,13 +5,13 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def hopcroft_karp_matching(G: Graph[_Node], top_nodes: Iterable[_Node] = None): ... +def hopcroft_karp_matching(G: Graph[_Node], top_nodes: Iterable[_Node] | None = None): ... @_dispatchable -def eppstein_matching(G: Graph[_Node], top_nodes: Iterable = None): ... +def eppstein_matching(G: Graph[_Node], top_nodes: Iterable | None = None): ... @_dispatchable -def to_vertex_cover(G: Graph[_Node], matching: SupportsGetItem, top_nodes: Iterable = None): ... +def to_vertex_cover(G: Graph[_Node], matching: SupportsGetItem, top_nodes: Iterable | None = None): ... maximum_matching = hopcroft_karp_matching @_dispatchable -def minimum_weight_full_matching(G: Graph[_Node], top_nodes: Iterable = None, weight: str | None = "weight"): ... +def minimum_weight_full_matching(G: Graph[_Node], top_nodes: Iterable | None = None, weight: str | None = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi index 03def09b99f0..3b86c46921ad 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi @@ -13,4 +13,4 @@ def biadjacency_matrix( format="csr", ): ... @_dispatchable -def from_biadjacency_matrix(A, create_using: Graph[_Node] = None, edge_attribute: str = "weight"): ... +def from_biadjacency_matrix(A, create_using: Graph[_Node] | 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 3ed76739f3f9..2216f43f727f 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/projection.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/projection.pyi @@ -12,4 +12,4 @@ def collaboration_weighted_projected_graph(B: Graph[_Node], nodes: Iterable): .. @_dispatchable def overlap_weighted_projected_graph(B: Graph[_Node], nodes: Iterable, jaccard: bool = True): ... @_dispatchable -def generic_weighted_projected_graph(B: Graph[_Node], nodes: Iterable, weight_function: Callable = None): ... +def generic_weighted_projected_graph(B: Graph[_Node], nodes: Iterable, weight_function: Callable | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi b/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi index 12b023a7b43f..292acec832b7 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi @@ -4,4 +4,4 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def node_redundancy(G: Graph[_Node], nodes: Iterable = None): ... +def node_redundancy(G: Graph[_Node], nodes: Iterable | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/boundary.pyi b/stubs/networkx/networkx/algorithms/boundary.pyi index e746bd1182e5..28f0e6ac2cd1 100644 --- a/stubs/networkx/networkx/algorithms/boundary.pyi +++ b/stubs/networkx/networkx/algorithms/boundary.pyi @@ -9,47 +9,102 @@ _U = TypeVar("_U") @overload def edge_boundary( - G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None + G: Graph[_Node], + nbunch1: Iterable, + nbunch2: Iterable | None = None, + data=False, + keys: bool = False, + default: object | None = None, ) -> Generator[tuple[_Node, _Node], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None + G: Graph[_Node], + nbunch1: Iterable, + nbunch2: Iterable | None = None, + data=False, + keys: bool = False, + default: object | None = None, ) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None + G: Graph[_Node], + nbunch1: Iterable, + nbunch2: Iterable | None = None, + data=False, + keys: bool = False, + default: object | None = None, ) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None + G: Graph[_Node], + nbunch1: Iterable, + nbunch2: Iterable | None = None, + data=False, + keys: bool = False, + default: object | None = None, ) -> Generator[tuple[_Node, _Node, dict[str, _U]], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None + G: Graph[_Node], + nbunch1: Iterable, + nbunch2: Iterable | None = None, + data=False, + keys: bool = False, + default: object | None = None, ) -> Generator[tuple[_Node, _Node, dict[str, _U]], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None + G: Graph[_Node], + nbunch1: Iterable, + nbunch2: Iterable | None = None, + data=False, + keys: bool = False, + default: object | None = None, ) -> Generator[tuple[_Node, _Node, int], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None + G: Graph[_Node], + nbunch1: Iterable, + nbunch2: Iterable | None = None, + data=False, + keys: bool = False, + default: object | None = None, ) -> Generator[tuple[_Node, _Node, int], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None + G: Graph[_Node], + nbunch1: Iterable, + nbunch2: Iterable | None = None, + data=False, + keys: bool = False, + default: object | None = None, ) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None + G: Graph[_Node], + nbunch1: Iterable, + nbunch2: Iterable | None = None, + data=False, + keys: bool = False, + default: object | None = None, ) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None + G: Graph[_Node], + nbunch1: Iterable, + nbunch2: Iterable | None = None, + data=False, + keys: bool = False, + default: object | None = None, ) -> Generator[tuple[_Node, _Node, int, dict[str, _U]], None, None]: ... @overload def edge_boundary( - G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None, data=False, keys: bool = False, default: object = None + G: Graph[_Node], + nbunch1: Iterable, + nbunch2: Iterable | None = None, + data=False, + keys: bool = False, + default: object | None = None, ) -> Generator[tuple[_Node, _Node, int, dict[str, _U]], None, None]: ... @_dispatchable -def node_boundary(G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable = None) -> set[_Node]: ... +def node_boundary(G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable | None = None) -> set[_Node]: ... diff --git a/stubs/networkx/networkx/algorithms/bridges.pyi b/stubs/networkx/networkx/algorithms/bridges.pyi index 5a05424bf1ca..2beb94e80077 100644 --- a/stubs/networkx/networkx/algorithms/bridges.pyi +++ b/stubs/networkx/networkx/algorithms/bridges.pyi @@ -5,12 +5,14 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def bridges(G: Graph[_Node], root: _Node = None) -> Generator[_Node, None, None]: ... +def bridges(G: Graph[_Node], root: _Node | None = None) -> Generator[_Node, None, None]: ... @_dispatchable -def has_bridges(G: Graph[_Node], root: _Node = None) -> bool: ... +def has_bridges(G: Graph[_Node], root: _Node | None = None) -> bool: ... @overload -def local_bridges(G: Graph[_Node], with_span: bool = True, weight: str = None) -> Generator[tuple[_Node, _Node], None, None]: ... +def local_bridges( + G: Graph[_Node], with_span: bool = True, weight: str | None = None +) -> Generator[tuple[_Node, _Node], None, None]: ... @overload def local_bridges( - G: Graph[_Node], with_span: bool = True, weight: str = None + G: Graph[_Node], with_span: bool = True, weight: str | None = None ) -> Generator[tuple[_Node, _Node, int], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi index bf4314aecda3..4bb9234481c3 100644 --- a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi @@ -9,5 +9,9 @@ def closeness_centrality( ) -> dict[_Node, float]: ... @_dispatchable def incremental_closeness_centrality( - G: Graph[_Node], edge: tuple, prev_cc: SupportsGetItem = None, insertion: bool | None = True, wf_improved: bool | None = True + G: Graph[_Node], + edge: tuple, + prev_cc: SupportsGetItem | None = None, + insertion: bool | None = True, + wf_improved: bool | None = True, ) -> dict[_Node, float]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi b/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi index c8130c4a2306..7491b06f8cad 100644 --- a/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi @@ -4,4 +4,4 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def harmonic_centrality(G: Graph[_Node], nbunch: Iterable = None, distance=None, sources: Iterable = None): ... +def harmonic_centrality(G: Graph[_Node], nbunch: Iterable | None = None, distance=None, sources: Iterable | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/reaching.pyi b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi index f0d15b98224c..5ced046b9903 100644 --- a/stubs/networkx/networkx/algorithms/centrality/reaching.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi @@ -8,5 +8,5 @@ from networkx.utils.backends import _dispatchable def global_reaching_centrality(G: DiGraph[_Node], weight: str | None = None, normalized: bool | None = True): ... @_dispatchable def local_reaching_centrality( - G: DiGraph[_Node], v: _Node, paths: SupportsGetItem = None, weight: str | None = None, normalized: bool | None = True + G: DiGraph[_Node], v: _Node, paths: SupportsGetItem | None = None, weight: str | None = None, normalized: bool | None = True ): ... diff --git a/stubs/networkx/networkx/algorithms/chains.pyi b/stubs/networkx/networkx/algorithms/chains.pyi index 446a8896b241..e7f99119c9d4 100644 --- a/stubs/networkx/networkx/algorithms/chains.pyi +++ b/stubs/networkx/networkx/algorithms/chains.pyi @@ -4,4 +4,4 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def chain_decomposition(G: Graph[_Node], root: _Node = None) -> Generator[list[tuple[_Node, _Node]], None, None]: ... +def chain_decomposition(G: Graph[_Node], root: _Node | None = None) -> Generator[list[tuple[_Node, _Node]], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi index a911a0673050..fa3e18135c61 100644 --- a/stubs/networkx/networkx/algorithms/clique.pyi +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -14,7 +14,7 @@ def find_cliques_recursive(G: Graph[_Node], nodes: Iterable | None = None) -> It def make_max_clique_graph(G: Graph[_Node], create_using: Graph[_Node] | None = None) -> Graph[_Node]: ... @_dispatchable def make_clique_bipartite( - G: Graph[_Node], fpos: bool = None, create_using: Graph[_Node] | None = None, name=None + G: Graph[_Node], fpos: bool | None = None, create_using: Graph[_Node] | None = None, name=None ) -> Graph[_Node]: ... @overload def node_clique_number( diff --git a/stubs/networkx/networkx/algorithms/community/centrality.pyi b/stubs/networkx/networkx/algorithms/community/centrality.pyi index 6d84d21bc781..a72125ac1fa4 100644 --- a/stubs/networkx/networkx/algorithms/community/centrality.pyi +++ b/stubs/networkx/networkx/algorithms/community/centrality.pyi @@ -5,4 +5,4 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def girvan_newman(G: Graph[_Node], most_valuable_edge: Callable = None) -> Generator[Incomplete, None, Incomplete]: ... +def girvan_newman(G: Graph[_Node], most_valuable_edge: Callable | None = None) -> Generator[Incomplete, None, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/community/divisive.pyi b/stubs/networkx/networkx/algorithms/community/divisive.pyi index ee026d06003a..4ae890eab5f1 100644 --- a/stubs/networkx/networkx/algorithms/community/divisive.pyi +++ b/stubs/networkx/networkx/algorithms/community/divisive.pyi @@ -6,7 +6,7 @@ from networkx.classes.graph import Graph, _Node __all__ = ["edge_betweenness_partition", "edge_current_flow_betweenness_partition"] @nx._dispatchable -def edge_betweenness_partition(G: Graph[_Node], number_of_sets: int, *, weight: str = None) -> list[Incomplete]: ... +def edge_betweenness_partition(G: Graph[_Node], number_of_sets: int, *, weight: str | None = None) -> list[Incomplete]: ... @nx._dispatchable def edge_current_flow_betweenness_partition( G: Graph[_Node], number_of_sets: int, *, weight: str | None = None diff --git a/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi b/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi index 5518aabdbd14..444f8b2b3b4e 100644 --- a/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi +++ b/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi @@ -4,5 +4,9 @@ from numpy.random import RandomState @_dispatchable def kernighan_lin_bisection( - G: Graph[_Node], partition: tuple = None, max_iter: int = 10, weight: str = "weight", seed: int | RandomState | None = None + G: Graph[_Node], + partition: tuple | None = None, + max_iter: int = 10, + weight: str = "weight", + seed: int | RandomState | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/community/label_propagation.pyi b/stubs/networkx/networkx/algorithms/community/label_propagation.pyi index 094de0795753..7679d01bc6d3 100644 --- a/stubs/networkx/networkx/algorithms/community/label_propagation.pyi +++ b/stubs/networkx/networkx/algorithms/community/label_propagation.pyi @@ -7,7 +7,7 @@ from numpy.random import RandomState @_dispatchable def asyn_lpa_communities( - G: Graph[_Node], weight: str = None, seed: int | RandomState | None = None + G: Graph[_Node], weight: str | None = None, seed: int | RandomState | None = None ) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable def label_propagation_communities(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi index 511c953ab8bf..20efc74936be 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi @@ -20,28 +20,32 @@ def local_node_connectivity( G: Graph[_Node], s: _Node, t: _Node, - flow_func: Callable = None, - auxiliary: DiGraph[_Node] = None, - residual: DiGraph[_Node] = None, + flow_func: Callable | None = None, + auxiliary: DiGraph[_Node] | None = None, + residual: DiGraph[_Node] | None = None, cutoff: float | None = None, ): ... @_dispatchable -def node_connectivity(G: Graph[_Node], s: _Node = None, t: _Node = None, flow_func: Callable = None): ... +def node_connectivity(G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable | None = None): ... @_dispatchable -def average_node_connectivity(G: Graph[_Node], flow_func: Callable = None): ... +def average_node_connectivity(G: Graph[_Node], flow_func: Callable | None = None): ... @_dispatchable -def all_pairs_node_connectivity(G: Graph[_Node], nbunch: Iterable = None, flow_func: Callable = None): ... +def all_pairs_node_connectivity(G: Graph[_Node], nbunch: Iterable | None = None, flow_func: Callable | None = None): ... @_dispatchable def local_edge_connectivity( G: Graph[_Node], s: _Node, t: _Node, - flow_func: Callable = None, - auxiliary: DiGraph[_Node] = None, - residual: DiGraph[_Node] = None, + flow_func: Callable | None = None, + auxiliary: DiGraph[_Node] | None = None, + residual: DiGraph[_Node] | None = None, cutoff: float | None = None, ): ... @_dispatchable def edge_connectivity( - G: Graph[_Node], s: _Node = None, t: _Node = None, flow_func: Callable = None, cutoff: float | None = None + G: Graph[_Node], + s: _Node | None = None, + t: _Node | None = None, + flow_func: Callable | None = None, + cutoff: float | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi index 6e889357726f..06f847837dbd 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi @@ -13,20 +13,20 @@ def minimum_st_edge_cut( G: Graph[_Node], s: _Node, t: _Node, - flow_func: Callable = None, - auxiliary: DiGraph[_Node] = None, - residual: DiGraph[_Node] = None, + flow_func: Callable | None = None, + auxiliary: DiGraph[_Node] | None = None, + residual: DiGraph[_Node] | None = None, ): ... @_dispatchable def minimum_st_node_cut( G: Graph[_Node], s: _Node, t: _Node, - flow_func: Callable = None, - auxiliary: DiGraph[_Node] = None, - residual: DiGraph[_Node] = None, + flow_func: Callable | None = None, + auxiliary: DiGraph[_Node] | None = None, + residual: DiGraph[_Node] | None = None, ): ... @_dispatchable -def minimum_node_cut(G: Graph[_Node], s: _Node = None, t: _Node = None, flow_func: Callable = None): ... +def minimum_node_cut(G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable | None = None): ... @_dispatchable -def minimum_edge_cut(G: Graph[_Node], s: _Node = None, t: _Node = None, flow_func: Callable = None): ... +def minimum_edge_cut(G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi b/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi index bbb80f8e94ab..328fcd54d651 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi @@ -14,18 +14,18 @@ def edge_disjoint_paths( G: Graph[_Node], s: _Node, t: _Node, - flow_func: Callable = None, + flow_func: Callable | None = None, cutoff: int | None = None, - auxiliary: DiGraph[_Node] = None, - residual: DiGraph[_Node] = None, + auxiliary: DiGraph[_Node] | None = None, + residual: DiGraph[_Node] | None = None, ) -> Generator[Incomplete, None, None]: ... @_dispatchable def node_disjoint_paths( G: Graph[_Node], s: _Node, t: _Node, - flow_func: Callable = None, + flow_func: Callable | None = None, cutoff: int | None = None, - auxiliary: DiGraph[_Node] = None, - residual: DiGraph[_Node] = None, + auxiliary: DiGraph[_Node] | None = None, + residual: DiGraph[_Node] | None = None, ) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi index 935fcc3a92bd..de9d9d64763b 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -12,7 +12,7 @@ def is_locally_k_edge_connected(G: Graph[_Node], s: _Node, t: _Node, k: int): .. def k_edge_augmentation( G: Graph[_Node], k: int, - avail: set[tuple[int, int]] | set[tuple[int, int, float]] | SupportsGetItem[tuple[int, int], float] = None, - weight: str = None, + avail: set[tuple[int, int]] | set[tuple[int, int, float]] | SupportsGetItem[tuple[int, int], float] | None = None, + weight: str | None = None, partial: bool = False, ) -> Generator[tuple[_Node, _Node], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi index 60544bc7a79c..67927d5cb64a 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi @@ -17,5 +17,5 @@ class EdgeComponentAuxGraph: @classmethod def construct(cls, G): ... - def k_edge_components(G: Graph[_Node], k: int) -> Generator[Incomplete, Incomplete, None]: ... - def k_edge_subgraphs(G: Graph[_Node], k: int) -> Generator[Incomplete, Incomplete, None]: ... + def k_edge_components(self, k: int) -> Generator[Incomplete, Incomplete, None]: ... + def k_edge_subgraphs(self, k: int) -> Generator[Incomplete, Incomplete, None]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi index 713096bd55eb..08188ad6cd8a 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi @@ -8,4 +8,4 @@ __all__ = ["k_components"] default_flow_func = edmonds_karp @_dispatchable -def k_components(G: Graph[_Node], flow_func: Callable = None): ... +def k_components(G: Graph[_Node], flow_func: Callable | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi b/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi index 22bfca236a9c..46c72316d8a2 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi @@ -9,4 +9,6 @@ __all__ = ["all_node_cuts"] default_flow_func = edmonds_karp @_dispatchable -def all_node_cuts(G: Graph[_Node], k: int = None, flow_func: Callable = None) -> Generator[Incomplete, None, None]: ... +def all_node_cuts( + G: Graph[_Node], k: int | None = None, flow_func: Callable | None = None +) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/covering.pyi b/stubs/networkx/networkx/algorithms/covering.pyi index 6518f4362ac8..293f00908644 100644 --- a/stubs/networkx/networkx/algorithms/covering.pyi +++ b/stubs/networkx/networkx/algorithms/covering.pyi @@ -4,6 +4,6 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable = None): ... +def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable | None = None): ... @_dispatchable def is_edge_cover(G: Graph[_Node], cover: set): ... diff --git a/stubs/networkx/networkx/algorithms/cuts.pyi b/stubs/networkx/networkx/algorithms/cuts.pyi index a3302d16a8b8..4f3e3474b5b9 100644 --- a/stubs/networkx/networkx/algorithms/cuts.pyi +++ b/stubs/networkx/networkx/algorithms/cuts.pyi @@ -4,17 +4,17 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def cut_size(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] = None, weight: str = None): ... +def cut_size(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] | None = None, weight: str | None = None): ... @_dispatchable -def volume(G: Graph[_Node], S: Iterable[_Node], weight: str = None): ... +def volume(G: Graph[_Node], S: Iterable[_Node], weight: str | None = None): ... @_dispatchable -def normalized_cut_size(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] = None, weight: str = None): ... +def normalized_cut_size(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] | None = None, weight: str | None = None): ... @_dispatchable -def conductance(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] = None, weight: str = None): ... +def conductance(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] | None = None, weight: str | None = None): ... @_dispatchable -def edge_expansion(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] = None, weight: str = None): ... +def edge_expansion(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] | None = None, weight: str | None = None): ... @_dispatchable -def mixing_expansion(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] = None, weight: str = None): ... +def mixing_expansion(G: Graph[_Node], S: Iterable[_Node], T: Iterable[_Node] | None = None, weight: str | None = None): ... @_dispatchable def node_expansion(G: Graph[_Node], S: Iterable[_Node]): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/cycles.pyi b/stubs/networkx/networkx/algorithms/cycles.pyi index 5a32c2f03a6a..9f8b887516e7 100644 --- a/stubs/networkx/networkx/algorithms/cycles.pyi +++ b/stubs/networkx/networkx/algorithms/cycles.pyi @@ -23,4 +23,4 @@ def recursive_simple_cycles(G: DiGraph[_Node]): ... @_dispatchable def find_cycle(G: Graph[_Node], source=None, orientation=None): ... @_dispatchable -def minimum_cycle_basis(G: Graph[_Node], weight: str = None): ... +def minimum_cycle_basis(G: Graph[_Node], weight: str | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/distance_measures.pyi b/stubs/networkx/networkx/algorithms/distance_measures.pyi index 8a38bbafb98a..1f768011a2e9 100644 --- a/stubs/networkx/networkx/algorithms/distance_measures.pyi +++ b/stubs/networkx/networkx/algorithms/distance_measures.pyi @@ -2,15 +2,15 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def eccentricity(G: Graph[_Node], v: _Node | None = None, sp=None, weight: str = None): ... +def eccentricity(G: Graph[_Node], v: _Node | None = None, sp=None, weight: str | None = None): ... @_dispatchable -def diameter(G: Graph[_Node], e=None, usebounds=False, weight: str = None): ... +def diameter(G: Graph[_Node], e=None, usebounds=False, weight: str | None = None): ... @_dispatchable -def periphery(G: Graph[_Node], e=None, usebounds=False, weight: str = None): ... +def periphery(G: Graph[_Node], e=None, usebounds=False, weight: str | None = None): ... @_dispatchable -def radius(G: Graph[_Node], e=None, usebounds=False, weight: str = None): ... +def radius(G: Graph[_Node], e=None, usebounds=False, weight: str | None = None): ... @_dispatchable -def center(G: Graph[_Node], e=None, usebounds=False, weight: str = None): ... +def center(G: Graph[_Node], e=None, usebounds=False, weight: str | None = None): ... @_dispatchable def barycenter(G, weight: str | None = None, attr=None, sp=None): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/dominating.pyi b/stubs/networkx/networkx/algorithms/dominating.pyi index 3ff16c116ee5..2c560997240a 100644 --- a/stubs/networkx/networkx/algorithms/dominating.pyi +++ b/stubs/networkx/networkx/algorithms/dominating.pyi @@ -4,6 +4,6 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def dominating_set(G: Graph[_Node], start_with: _Node = None): ... +def dominating_set(G: Graph[_Node], start_with: _Node | None = None): ... @_dispatchable def is_dominating_set(G: Graph[_Node], nbunch: Iterable): ... diff --git a/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi b/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi index 62ffa03704f1..1389aac0009d 100644 --- a/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi +++ b/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi @@ -7,7 +7,7 @@ def boykov_kolmogorov( s: _Node, t: _Node, capacity: str = "capacity", - residual: Graph[_Node] = None, + residual: Graph[_Node] | None = None, value_only: bool = False, - cutoff: float = None, + cutoff: float | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi b/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi index 9dc076e68ad4..bd4c8bb1bdd6 100644 --- a/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi +++ b/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi @@ -7,7 +7,7 @@ def dinitz( s: _Node, t: _Node, capacity: str = "capacity", - residual: Graph[_Node] = None, + residual: Graph[_Node] | None = None, value_only: bool = False, - cutoff: float = None, + cutoff: float | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi b/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi index e444eeaf285a..95fb8d5a3809 100644 --- a/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi +++ b/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi @@ -7,7 +7,7 @@ def edmonds_karp( s: _Node, t: _Node, capacity: str = "capacity", - residual: Graph[_Node] = None, + residual: Graph[_Node] | None = None, value_only: bool = False, - cutoff: float = None, + cutoff: float | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi b/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi index 880e39f72fc0..c4089821d2dd 100644 --- a/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi +++ b/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi @@ -9,4 +9,4 @@ __all__ = ["gomory_hu_tree"] default_flow_func = edmonds_karp @_dispatchable -def gomory_hu_tree(G: Graph[_Node], capacity: str = "capacity", flow_func: Callable = None): ... +def gomory_hu_tree(G: Graph[_Node], capacity: str = "capacity", flow_func: Callable | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/flow/maxflow.pyi b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi index 6f38269c5d02..47bab99fb167 100644 --- a/stubs/networkx/networkx/algorithms/flow/maxflow.pyi +++ b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi @@ -9,14 +9,18 @@ __all__ = ["maximum_flow", "maximum_flow_value", "minimum_cut", "minimum_cut_val default_flow_func = preflow_push @_dispatchable -def maximum_flow(flowG: Graph[_Node], _s: _Node, _t: _Node, capacity: str = "capacity", flow_func: Callable = None, **kwargs): ... +def maximum_flow( + flowG: Graph[_Node], _s: _Node, _t: _Node, capacity: str = "capacity", flow_func: Callable | None = None, **kwargs +): ... @_dispatchable def maximum_flow_value( - flowG: Graph[_Node], _s: _Node, _t: _Node, capacity: str = "capacity", flow_func: Callable = None, **kwargs + flowG: Graph[_Node], _s: _Node, _t: _Node, capacity: str = "capacity", flow_func: Callable | None = None, **kwargs ): ... @_dispatchable -def minimum_cut(flowG: Graph[_Node], _s: _Node, _t: _Node, capacity: str = "capacity", flow_func: Callable = None, **kwargs): ... +def minimum_cut( + flowG: Graph[_Node], _s: _Node, _t: _Node, capacity: str = "capacity", flow_func: Callable | None = None, **kwargs +): ... @_dispatchable def minimum_cut_value( - flowG: Graph[_Node], _s: _Node, _t: _Node, capacity: str = "capacity", flow_func: Callable = None, **kwargs + flowG: Graph[_Node], _s: _Node, _t: _Node, capacity: str = "capacity", flow_func: Callable | None = None, **kwargs ): ... diff --git a/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi b/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi index bb57ff3c3de9..cd25f1cb00bd 100644 --- a/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi +++ b/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi @@ -7,7 +7,7 @@ def preflow_push( s: _Node, t: _Node, capacity: str = "capacity", - residual: Graph[_Node] = None, + residual: Graph[_Node] | None = None, global_relabel_freq: float = 1, value_only: bool = False, ): ... diff --git a/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi b/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi index 51502388deb3..43b5ae4af72c 100644 --- a/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi +++ b/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi @@ -7,8 +7,8 @@ def shortest_augmenting_path( s: _Node, t: _Node, capacity: str = "capacity", - residual: Graph[_Node] = None, + residual: Graph[_Node] | None = None, value_only: bool = False, two_phase: bool = False, - cutoff: float = None, + cutoff: float | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi b/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi index 7e09b7b20ccf..951ba0312c37 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi @@ -20,4 +20,4 @@ def faster_could_be_isomorphic(G1, G2): ... faster_graph_could_be_isomorphic = faster_could_be_isomorphic @_dispatchable -def is_isomorphic(G1, G2, node_match: Callable = None, edge_match: Callable = None): ... +def is_isomorphic(G1, G2, node_match: Callable | None = None, edge_match: Callable | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi b/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi index 0725e20af60c..61ff088b1b1f 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi @@ -26,10 +26,10 @@ class _StateParameters(NamedTuple): T2_tilde_in: Incomplete @_dispatchable -def vf2pp_isomorphism(G1, G2, node_label: str | None = None, default_label: float = None): ... +def vf2pp_isomorphism(G1, G2, node_label: str | None = None, default_label: float | None = None): ... @_dispatchable -def vf2pp_is_isomorphic(G1, G2, node_label: str | None = None, default_label: float = None): ... +def vf2pp_is_isomorphic(G1, G2, node_label: str | None = None, default_label: float | None = None): ... @_dispatchable def vf2pp_all_isomorphisms( - G1, G2, node_label: str | None = None, default_label: float = None + G1, G2, node_label: str | None = None, default_label: float | None = None ) -> Generator[Incomplete, None, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi b/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi index 20bc7e989578..fd41bff9d98b 100644 --- a/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi +++ b/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi @@ -7,6 +7,6 @@ from networkx.utils.backends import _dispatchable @_dispatchable def all_pairs_lowest_common_ancestor(G, pairs=None): ... @_dispatchable -def lowest_common_ancestor(G, node1, node2, default: object = None): ... +def lowest_common_ancestor(G, node1, node2, default: object | None = None): ... @_dispatchable def tree_all_pairs_lowest_common_ancestor(G, root: _Node | None = None, pairs=None) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/minors/contraction.pyi b/stubs/networkx/networkx/algorithms/minors/contraction.pyi index 541e0a955e6b..63c4b52117af 100644 --- a/stubs/networkx/networkx/algorithms/minors/contraction.pyi +++ b/stubs/networkx/networkx/algorithms/minors/contraction.pyi @@ -10,8 +10,8 @@ def quotient_graph( G: Graph[_Node], partition, edge_relation=None, - node_data: Callable = None, - edge_data: Callable = None, + node_data: Callable | None = None, + edge_data: Callable | None = None, weight: str | None = "weight", relabel: bool = False, create_using: Graph[_Node] | None = None, diff --git a/stubs/networkx/networkx/algorithms/mis.pyi b/stubs/networkx/networkx/algorithms/mis.pyi index a876fbb3eb17..30cc7e432d16 100644 --- a/stubs/networkx/networkx/algorithms/mis.pyi +++ b/stubs/networkx/networkx/algorithms/mis.pyi @@ -5,4 +5,4 @@ from networkx.utils.backends import _dispatchable from numpy.random import RandomState @_dispatchable -def maximal_independent_set(G: Graph[_Node], nodes: Iterable = None, seed: int | RandomState | None = None): ... +def maximal_independent_set(G: Graph[_Node], nodes: Iterable | None = None, seed: int | RandomState | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/non_randomness.pyi b/stubs/networkx/networkx/algorithms/non_randomness.pyi index 8955afa75810..fc1f04b00f2e 100644 --- a/stubs/networkx/networkx/algorithms/non_randomness.pyi +++ b/stubs/networkx/networkx/algorithms/non_randomness.pyi @@ -2,4 +2,4 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def non_randomness(G: Graph[_Node], k: int = None, weight: str | None = "weight"): ... +def non_randomness(G: Graph[_Node], k: int | None = None, weight: str | None = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/operators/unary.pyi b/stubs/networkx/networkx/algorithms/operators/unary.pyi index 6e5304605a69..cda8ebbf6b45 100644 --- a/stubs/networkx/networkx/algorithms/operators/unary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/unary.pyi @@ -1,7 +1,6 @@ from collections.abc import Hashable from typing import TypeVar -from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -10,4 +9,4 @@ _G = TypeVar("_G", bound=Graph[Hashable]) @_dispatchable def complement(G: Graph[_Node]): ... @_dispatchable -def reverse(G: DiGraph[_Node], copy: bool = True) -> _G: ... +def reverse(G: _G, copy: bool = True) -> _G: ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi index 41ad9b80912f..37361b017da8 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi @@ -10,7 +10,7 @@ def astar_path( G: Graph[_Node], source: _Node, target: _Node, - heuristic: Callable = None, + heuristic: Callable | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", *, cutoff: float | None = None, @@ -20,7 +20,7 @@ def astar_path_length( G: Graph[_Node], source: _Node, target: _Node, - heuristic: Callable = None, + heuristic: Callable | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", *, cutoff: float | None = None, diff --git a/stubs/networkx/networkx/algorithms/similarity.pyi b/stubs/networkx/networkx/algorithms/similarity.pyi index c6c385bd9e80..14db2bd23c21 100644 --- a/stubs/networkx/networkx/algorithms/similarity.pyi +++ b/stubs/networkx/networkx/algorithms/similarity.pyi @@ -9,8 +9,8 @@ from numpy.random import RandomState def graph_edit_distance( G1, G2, - node_match: Callable = None, - edge_match: Callable = None, + node_match: Callable | None = None, + edge_match: Callable | None = None, node_subst_cost=None, node_del_cost=None, node_ins_cost=None, @@ -18,59 +18,59 @@ def graph_edit_distance( edge_del_cost=None, edge_ins_cost=None, roots=None, - upper_bound: float = None, - timeout: float = None, + upper_bound: float | None = None, + timeout: float | None = None, ): ... @_dispatchable def optimal_edit_paths( G1, G2, - node_match: Callable = None, - edge_match: Callable = None, + node_match: Callable | None = None, + edge_match: Callable | None = None, node_subst_cost=None, node_del_cost=None, node_ins_cost=None, edge_subst_cost=None, edge_del_cost=None, edge_ins_cost=None, - upper_bound: float = None, + upper_bound: float | None = None, ): ... @_dispatchable def optimize_graph_edit_distance( G1, G2, - node_match: Callable = None, - edge_match: Callable = None, + node_match: Callable | None = None, + edge_match: Callable | None = None, node_subst_cost=None, node_del_cost=None, node_ins_cost=None, edge_subst_cost=None, edge_del_cost=None, edge_ins_cost=None, - upper_bound: float = None, + upper_bound: float | None = None, ) -> Generator[Incomplete, None, None]: ... @_dispatchable def optimize_edit_paths( G1, G2, - node_match: Callable = None, - edge_match: Callable = None, + node_match: Callable | None = None, + edge_match: Callable | None = None, node_subst_cost=None, node_del_cost=None, node_ins_cost=None, edge_subst_cost=None, edge_del_cost=None, edge_ins_cost=None, - upper_bound: float = None, + upper_bound: float | None = None, strictly_decreasing: bool = True, roots=None, - timeout: float = None, + timeout: float | None = None, ) -> Generator[Incomplete, None, Incomplete]: ... @_dispatchable def simrank_similarity( G: Graph[_Node], - source: _Node = None, - target: _Node = None, + source: _Node | None = None, + target: _Node | None = None, importance_factor: float = 0.9, max_iterations: int = 1000, tolerance: float = 0.0001, diff --git a/stubs/networkx/networkx/algorithms/simple_paths.pyi b/stubs/networkx/networkx/algorithms/simple_paths.pyi index a540d681c6fd..6713aa2af892 100644 --- a/stubs/networkx/networkx/algorithms/simple_paths.pyi +++ b/stubs/networkx/networkx/algorithms/simple_paths.pyi @@ -20,7 +20,7 @@ def shortest_simple_paths( G: Graph[_Node], source: _Node, target: _Node, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = None, + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float] | None = None, ) -> Generator[list[_Node], None, None]: ... class PathBuffer: diff --git a/stubs/networkx/networkx/algorithms/sparsifiers.pyi b/stubs/networkx/networkx/algorithms/sparsifiers.pyi index a334a5e5ad42..e2c456c9c1c1 100644 --- a/stubs/networkx/networkx/algorithms/sparsifiers.pyi +++ b/stubs/networkx/networkx/algorithms/sparsifiers.pyi @@ -3,4 +3,4 @@ from networkx.utils.backends import _dispatchable from numpy.random import RandomState @_dispatchable -def spanner(G: Graph[_Node], stretch: float, weight: str = None, seed: int | RandomState | None = None): ... +def spanner(G: Graph[_Node], stretch: float, weight: str | None = None, seed: int | RandomState | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/time_dependent.pyi b/stubs/networkx/networkx/algorithms/time_dependent.pyi index 43b49e9ae698..4a77f32bb5dc 100644 --- a/stubs/networkx/networkx/algorithms/time_dependent.pyi +++ b/stubs/networkx/networkx/algorithms/time_dependent.pyi @@ -2,4 +2,4 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def cd_index(G: Graph[_Node], node: _Node, time_delta, *, time: str = "time", weight: str = None): ... +def cd_index(G: Graph[_Node], node: _Node, time_delta, *, time: str = "time", weight: str | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi b/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi index 994640f2c396..447513a59790 100644 --- a/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi @@ -6,5 +6,5 @@ from networkx.utils.backends import _dispatchable @_dispatchable def bfs_beam_edges( - G: Graph[_Node], source: _Node, value: Callable, width: int = None + G: Graph[_Node], source: _Node, value: Callable, width: int | 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 7e4ab110ae63..4cfadff353db 100644 --- a/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi @@ -6,17 +6,19 @@ from networkx.utils.backends import _dispatchable @_dispatchable def bfs_edges( - G: Graph[_Node], source: _Node, reverse: bool | None = False, depth_limit=None, sort_neighbors: Callable = None + G: Graph[_Node], source: _Node, reverse: bool | None = False, depth_limit=None, sort_neighbors: Callable | None = None ) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable -def bfs_tree(G: Graph[_Node], source: _Node, reverse: bool | None = False, depth_limit=None, sort_neighbors: Callable = None): ... +def bfs_tree( + G: Graph[_Node], source: _Node, reverse: bool | None = False, depth_limit=None, sort_neighbors: Callable | None = None +): ... @_dispatchable def bfs_predecessors( - G: Graph[_Node], source: _Node, depth_limit=None, sort_neighbors: Callable = None + G: Graph[_Node], source: _Node, depth_limit=None, sort_neighbors: Callable | None = None ) -> Generator[Incomplete, None, None]: ... @_dispatchable def bfs_successors( - G: Graph[_Node], source: _Node, depth_limit=None, sort_neighbors: Callable = None + G: Graph[_Node], source: _Node, depth_limit=None, sort_neighbors: Callable | None = None ) -> Generator[Incomplete, None, None]: ... @_dispatchable def bfs_layers(G: Graph[_Node], sources) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi index 2ef3654b0e4b..3953a36b032f 100644 --- a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi @@ -5,19 +5,25 @@ from networkx.utils.backends import _dispatchable @_dispatchable def dfs_edges( - G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable = None + G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable | None = None ) -> Generator[tuple[_Node, _Node], None, None]: ... @_dispatchable -def dfs_tree(G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable = None): ... +def dfs_tree(G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable | None = None): ... @_dispatchable -def dfs_predecessors(G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable = None): ... +def dfs_predecessors( + G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable | None = None +): ... @_dispatchable -def dfs_successors(G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable = None): ... +def dfs_successors(G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable | None = None): ... @_dispatchable -def dfs_postorder_nodes(G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable = None): ... +def dfs_postorder_nodes( + G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable | None = None +): ... @_dispatchable -def dfs_preorder_nodes(G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable = None): ... +def dfs_preorder_nodes( + G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable | None = None +): ... @_dispatchable def dfs_labeled_edges( - G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable = None + G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable | None = None ) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi index fc71e4e20349..00a09bdafdbe 100644 --- a/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -25,19 +25,19 @@ def greedy_branching( ): ... @_dispatchable def maximum_branching( - G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str = None + G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str | None = None ): ... @_dispatchable def minimum_branching( - G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str = None + G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str | None = None ): ... @_dispatchable def maximum_spanning_arborescence( - G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str = None + G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str | None = None ): ... @_dispatchable def minimum_spanning_arborescence( - G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str = None + G: DiGraph[_Node], attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: str | None = None ): ... class ArborescenceIterator: diff --git a/stubs/networkx/networkx/algorithms/tree/mst.pyi b/stubs/networkx/networkx/algorithms/tree/mst.pyi index 3f974df5bb91..2a55ed99c20a 100644 --- a/stubs/networkx/networkx/algorithms/tree/mst.pyi +++ b/stubs/networkx/networkx/algorithms/tree/mst.pyi @@ -39,7 +39,9 @@ def partition_spanning_tree( @_dispatchable def maximum_spanning_tree(G: Graph[_Node], weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False): ... @_dispatchable -def random_spanning_tree(G: Graph[_Node], weight: str = None, *, multiplicative=True, seed: int | RandomState | None = None): ... +def random_spanning_tree( + G: Graph[_Node], weight: str | None = None, *, multiplicative=True, seed: int | RandomState | None = None +): ... class SpanningTreeIterator: @dataclass diff --git a/stubs/networkx/networkx/algorithms/tree/operations.pyi b/stubs/networkx/networkx/algorithms/tree/operations.pyi index 74fa5ffe1956..d09e04b61d47 100644 --- a/stubs/networkx/networkx/algorithms/tree/operations.pyi +++ b/stubs/networkx/networkx/algorithms/tree/operations.pyi @@ -3,4 +3,4 @@ from collections.abc import Iterable from networkx.utils.backends import _dispatchable @_dispatchable -def join_trees(rooted_trees: Iterable, *, label_attribute: str = None, first_label: int | None = 0): ... +def join_trees(rooted_trees: Iterable, *, label_attribute: str | None = None, first_label: int | None = 0): ... diff --git a/stubs/networkx/networkx/algorithms/triads.pyi b/stubs/networkx/networkx/algorithms/triads.pyi index 0b0f94742e23..ad2140084e19 100644 --- a/stubs/networkx/networkx/algorithms/triads.pyi +++ b/stubs/networkx/networkx/algorithms/triads.pyi @@ -7,7 +7,7 @@ from networkx.utils.backends import _dispatchable from numpy.random import RandomState @_dispatchable -def triadic_census(G: DiGraph[_Node], nodelist: Iterable = None): ... +def triadic_census(G: DiGraph[_Node], nodelist: Iterable | None = None): ... @_dispatchable def is_triad(G: Graph[_Node]): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/vitality.pyi b/stubs/networkx/networkx/algorithms/vitality.pyi index 533bf929a19c..c5a515c9f8df 100644 --- a/stubs/networkx/networkx/algorithms/vitality.pyi +++ b/stubs/networkx/networkx/algorithms/vitality.pyi @@ -2,4 +2,6 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def closeness_vitality(G: Graph[_Node], node: object = None, weight: str = None, wiener_index: float = None): ... +def closeness_vitality( + G: Graph[_Node], node: object | None = None, weight: str | None = None, wiener_index: float | None = None +): ... From 08ed5d86e7985bf9d6b48e56f93da9b209aea720 Mon Sep 17 00:00:00 2001 From: Daniel Darabos Date: Mon, 3 Feb 2025 18:32:53 +0100 Subject: [PATCH 6/7] Fix mypy and pyright errors. --- .../algorithms/approximation/connectivity.pyi | 3 +- .../algorithms/approximation/maxcut.pyi | 4 +- .../algorithms/approximation/steinertree.pyi | 3 +- .../approximation/traveling_salesman.pyi | 8 +- .../algorithms/assortativity/connectivity.pyi | 3 +- .../algorithms/assortativity/correlation.pyi | 9 +- .../algorithms/assortativity/mixing.pyi | 14 ++-- .../assortativity/neighbor_degree.pyi | 3 +- .../algorithms/assortativity/pairs.pyi | 6 +- .../networkx/algorithms/bipartite/basic.pyi | 3 +- .../networkx/algorithms/bipartite/cluster.pyi | 5 +- .../algorithms/bipartite/covering.pyi | 3 +- .../algorithms/bipartite/generators.pyi | 18 ++-- .../algorithms/bipartite/matching.pyi | 12 ++- .../networkx/algorithms/bipartite/matrix.pyi | 3 +- .../algorithms/bipartite/projection.pyi | 13 +-- .../algorithms/bipartite/redundancy.pyi | 3 +- .../networkx/networkx/algorithms/boundary.pyi | 68 +++++++-------- .../algorithms/centrality/closeness.pyi | 6 +- .../algorithms/centrality/dispersion.pyi | 8 +- .../algorithms/centrality/eigenvector.pyi | 4 +- .../networkx/algorithms/centrality/group.pyi | 11 +-- .../algorithms/centrality/harmonic.pyi | 5 +- .../networkx/algorithms/centrality/katz.pyi | 8 +- .../algorithms/centrality/laplacian.pyi | 3 +- .../algorithms/centrality/percolation.pyi | 7 +- .../algorithms/centrality/reaching.pyi | 8 +- stubs/networkx/networkx/algorithms/clique.pyi | 9 +- .../algorithms/community/centrality.pyi | 4 +- .../algorithms/community/kernighan_lin.pyi | 4 +- .../algorithms/connectivity/connectivity.pyi | 17 ++-- .../networkx/algorithms/connectivity/cuts.pyi | 13 ++- .../connectivity/disjoint_paths.pyi | 4 +- .../algorithms/connectivity/kcomponents.pyi | 3 +- .../algorithms/connectivity/kcutsets.pyi | 2 +- stubs/networkx/networkx/algorithms/core.pyi | 10 +-- .../networkx/networkx/algorithms/covering.pyi | 5 +- stubs/networkx/networkx/algorithms/dag.pyi | 14 +++- .../networkx/algorithms/dominance.pyi | 6 +- .../networkx/algorithms/dominating.pyi | 3 +- .../algorithms/efficiency_measures.pyi | 3 +- .../networkx/algorithms/flow/gomory_hu.pyi | 3 +- .../networkx/algorithms/flow/maxflow.pyi | 29 ++++++- .../networkx/algorithms/flow/mincost.pyi | 4 +- .../networkx/algorithms/graphical.pyi | 13 +-- .../algorithms/isomorphism/isomorph.pyi | 15 +++- .../networkx/algorithms/isomorphism/vf2pp.pyi | 9 +- .../algorithms/link_analysis/hits_alg.pyi | 4 +- .../algorithms/link_analysis/pagerank_alg.pyi | 14 ++-- .../algorithms/lowest_common_ancestors.pyi | 9 +- .../algorithms/minors/contraction.pyi | 7 +- stubs/networkx/networkx/algorithms/mis.pyi | 5 +- .../networkx/algorithms/operators/all.pyi | 9 +- .../networkx/algorithms/operators/binary.pyi | 14 ++-- .../networkx/algorithms/operators/product.pyi | 18 ++-- .../algorithms/shortest_paths/astar.pyi | 10 +-- .../algorithms/shortest_paths/dense.pyi | 6 +- .../algorithms/shortest_paths/generic.pyi | 19 +++-- .../algorithms/shortest_paths/weighted.pyi | 50 +++++------ .../networkx/algorithms/similarity.pyi | 82 +++++++++---------- .../networkx/algorithms/simple_paths.pyi | 4 +- .../networkx/algorithms/structuralholes.pyi | 5 +- .../networkx/algorithms/summarization.pyi | 3 +- .../algorithms/traversal/beamsearch.pyi | 2 +- .../traversal/breadth_first_search.pyi | 16 +++- .../traversal/depth_first_search.pyi | 19 +++-- .../networkx/algorithms/tree/coding.pyi | 5 +- .../networkx/algorithms/tree/operations.pyi | 3 +- stubs/networkx/networkx/algorithms/triads.pyi | 2 +- .../networkx/networkx/algorithms/vitality.pyi | 4 +- .../networkx/networkx/algorithms/voronoi.pyi | 6 +- 71 files changed, 442 insertions(+), 285 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi b/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi index 3190564e2300..b20466e208e5 100644 --- a/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -8,4 +9,4 @@ def local_node_connectivity(G: Graph[_Node], source: _Node, target: _Node, cutof @_dispatchable def node_connectivity(G: Graph[_Node], s: _Node | None = None, t: _Node | None = None): ... @_dispatchable -def all_pairs_node_connectivity(G: Graph[_Node], nbunch: Iterable | None = None, cutoff: int | None = None): ... +def all_pairs_node_connectivity(G: Graph[_Node], nbunch: Iterable[Incomplete] | None = None, cutoff: int | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi b/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi index 4a52ac18f72c..e84b601c8f21 100644 --- a/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState @@ -8,5 +10,5 @@ def randomized_partitioning( ): ... @_dispatchable def one_exchange( - G: Graph[_Node], initial_cut: set | None = None, seed: int | RandomState | None = None, weight: str | None = None + G: Graph[_Node], initial_cut: set[Incomplete] | None = None, seed: int | RandomState | None = None, weight: str | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi b/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi index 6841c94bfc8d..f75bd9023db9 100644 --- a/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -6,4 +7,4 @@ from networkx.utils.backends import _dispatchable @_dispatchable def metric_closure(G: Graph[_Node], weight="weight"): ... @_dispatchable -def steiner_tree(G: Graph[_Node], terminal_nodes: Iterable, weight: str = "weight", method: str | None = None): ... +def steiner_tree(G: Graph[_Node], terminal_nodes: Iterable[Incomplete], weight: str = "weight", method: str | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi index 86fb044fe50a..bccba05d805d 100644 --- a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Callable from networkx.classes.digraph import DiGraph @@ -9,7 +10,12 @@ from numpy.random import RandomState def christofides(G: Graph[_Node], weight: str | None = "weight", tree: Graph[_Node] | None = None): ... @_dispatchable def traveling_salesman_problem( - G: Graph[_Node], weight: str | None = "weight", nodes=None, cycle: bool = True, method: Callable | None = None, **kwargs + G: Graph[_Node], + weight: str = "weight", + nodes=None, + cycle: bool = True, + method: Callable[..., Incomplete] | None = None, + **kwargs, ): ... @_dispatchable def asadpour_atsp( diff --git a/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi b/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi index 8d9dfa27a493..3c0c202c56e8 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -5,5 +6,5 @@ from networkx.utils.backends import _dispatchable @_dispatchable def average_degree_connectivity( - G: Graph[_Node], source="in+out", target="in+out", nodes: Iterable | None = None, weight: str | None = None + G: Graph[_Node], source="in+out", target="in+out", nodes: Iterable[Incomplete] | None = None, weight: str | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi index 41a4bcfe62b9..9fe4866db3d8 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -5,13 +6,13 @@ from networkx.utils.backends import _dispatchable @_dispatchable def degree_assortativity_coefficient( - G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable | None = None + G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable[Incomplete] | None = None ): ... @_dispatchable def degree_pearson_correlation_coefficient( - G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable | None = None + G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable[Incomplete] | None = None ): ... @_dispatchable -def attribute_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable | None = None): ... +def attribute_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None): ... @_dispatchable -def numeric_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable | None = None): ... +def numeric_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi index e3d30b765cf3..c80fdae4eadb 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi @@ -1,17 +1,19 @@ -from _typeshed import SupportsGetItem +from _typeshed import Incomplete, SupportsGetItem from collections.abc import Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def attribute_mixing_dict(G: Graph[_Node], attribute: str, nodes: Iterable | None = None, normalized: bool = False): ... +def attribute_mixing_dict( + G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None, normalized: bool = False +): ... @_dispatchable def attribute_mixing_matrix( G: Graph[_Node], attribute: str, - nodes: Iterable | None = None, - mapping: SupportsGetItem | None = None, + nodes: Iterable[Incomplete] | None = None, + mapping: SupportsGetItem[Incomplete, Incomplete] | None = None, normalized: bool = True, ): ... @_dispatchable @@ -24,9 +26,9 @@ def degree_mixing_matrix( x: str = "out", y: str = "in", weight: str | None = None, - nodes: Iterable | None = None, + nodes: Iterable[Incomplete] | None = None, normalized: bool = True, - mapping: SupportsGetItem | None = None, + mapping: SupportsGetItem[Incomplete, Incomplete] | None = None, ): ... @_dispatchable 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 95338ebe82cc..042777067212 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -8,6 +9,6 @@ def average_neighbor_degree( G: Graph[_Node], source: str | None = "out", target: str | None = "out", - nodes: Iterable | None = None, + nodes: Iterable[Incomplete] | None = None, weight: str | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi b/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi index 4335d32c5738..4e9fb3c7516b 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi @@ -5,8 +5,10 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def node_attribute_xy(G: Graph[_Node], attribute, nodes: Iterable | None = None) -> Generator[Incomplete, None, None]: ... +def node_attribute_xy( + G: Graph[_Node], attribute, nodes: Iterable[Incomplete] | None = None +) -> Generator[Incomplete, None, None]: ... @_dispatchable def node_degree_xy( - G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable | None = None + G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable[Incomplete] | None = None ) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/basic.pyi b/stubs/networkx/networkx/algorithms/bipartite/basic.pyi index 23bf3ef5ffba..c8d80a1b642d 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/basic.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/basic.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -10,7 +11,7 @@ def is_bipartite(G: Graph[_Node]): ... @_dispatchable def is_bipartite_node_set(G: Graph[_Node], nodes): ... @_dispatchable -def sets(G: Graph[_Node], top_nodes: Iterable | None = None): ... +def sets(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None): ... @_dispatchable def density(B: Graph[_Node], nodes): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi b/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi index bd8ac0690126..7fed50d545d0 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi @@ -1,14 +1,15 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def latapy_clustering(G: Graph[_Node], nodes: Iterable | None = None, mode: str = "dot"): ... +def latapy_clustering(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, mode: str = "dot"): ... clustering = latapy_clustering @_dispatchable -def average_clustering(G: Graph[_Node], nodes: Iterable | None = None, mode: str = "dot"): ... +def average_clustering(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, mode: str = "dot"): ... @_dispatchable def robins_alexander_clustering(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/covering.pyi b/stubs/networkx/networkx/algorithms/bipartite/covering.pyi index e0212be115a5..9d9fe9758baf 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/covering.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/covering.pyi @@ -1,7 +1,8 @@ +from _typeshed import Incomplete from collections.abc import Callable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable | None = None): ... +def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable[..., Incomplete] | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/generators.pyi b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi index 61a4a4e037b5..3fe8b22ca59e 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/generators.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -8,17 +9,24 @@ from numpy.random import RandomState def complete_bipartite_graph(n1, n2, create_using: Graph[_Node] | None = None): ... @_dispatchable def configuration_model( - aseq: Iterable, bseq: Iterable, create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None + aseq: Iterable[Incomplete], + bseq: Iterable[Incomplete], + create_using: Graph[_Node] | None = None, + seed: int | RandomState | None = None, ): ... @_dispatchable -def havel_hakimi_graph(aseq: Iterable, bseq: Iterable, create_using: Graph[_Node] | None = None): ... +def havel_hakimi_graph(aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | None = None): ... @_dispatchable -def reverse_havel_hakimi_graph(aseq: Iterable, bseq: Iterable, create_using: Graph[_Node] | None = None): ... +def reverse_havel_hakimi_graph( + aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | None = None +): ... @_dispatchable -def alternating_havel_hakimi_graph(aseq: Iterable, bseq: Iterable, create_using: Graph[_Node] | None = None): ... +def alternating_havel_hakimi_graph( + aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | None = None +): ... @_dispatchable def preferential_attachment_graph( - aseq: Iterable, p: float, create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None + aseq: Iterable[Incomplete], p: float, create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None ): ... @_dispatchable def random_graph(n: int, m: int, p: float, seed: int | RandomState | None = None, directed: bool | None = False): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi index abb3bc6a2a27..b744c44f2e34 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi @@ -1,4 +1,4 @@ -from _typeshed import SupportsGetItem +from _typeshed import Incomplete, SupportsGetItem from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -7,11 +7,15 @@ from networkx.utils.backends import _dispatchable @_dispatchable def hopcroft_karp_matching(G: Graph[_Node], top_nodes: Iterable[_Node] | None = None): ... @_dispatchable -def eppstein_matching(G: Graph[_Node], top_nodes: Iterable | None = None): ... +def eppstein_matching(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None): ... @_dispatchable -def to_vertex_cover(G: Graph[_Node], matching: SupportsGetItem, top_nodes: Iterable | None = None): ... +def to_vertex_cover( + G: Graph[_Node], matching: SupportsGetItem[Incomplete, Incomplete], top_nodes: Iterable[Incomplete] | None = None +): ... maximum_matching = hopcroft_karp_matching @_dispatchable -def minimum_weight_full_matching(G: Graph[_Node], top_nodes: Iterable | None = None, weight: str | None = "weight"): ... +def minimum_weight_full_matching( + G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None, weight: str | None = "weight" +): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi index 3b86c46921ad..f8a7af78c99b 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -7,7 +8,7 @@ from networkx.utils.backends import _dispatchable def biadjacency_matrix( G: Graph[_Node], row_order: Iterable[_Node], - column_order: Iterable | None = None, + column_order: Iterable[Incomplete] | None = None, dtype=None, weight: str | None = "weight", format="csr", diff --git a/stubs/networkx/networkx/algorithms/bipartite/projection.pyi b/stubs/networkx/networkx/algorithms/bipartite/projection.pyi index 2216f43f727f..c545b78ff61e 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/projection.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/projection.pyi @@ -1,15 +1,18 @@ +from _typeshed import Incomplete from collections.abc import Callable, Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def projected_graph(B: Graph[_Node], nodes: Iterable, multigraph: bool = False): ... +def projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], multigraph: bool = False): ... @_dispatchable -def weighted_projected_graph(B: Graph[_Node], nodes: Iterable, ratio: bool = False): ... +def weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], ratio: bool = False): ... @_dispatchable -def collaboration_weighted_projected_graph(B: Graph[_Node], nodes: Iterable): ... +def collaboration_weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete]): ... @_dispatchable -def overlap_weighted_projected_graph(B: Graph[_Node], nodes: Iterable, jaccard: bool = True): ... +def overlap_weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], jaccard: bool = True): ... @_dispatchable -def generic_weighted_projected_graph(B: Graph[_Node], nodes: Iterable, weight_function: Callable | None = None): ... +def generic_weighted_projected_graph( + B: Graph[_Node], nodes: Iterable[Incomplete], weight_function: Callable[..., Incomplete] | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi b/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi index 292acec832b7..474329b6e68e 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi @@ -1,7 +1,8 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def node_redundancy(G: Graph[_Node], nodes: Iterable | None = None): ... +def node_redundancy(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/boundary.pyi b/stubs/networkx/networkx/algorithms/boundary.pyi index 28f0e6ac2cd1..e85644bef42f 100644 --- a/stubs/networkx/networkx/algorithms/boundary.pyi +++ b/stubs/networkx/networkx/algorithms/boundary.pyi @@ -10,101 +10,101 @@ _U = TypeVar("_U") @overload def edge_boundary( G: Graph[_Node], - nbunch1: Iterable, - nbunch2: Iterable | None = None, + nbunch1: Iterable[Incomplete], + nbunch2: Iterable[Incomplete] | None = None, data=False, keys: bool = False, - default: object | None = None, + default: Incomplete | None = None, ) -> Generator[tuple[_Node, _Node], None, None]: ... @overload def edge_boundary( G: Graph[_Node], - nbunch1: Iterable, - nbunch2: Iterable | None = None, + nbunch1: Iterable[Incomplete], + nbunch2: Iterable[Incomplete] | None = None, data=False, keys: bool = False, - default: object | None = None, + default: Incomplete | None = None, ) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( G: Graph[_Node], - nbunch1: Iterable, - nbunch2: Iterable | None = None, + nbunch1: Iterable[Incomplete], + nbunch2: Iterable[Incomplete] | None = None, data=False, keys: bool = False, - default: object | None = None, + default: Incomplete | None = None, ) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( G: Graph[_Node], - nbunch1: Iterable, - nbunch2: Iterable | None = None, + nbunch1: Iterable[Incomplete], + nbunch2: Iterable[Incomplete] | None = None, data=False, keys: bool = False, - default: object | None = None, + default: _U | None = None, ) -> Generator[tuple[_Node, _Node, dict[str, _U]], None, None]: ... @overload def edge_boundary( G: Graph[_Node], - nbunch1: Iterable, - nbunch2: Iterable | None = None, + nbunch1: Iterable[Incomplete], + nbunch2: Iterable[Incomplete] | None = None, data=False, keys: bool = False, - default: object | None = None, + default: _U | None = None, ) -> Generator[tuple[_Node, _Node, dict[str, _U]], None, None]: ... @overload def edge_boundary( G: Graph[_Node], - nbunch1: Iterable, - nbunch2: Iterable | None = None, + nbunch1: Iterable[Incomplete], + nbunch2: Iterable[Incomplete] | None = None, data=False, keys: bool = False, - default: object | None = None, + default: Incomplete | None = None, ) -> Generator[tuple[_Node, _Node, int], None, None]: ... @overload def edge_boundary( G: Graph[_Node], - nbunch1: Iterable, - nbunch2: Iterable | None = None, + nbunch1: Iterable[Incomplete], + nbunch2: Iterable[Incomplete] | None = None, data=False, keys: bool = False, - default: object | None = None, + default: Incomplete | None = None, ) -> Generator[tuple[_Node, _Node, int], None, None]: ... @overload def edge_boundary( G: Graph[_Node], - nbunch1: Iterable, - nbunch2: Iterable | None = None, + nbunch1: Iterable[Incomplete], + nbunch2: Iterable[Incomplete] | None = None, data=False, keys: bool = False, - default: object | None = None, + default: Incomplete | None = None, ) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( G: Graph[_Node], - nbunch1: Iterable, - nbunch2: Iterable | None = None, + nbunch1: Iterable[Incomplete], + nbunch2: Iterable[Incomplete] | None = None, data=False, keys: bool = False, - default: object | None = None, + default: Incomplete | None = None, ) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( G: Graph[_Node], - nbunch1: Iterable, - nbunch2: Iterable | None = None, + nbunch1: Iterable[Incomplete], + nbunch2: Iterable[Incomplete] | None = None, data=False, keys: bool = False, - default: object | None = None, + default: _U | None = None, ) -> Generator[tuple[_Node, _Node, int, dict[str, _U]], None, None]: ... @overload def edge_boundary( G: Graph[_Node], - nbunch1: Iterable, - nbunch2: Iterable | None = None, + nbunch1: Iterable[Incomplete], + nbunch2: Iterable[Incomplete] | None = None, data=False, keys: bool = False, - default: object | None = None, + default: _U | None = None, ) -> Generator[tuple[_Node, _Node, int, dict[str, _U]], None, None]: ... @_dispatchable -def node_boundary(G: Graph[_Node], nbunch1: Iterable, nbunch2: Iterable | None = None) -> set[_Node]: ... +def node_boundary(G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None) -> set[_Node]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi index 4bb9234481c3..edfae3a7b828 100644 --- a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi @@ -1,4 +1,4 @@ -from _typeshed import SupportsGetItem +from _typeshed import Incomplete, SupportsGetItem from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -10,8 +10,8 @@ def closeness_centrality( @_dispatchable def incremental_closeness_centrality( G: Graph[_Node], - edge: tuple, - prev_cc: SupportsGetItem | None = None, + edge: tuple[Incomplete], + prev_cc: SupportsGetItem[Incomplete, Incomplete] | None = None, insertion: bool | None = True, wf_improved: bool | None = True, ) -> dict[_Node, float]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/dispersion.pyi b/stubs/networkx/networkx/algorithms/centrality/dispersion.pyi index b2c9a9d5cb0e..b673beb8778b 100644 --- a/stubs/networkx/networkx/algorithms/centrality/dispersion.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/dispersion.pyi @@ -3,5 +3,11 @@ from networkx.utils.backends import _dispatchable @_dispatchable def dispersion( - G: Graph[_Node], u: _Node | None = None, v: _Node | None = None, normalized: bool = True, alpha=1.0, b=0.0, c=0.0 + G: Graph[_Node], + u: _Node | None = None, + v: _Node | None = None, + normalized: bool = True, + alpha: float = 1.0, + b: float = 0.0, + c: float = 0.0, ) -> dict[_Node, float] | dict[_Node, dict[_Node, float]]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi index f78d1b66c0bb..8c9ccd34c568 100644 --- a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi @@ -1,4 +1,4 @@ -from _typeshed import SupportsGetItem +from _typeshed import Incomplete, SupportsGetItem from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -8,7 +8,7 @@ def eigenvector_centrality( G: Graph[_Node], max_iter: int | None = 100, tol: float | None = 1e-06, - nstart: SupportsGetItem | None = None, + nstart: SupportsGetItem[Incomplete, Incomplete] | None = None, weight: str | None = None, ): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/centrality/group.pyi b/stubs/networkx/networkx/algorithms/centrality/group.pyi index 7654d1aa4381..3229bdec3789 100644 --- a/stubs/networkx/networkx/algorithms/centrality/group.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/group.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -12,16 +13,16 @@ def prominent_group( G: Graph[_Node], k: int, weight: str | None = None, - C: Iterable | None = None, + C: Iterable[Incomplete] | None = None, endpoints: bool | None = False, normalized: bool | None = True, greedy: bool | None = False, ): ... @_dispatchable -def group_closeness_centrality(G: Graph[_Node], S: Iterable, weight: str | None = None): ... +def group_closeness_centrality(G: Graph[_Node], S: Iterable[Incomplete], weight: str | None = None): ... @_dispatchable -def group_degree_centrality(G: Graph[_Node], S: Iterable): ... +def group_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]): ... @_dispatchable -def group_in_degree_centrality(G: Graph[_Node], S: Iterable): ... +def group_in_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]): ... @_dispatchable -def group_out_degree_centrality(G: Graph[_Node], S: Iterable): ... +def group_out_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi b/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi index 7491b06f8cad..af566d1c4d7d 100644 --- a/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi @@ -1,7 +1,10 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def harmonic_centrality(G: Graph[_Node], nbunch: Iterable | None = None, distance=None, sources: Iterable | None = None): ... +def harmonic_centrality( + G: Graph[_Node], nbunch: Iterable[Incomplete] | None = None, distance=None, sources: Iterable[Incomplete] | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/katz.pyi b/stubs/networkx/networkx/algorithms/centrality/katz.pyi index 75e6c3fcf4d9..ba353da7a8ce 100644 --- a/stubs/networkx/networkx/algorithms/centrality/katz.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/katz.pyi @@ -1,4 +1,4 @@ -from _typeshed import SupportsGetItem +from _typeshed import Incomplete, SupportsGetItem from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -7,10 +7,10 @@ from networkx.utils.backends import _dispatchable def katz_centrality( G: Graph[_Node], alpha: float | None = 0.1, - beta: float | SupportsGetItem | None = 1.0, + beta: float | SupportsGetItem[Incomplete, Incomplete] | None = 1.0, max_iter: int | None = 1000, tol: float | None = 1e-06, - nstart: SupportsGetItem | None = None, + nstart: SupportsGetItem[Incomplete, Incomplete] | None = None, normalized: bool | None = True, weight: str | None = None, ): ... @@ -18,7 +18,7 @@ def katz_centrality( def katz_centrality_numpy( G: Graph[_Node], alpha: float = 0.1, - beta: float | SupportsGetItem | None = 1.0, + beta: float | SupportsGetItem[Incomplete, Incomplete] | None = 1.0, normalized: bool = True, weight: str | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi b/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi index 55cff9598fea..8dfdb2d0d11a 100644 --- a/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -7,7 +8,7 @@ from networkx.utils.backends import _dispatchable def laplacian_centrality( G: Graph[_Node], normalized: bool = True, - nodelist: Iterable | None = None, + nodelist: Iterable[Incomplete] | None = None, weight: str | None = "weight", walk_type: str | None = None, alpha: float = 0.95, diff --git a/stubs/networkx/networkx/algorithms/centrality/percolation.pyi b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi index 9a0e45d84d01..b9124b5e7a0a 100644 --- a/stubs/networkx/networkx/algorithms/centrality/percolation.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi @@ -1,9 +1,12 @@ -from _typeshed import SupportsGetItem +from _typeshed import Incomplete, SupportsGetItem from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def percolation_centrality( - G: Graph[_Node], attribute: str | None = "percolation", states: SupportsGetItem | None = None, weight: str | None = None + G: Graph[_Node], + attribute: str | None = "percolation", + states: SupportsGetItem[Incomplete, Incomplete] | None = None, + weight: str | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/reaching.pyi b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi index 5ced046b9903..b2a1a2a0deeb 100644 --- a/stubs/networkx/networkx/algorithms/centrality/reaching.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi @@ -1,4 +1,4 @@ -from _typeshed import SupportsGetItem +from _typeshed import Incomplete, SupportsGetItem from networkx.classes.digraph import DiGraph from networkx.classes.graph import _Node @@ -8,5 +8,9 @@ from networkx.utils.backends import _dispatchable def global_reaching_centrality(G: DiGraph[_Node], weight: str | None = None, normalized: bool | None = True): ... @_dispatchable def local_reaching_centrality( - G: DiGraph[_Node], v: _Node, paths: SupportsGetItem | None = None, weight: str | None = None, normalized: bool | None = True + G: DiGraph[_Node], + v: _Node, + paths: SupportsGetItem[Incomplete, Incomplete] | None = None, + weight: str | None = None, + normalized: bool | None = True, ): ... diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi index fa3e18135c61..72af1e40f811 100644 --- a/stubs/networkx/networkx/algorithms/clique.pyi +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Generator, Iterable, Iterator from typing import overload @@ -7,9 +8,9 @@ from networkx.utils.backends import _dispatchable @_dispatchable def enumerate_all_cliques(G: Graph[_Node]) -> Generator[list[_Node], None, None]: ... @_dispatchable -def find_cliques(G: Graph[_Node], nodes: Iterable | None = None) -> Generator[list[_Node], None, None]: ... +def find_cliques(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None) -> Generator[list[_Node], None, None]: ... @_dispatchable -def find_cliques_recursive(G: Graph[_Node], nodes: Iterable | None = None) -> Iterator[list[_Node]]: ... +def find_cliques_recursive(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None) -> Iterator[list[_Node]]: ... @_dispatchable def make_max_clique_graph(G: Graph[_Node], create_using: Graph[_Node] | None = None) -> Graph[_Node]: ... @_dispatchable @@ -18,7 +19,7 @@ def make_clique_bipartite( ) -> Graph[_Node]: ... @overload def node_clique_number( - G: Graph[_Node], nodes=None, cliques: Iterable | None = None, separate_nodes=False + G: Graph[_Node], nodes=None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False ) -> dict[_Node, int]: ... @overload -def node_clique_number(G: Graph[_Node], nodes=None, cliques: Iterable | None = None, separate_nodes=False) -> int: ... +def node_clique_number(G: Graph[_Node], nodes=None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False) -> int: ... diff --git a/stubs/networkx/networkx/algorithms/community/centrality.pyi b/stubs/networkx/networkx/algorithms/community/centrality.pyi index a72125ac1fa4..8fbd47609966 100644 --- a/stubs/networkx/networkx/algorithms/community/centrality.pyi +++ b/stubs/networkx/networkx/algorithms/community/centrality.pyi @@ -5,4 +5,6 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def girvan_newman(G: Graph[_Node], most_valuable_edge: Callable | None = None) -> Generator[Incomplete, None, Incomplete]: ... +def girvan_newman( + G: Graph[_Node], most_valuable_edge: Callable[..., Incomplete] | None = None +) -> Generator[Incomplete, None, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi b/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi index 444f8b2b3b4e..4bb3fce53e9a 100644 --- a/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi +++ b/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState @@ -5,7 +7,7 @@ from numpy.random import RandomState @_dispatchable def kernighan_lin_bisection( G: Graph[_Node], - partition: tuple | None = None, + partition: tuple[Incomplete] | None = None, max_iter: int = 10, weight: str = "weight", seed: int | RandomState | None = None, diff --git a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi index 20efc74936be..8060b1e332c0 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Callable, Iterable from networkx.algorithms.flow import edmonds_karp @@ -20,23 +21,27 @@ def local_node_connectivity( G: Graph[_Node], s: _Node, t: _Node, - flow_func: Callable | None = None, + flow_func: Callable[..., Incomplete] | None = None, auxiliary: DiGraph[_Node] | None = None, residual: DiGraph[_Node] | None = None, cutoff: float | None = None, ): ... @_dispatchable -def node_connectivity(G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable | None = None): ... +def node_connectivity( + G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable[..., Incomplete] | None = None +): ... @_dispatchable -def average_node_connectivity(G: Graph[_Node], flow_func: Callable | None = None): ... +def average_node_connectivity(G: Graph[_Node], flow_func: Callable[..., Incomplete] | None = None): ... @_dispatchable -def all_pairs_node_connectivity(G: Graph[_Node], nbunch: Iterable | None = None, flow_func: Callable | None = None): ... +def all_pairs_node_connectivity( + G: Graph[_Node], nbunch: Iterable[Incomplete] | None = None, flow_func: Callable[..., Incomplete] | None = None +): ... @_dispatchable def local_edge_connectivity( G: Graph[_Node], s: _Node, t: _Node, - flow_func: Callable | None = None, + flow_func: Callable[..., Incomplete] | None = None, auxiliary: DiGraph[_Node] | None = None, residual: DiGraph[_Node] | None = None, cutoff: float | None = None, @@ -46,6 +51,6 @@ def edge_connectivity( G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, - flow_func: Callable | None = None, + flow_func: Callable[..., Incomplete] | None = None, cutoff: float | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi index 06f847837dbd..d9c41c57195d 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Callable from networkx.algorithms.flow import edmonds_karp @@ -13,7 +14,7 @@ def minimum_st_edge_cut( G: Graph[_Node], s: _Node, t: _Node, - flow_func: Callable | None = None, + flow_func: Callable[..., Incomplete] | None = None, auxiliary: DiGraph[_Node] | None = None, residual: DiGraph[_Node] | None = None, ): ... @@ -22,11 +23,15 @@ def minimum_st_node_cut( G: Graph[_Node], s: _Node, t: _Node, - flow_func: Callable | None = None, + flow_func: Callable[..., Incomplete] | None = None, auxiliary: DiGraph[_Node] | None = None, residual: DiGraph[_Node] | None = None, ): ... @_dispatchable -def minimum_node_cut(G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable | None = None): ... +def minimum_node_cut( + G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable[..., Incomplete] | None = None +): ... @_dispatchable -def minimum_edge_cut(G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable | None = None): ... +def minimum_edge_cut( + G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable[..., Incomplete] | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi b/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi index 328fcd54d651..254973fa6a68 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi @@ -14,7 +14,7 @@ def edge_disjoint_paths( G: Graph[_Node], s: _Node, t: _Node, - flow_func: Callable | None = None, + flow_func: Callable[..., Incomplete] | None = None, cutoff: int | None = None, auxiliary: DiGraph[_Node] | None = None, residual: DiGraph[_Node] | None = None, @@ -24,7 +24,7 @@ def node_disjoint_paths( G: Graph[_Node], s: _Node, t: _Node, - flow_func: Callable | None = None, + flow_func: Callable[..., Incomplete] | None = None, cutoff: int | None = None, auxiliary: DiGraph[_Node] | None = None, residual: DiGraph[_Node] | None = None, diff --git a/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi index 08188ad6cd8a..32010e9ed331 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Callable from networkx.algorithms.flow import edmonds_karp @@ -8,4 +9,4 @@ __all__ = ["k_components"] default_flow_func = edmonds_karp @_dispatchable -def k_components(G: Graph[_Node], flow_func: Callable | None = None): ... +def k_components(G: Graph[_Node], flow_func: Callable[..., Incomplete] | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi b/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi index 46c72316d8a2..78b0cb1befbf 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi @@ -10,5 +10,5 @@ default_flow_func = edmonds_karp @_dispatchable def all_node_cuts( - G: Graph[_Node], k: int | None = None, flow_func: Callable | None = None + G: Graph[_Node], k: int | None = None, flow_func: Callable[..., Incomplete] | None = None ) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/core.pyi b/stubs/networkx/networkx/algorithms/core.pyi index a4a196002962..401797dc8be1 100644 --- a/stubs/networkx/networkx/algorithms/core.pyi +++ b/stubs/networkx/networkx/algorithms/core.pyi @@ -1,4 +1,4 @@ -from _typeshed import SupportsGetItem +from _typeshed import Incomplete, SupportsGetItem from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -6,13 +6,13 @@ from networkx.utils.backends import _dispatchable @_dispatchable def core_number(G: Graph[_Node]): ... @_dispatchable -def k_core(G: Graph[_Node], k: int | None = None, core_number: SupportsGetItem | None = None): ... +def k_core(G: Graph[_Node], k: int | None = None, core_number: SupportsGetItem[Incomplete, Incomplete] | None = None): ... @_dispatchable -def k_shell(G: Graph[_Node], k: int | None = None, core_number: SupportsGetItem | None = None): ... +def k_shell(G: Graph[_Node], k: int | None = None, core_number: SupportsGetItem[Incomplete, Incomplete] | None = None): ... @_dispatchable -def k_crust(G: Graph[_Node], k: int | None = None, core_number: SupportsGetItem | None = None): ... +def k_crust(G: Graph[_Node], k: int | None = None, core_number: SupportsGetItem[Incomplete, Incomplete] | None = None): ... @_dispatchable -def k_corona(G: Graph[_Node], k: int, core_number: SupportsGetItem | None = None): ... +def k_corona(G: Graph[_Node], k: int, core_number: SupportsGetItem[Incomplete, Incomplete] | None = None): ... @_dispatchable def k_truss(G: Graph[_Node], k: int): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/covering.pyi b/stubs/networkx/networkx/algorithms/covering.pyi index 293f00908644..0680bbc27e41 100644 --- a/stubs/networkx/networkx/algorithms/covering.pyi +++ b/stubs/networkx/networkx/algorithms/covering.pyi @@ -1,9 +1,10 @@ +from _typeshed import Incomplete from collections.abc import Callable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable | None = None): ... +def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable[..., Incomplete] | None = None): ... @_dispatchable -def is_edge_cover(G: Graph[_Node], cover: set): ... +def is_edge_cover(G: Graph[_Node], cover: set[Incomplete]): ... diff --git a/stubs/networkx/networkx/algorithms/dag.pyi b/stubs/networkx/networkx/algorithms/dag.pyi index 5458999646a4..07c3b3deff43 100644 --- a/stubs/networkx/networkx/algorithms/dag.pyi +++ b/stubs/networkx/networkx/algorithms/dag.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Callable, Generator, Iterable from networkx.classes.digraph import DiGraph @@ -15,7 +16,9 @@ def topological_generations(G: DiGraph[_Node]) -> Generator[list[_Node], None, N @_dispatchable def topological_sort(G: DiGraph[_Node]) -> Generator[_Node, None, None]: ... @_dispatchable -def lexicographical_topological_sort(G: DiGraph[_Node], key: Callable | None = None) -> Generator[_Node, None, None]: ... +def lexicographical_topological_sort( + G: DiGraph[_Node], key: Callable[..., Incomplete] | None = None +) -> Generator[_Node, None, None]: ... @_dispatchable def all_topological_sorts(G: DiGraph[_Node]) -> Generator[list[_Node], None, None]: ... @_dispatchable @@ -23,14 +26,17 @@ def is_aperiodic(G: DiGraph[_Node]) -> bool: ... @_dispatchable def transitive_closure(G: Graph[_Node], reflexive=False) -> Graph[_Node]: ... @_dispatchable -def transitive_closure_dag(G: DiGraph[_Node], topo_order: Iterable | None = None) -> DiGraph[_Node]: ... +def transitive_closure_dag(G: DiGraph[_Node], topo_order: Iterable[Incomplete] | None = None) -> DiGraph[_Node]: ... @_dispatchable def transitive_reduction(G: DiGraph[_Node]) -> DiGraph[_Node]: ... @_dispatchable -def antichains(G: DiGraph[_Node], topo_order: Iterable | None = None) -> Generator[list[_Node], None, None]: ... +def antichains(G: DiGraph[_Node], topo_order: Iterable[Incomplete] | None = None) -> Generator[list[_Node], None, None]: ... @_dispatchable def dag_longest_path( - G: DiGraph[_Node], weight: str | None = "weight", default_weight: int | None = 1, topo_order: Iterable | None = None + G: DiGraph[_Node], + weight: str | None = "weight", + default_weight: int | None = 1, + topo_order: Iterable[Incomplete] | None = None, ) -> list[_Node]: ... @_dispatchable def dag_longest_path_length(G: DiGraph[_Node], weight: str | None = "weight", default_weight: int | None = 1) -> int: ... diff --git a/stubs/networkx/networkx/algorithms/dominance.pyi b/stubs/networkx/networkx/algorithms/dominance.pyi index 415485b28b8c..cc431c676e73 100644 --- a/stubs/networkx/networkx/algorithms/dominance.pyi +++ b/stubs/networkx/networkx/algorithms/dominance.pyi @@ -1,7 +1,7 @@ -from networkx.classes.graph import _Node +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def immediate_dominators(G, start: _Node): ... +def immediate_dominators(G: Graph[_Node], start: _Node): ... @_dispatchable -def dominance_frontiers(G, start: _Node): ... +def dominance_frontiers(G: Graph[_Node], start: _Node): ... diff --git a/stubs/networkx/networkx/algorithms/dominating.pyi b/stubs/networkx/networkx/algorithms/dominating.pyi index 2c560997240a..3786bb538077 100644 --- a/stubs/networkx/networkx/algorithms/dominating.pyi +++ b/stubs/networkx/networkx/algorithms/dominating.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -6,4 +7,4 @@ from networkx.utils.backends import _dispatchable @_dispatchable def dominating_set(G: Graph[_Node], start_with: _Node | None = None): ... @_dispatchable -def is_dominating_set(G: Graph[_Node], nbunch: Iterable): ... +def is_dominating_set(G: Graph[_Node], nbunch: Iterable[Incomplete]): ... diff --git a/stubs/networkx/networkx/algorithms/efficiency_measures.pyi b/stubs/networkx/networkx/algorithms/efficiency_measures.pyi index a0083616a943..420795a59a58 100644 --- a/stubs/networkx/networkx/algorithms/efficiency_measures.pyi +++ b/stubs/networkx/networkx/algorithms/efficiency_measures.pyi @@ -1,7 +1,8 @@ +from networkx.classes.graph import _Node from networkx.utils.backends import _dispatchable @_dispatchable -def efficiency(G, u, v): ... +def efficiency(G, u: _Node, v: _Node): ... @_dispatchable def global_efficiency(G): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi b/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi index c4089821d2dd..a1680ad0b727 100644 --- a/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi +++ b/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Callable from networkx.classes.graph import Graph, _Node @@ -9,4 +10,4 @@ __all__ = ["gomory_hu_tree"] default_flow_func = edmonds_karp @_dispatchable -def gomory_hu_tree(G: Graph[_Node], capacity: str = "capacity", flow_func: Callable | None = None): ... +def gomory_hu_tree(G: Graph[_Node], capacity: str = "capacity", flow_func: Callable[..., Incomplete] | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/flow/maxflow.pyi b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi index 47bab99fb167..a94415cfb00d 100644 --- a/stubs/networkx/networkx/algorithms/flow/maxflow.pyi +++ b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Callable from networkx.classes.graph import Graph, _Node @@ -10,17 +11,37 @@ default_flow_func = preflow_push @_dispatchable def maximum_flow( - flowG: Graph[_Node], _s: _Node, _t: _Node, capacity: str = "capacity", flow_func: Callable | None = None, **kwargs + flowG: Graph[_Node], + _s: _Node, + _t: _Node, + capacity: str = "capacity", + flow_func: Callable[..., Incomplete] | None = None, + **kwargs, ): ... @_dispatchable def maximum_flow_value( - flowG: Graph[_Node], _s: _Node, _t: _Node, capacity: str = "capacity", flow_func: Callable | None = None, **kwargs + flowG: Graph[_Node], + _s: _Node, + _t: _Node, + capacity: str = "capacity", + flow_func: Callable[..., Incomplete] | None = None, + **kwargs, ): ... @_dispatchable def minimum_cut( - flowG: Graph[_Node], _s: _Node, _t: _Node, capacity: str = "capacity", flow_func: Callable | None = None, **kwargs + flowG: Graph[_Node], + _s: _Node, + _t: _Node, + capacity: str = "capacity", + flow_func: Callable[..., Incomplete] | None = None, + **kwargs, ): ... @_dispatchable def minimum_cut_value( - flowG: Graph[_Node], _s: _Node, _t: _Node, capacity: str = "capacity", flow_func: Callable | None = None, **kwargs + flowG: Graph[_Node], + _s: _Node, + _t: _Node, + capacity: str = "capacity", + flow_func: Callable[..., Incomplete] | None = None, + **kwargs, ): ... diff --git a/stubs/networkx/networkx/algorithms/flow/mincost.pyi b/stubs/networkx/networkx/algorithms/flow/mincost.pyi index f339371fe069..86e0834f567e 100644 --- a/stubs/networkx/networkx/algorithms/flow/mincost.pyi +++ b/stubs/networkx/networkx/algorithms/flow/mincost.pyi @@ -1,4 +1,4 @@ -from _typeshed import SupportsGetItem +from _typeshed import Incomplete, SupportsGetItem from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -8,6 +8,6 @@ def min_cost_flow_cost(G: Graph[_Node], demand: str = "demand", capacity: str = @_dispatchable def min_cost_flow(G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... @_dispatchable -def cost_of_flow(G: Graph[_Node], flowDict: SupportsGetItem, weight: str = "weight"): ... +def cost_of_flow(G: Graph[_Node], flowDict: SupportsGetItem[Incomplete, Incomplete], weight: str = "weight"): ... @_dispatchable def max_flow_min_cost(G: Graph[_Node], s: str, t: str, capacity: str = "capacity", weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/graphical.pyi b/stubs/networkx/networkx/algorithms/graphical.pyi index 2d5534b5de04..87c3a9068dfd 100644 --- a/stubs/networkx/networkx/algorithms/graphical.pyi +++ b/stubs/networkx/networkx/algorithms/graphical.pyi @@ -1,16 +1,17 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.utils.backends import _dispatchable @_dispatchable -def is_graphical(sequence: Iterable, method="eg"): ... +def is_graphical(sequence: Iterable[Incomplete], method="eg"): ... @_dispatchable -def is_valid_degree_sequence_havel_hakimi(deg_sequence: Iterable): ... +def is_valid_degree_sequence_havel_hakimi(deg_sequence: Iterable[Incomplete]): ... @_dispatchable -def is_valid_degree_sequence_erdos_gallai(deg_sequence: Iterable): ... +def is_valid_degree_sequence_erdos_gallai(deg_sequence: Iterable[Incomplete]): ... @_dispatchable -def is_multigraphical(sequence: Iterable): ... +def is_multigraphical(sequence: Iterable[Incomplete]): ... @_dispatchable -def is_pseudographical(sequence: Iterable): ... +def is_pseudographical(sequence: Iterable[Incomplete]): ... @_dispatchable -def is_digraphical(in_sequence: Iterable, out_sequence: Iterable): ... +def is_digraphical(in_sequence: Iterable[Incomplete], out_sequence: Iterable[Incomplete]): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi b/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi index 951ba0312c37..369615e1ba06 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi @@ -1,23 +1,30 @@ +from _typeshed import Incomplete from collections.abc import Callable +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["could_be_isomorphic", "fast_could_be_isomorphic", "faster_could_be_isomorphic", "is_isomorphic"] @_dispatchable -def could_be_isomorphic(G1, G2): ... +def could_be_isomorphic(G1: Graph[_Node], G2: Graph[_Node]): ... graph_could_be_isomorphic = could_be_isomorphic @_dispatchable -def fast_could_be_isomorphic(G1, G2): ... +def fast_could_be_isomorphic(G1: Graph[_Node], G2: Graph[_Node]): ... fast_graph_could_be_isomorphic = fast_could_be_isomorphic @_dispatchable -def faster_could_be_isomorphic(G1, G2): ... +def faster_could_be_isomorphic(G1: Graph[_Node], G2: Graph[_Node]): ... faster_graph_could_be_isomorphic = faster_could_be_isomorphic @_dispatchable -def is_isomorphic(G1, G2, node_match: Callable | None = None, edge_match: Callable | None = None): ... +def is_isomorphic( + G1: Graph[_Node], + G2: Graph[_Node], + node_match: Callable[..., Incomplete] | None = None, + edge_match: Callable[..., Incomplete] | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi b/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi index 61ff088b1b1f..704bdcfc0f26 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi @@ -2,6 +2,7 @@ from _typeshed import Incomplete from collections.abc import Generator from typing import NamedTuple +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable class _GraphParameters(NamedTuple): @@ -26,10 +27,12 @@ class _StateParameters(NamedTuple): T2_tilde_in: Incomplete @_dispatchable -def vf2pp_isomorphism(G1, G2, node_label: str | None = None, default_label: float | None = None): ... +def vf2pp_isomorphism(G1: Graph[_Node], G2: Graph[_Node], node_label: str | None = None, default_label: float | None = None): ... @_dispatchable -def vf2pp_is_isomorphic(G1, G2, node_label: str | None = None, default_label: float | None = None): ... +def vf2pp_is_isomorphic( + G1: Graph[_Node], G2: Graph[_Node], node_label: str | None = None, default_label: float | None = None +): ... @_dispatchable def vf2pp_all_isomorphisms( - G1, G2, node_label: str | None = None, default_label: float | None = None + G1: Graph[_Node], G2: Graph[_Node], node_label: str | None = None, default_label: float | 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 4d9f22dbe251..b91bc4610a9d 100644 --- a/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi +++ b/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi @@ -1,4 +1,4 @@ -from _typeshed import SupportsGetItem +from _typeshed import Incomplete, SupportsGetItem from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -8,6 +8,6 @@ def hits( G: Graph[_Node], max_iter: int | None = 100, tol: float | None = 1e-08, - nstart: SupportsGetItem | None = None, + nstart: SupportsGetItem[Incomplete, 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 d7ae50732108..cb3ab19ce19d 100644 --- a/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi +++ b/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi @@ -1,4 +1,4 @@ -from _typeshed import SupportsGetItem +from _typeshed import Incomplete, SupportsGetItem from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -8,19 +8,19 @@ from networkx.utils.backends import _dispatchable def pagerank( G: Graph[_Node], alpha: float | None = 0.85, - personalization: SupportsGetItem | None = None, + personalization: SupportsGetItem[Incomplete, Incomplete] | None = None, max_iter: int | None = 100, tol: float | None = 1e-06, - nstart: SupportsGetItem | None = None, + nstart: SupportsGetItem[Incomplete, Incomplete] | None = None, weight: str | None = "weight", - dangling: SupportsGetItem | None = None, + dangling: SupportsGetItem[Incomplete, Incomplete] | None = None, ): ... @_dispatchable def google_matrix( G: Graph[_Node], alpha: float = 0.85, - personalization: SupportsGetItem | None = None, - nodelist: Iterable | None = None, + personalization: SupportsGetItem[Incomplete, Incomplete] | None = None, + nodelist: Iterable[Incomplete] | None = None, weight: str | None = "weight", - dangling: SupportsGetItem | None = None, + dangling: SupportsGetItem[Incomplete, Incomplete] | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi b/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi index fd41bff9d98b..b884ed0cdd2c 100644 --- a/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi +++ b/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi @@ -1,12 +1,15 @@ from _typeshed import Incomplete from collections.abc import Generator +from networkx.classes.digraph import DiGraph from networkx.classes.graph import _Node from networkx.utils.backends import _dispatchable @_dispatchable -def all_pairs_lowest_common_ancestor(G, pairs=None): ... +def all_pairs_lowest_common_ancestor(G: DiGraph[_Node], pairs=None): ... @_dispatchable -def lowest_common_ancestor(G, node1, node2, default: object | None = None): ... +def lowest_common_ancestor(G: DiGraph[_Node], node1, node2, default: Incomplete | None = None): ... @_dispatchable -def tree_all_pairs_lowest_common_ancestor(G, root: _Node | None = None, pairs=None) -> Generator[Incomplete, None, None]: ... +def tree_all_pairs_lowest_common_ancestor( + G: DiGraph[_Node], root: _Node | None = None, pairs=None +) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/minors/contraction.pyi b/stubs/networkx/networkx/algorithms/minors/contraction.pyi index 63c4b52117af..40dc9a0adda3 100644 --- a/stubs/networkx/networkx/algorithms/minors/contraction.pyi +++ b/stubs/networkx/networkx/algorithms/minors/contraction.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Callable from networkx.classes.graph import Graph, _Node @@ -10,8 +11,8 @@ def quotient_graph( G: Graph[_Node], partition, edge_relation=None, - node_data: Callable | None = None, - edge_data: Callable | None = None, + node_data: Callable[..., Incomplete] | None = None, + edge_data: Callable[..., Incomplete] | None = None, weight: str | None = "weight", relabel: bool = False, create_using: Graph[_Node] | None = None, @@ -22,4 +23,4 @@ def contracted_nodes(G: Graph[_Node], u, v, self_loops: bool = True, copy: bool identified_nodes = contracted_nodes @_dispatchable -def contracted_edge(G: Graph[_Node], edge: tuple, self_loops: bool = True, copy: bool = True): ... +def contracted_edge(G: Graph[_Node], edge: tuple[Incomplete], self_loops: bool = True, copy: bool = True): ... diff --git a/stubs/networkx/networkx/algorithms/mis.pyi b/stubs/networkx/networkx/algorithms/mis.pyi index 30cc7e432d16..66ec315178b7 100644 --- a/stubs/networkx/networkx/algorithms/mis.pyi +++ b/stubs/networkx/networkx/algorithms/mis.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -5,4 +6,6 @@ from networkx.utils.backends import _dispatchable from numpy.random import RandomState @_dispatchable -def maximal_independent_set(G: Graph[_Node], nodes: Iterable | None = None, seed: int | RandomState | None = None): ... +def maximal_independent_set( + G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, seed: int | RandomState | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/operators/all.pyi b/stubs/networkx/networkx/algorithms/operators/all.pyi index d33ac3a5f2d5..67e66bfcf29c 100644 --- a/stubs/networkx/networkx/algorithms/operators/all.pyi +++ b/stubs/networkx/networkx/algorithms/operators/all.pyi @@ -1,12 +1,13 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.utils.backends import _dispatchable @_dispatchable -def union_all(graphs: Iterable, rename: Iterable | None = ()): ... +def union_all(graphs: Iterable[Incomplete], rename: Iterable[Incomplete] | None = ()): ... @_dispatchable -def disjoint_union_all(graphs: Iterable): ... +def disjoint_union_all(graphs: Iterable[Incomplete]): ... @_dispatchable -def compose_all(graphs: Iterable): ... +def compose_all(graphs: Iterable[Incomplete]): ... @_dispatchable -def intersection_all(graphs: Iterable): ... +def intersection_all(graphs: Iterable[Incomplete]): ... diff --git a/stubs/networkx/networkx/algorithms/operators/binary.pyi b/stubs/networkx/networkx/algorithms/operators/binary.pyi index cacb64396c87..9e794329668f 100644 --- a/stubs/networkx/networkx/algorithms/operators/binary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/binary.pyi @@ -1,22 +1,24 @@ +from _typeshed import Incomplete from collections.abc import Hashable, Iterable from typing import TypeVar from networkx.classes.digraph import DiGraph +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def disjoint_union(G, H): ... +def disjoint_union(G: Graph[_Node], H: Graph[_Node]): ... @_dispatchable -def intersection(G, H): ... +def intersection(G: Graph[_Node], H: Graph[_Node]): ... @_dispatchable -def difference(G, H): ... +def difference(G: Graph[_Node], H: Graph[_Node]): ... @_dispatchable -def symmetric_difference(G, H): ... +def symmetric_difference(G: Graph[_Node], H: Graph[_Node]): ... _X = TypeVar("_X", bound=Hashable, covariant=True) _Y = TypeVar("_Y", bound=Hashable, covariant=True) @_dispatchable -def compose(G, H) -> DiGraph[_X | _Y]: ... +def compose(G: Graph[_X], H: Graph[_Y]) -> DiGraph[_X | _Y]: ... @_dispatchable -def union(G, H, rename: Iterable | None = ()) -> DiGraph[_X | _Y]: ... +def union(G: Graph[_X], H: Graph[_Y], rename: Iterable[Incomplete] | None = ()) -> DiGraph[_X | _Y]: ... diff --git a/stubs/networkx/networkx/algorithms/operators/product.pyi b/stubs/networkx/networkx/algorithms/operators/product.pyi index d128745334c3..de12cd51bd36 100644 --- a/stubs/networkx/networkx/algorithms/operators/product.pyi +++ b/stubs/networkx/networkx/algorithms/operators/product.pyi @@ -1,17 +1,23 @@ +from collections.abc import Hashable +from typing import TypeVar + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +_X = TypeVar("_X", bound=Hashable) +_Y = TypeVar("_Y", bound=Hashable) + @_dispatchable -def tensor_product(G, H): ... +def tensor_product(G: Graph[_X], H: Graph[_Y]) -> Graph[tuple[_X, _Y]]: ... @_dispatchable -def cartesian_product(G, H): ... +def cartesian_product(G: Graph[_X], H: Graph[_Y]) -> Graph[tuple[_X, _Y]]: ... @_dispatchable -def lexicographic_product(G, H): ... +def lexicographic_product(G: Graph[_X], H: Graph[_Y]) -> Graph[tuple[_X, _Y]]: ... @_dispatchable -def strong_product(G, H): ... +def strong_product(G: Graph[_X], H: Graph[_Y]) -> Graph[tuple[_X, _Y]]: ... @_dispatchable def power(G: Graph[_Node], k): ... @_dispatchable -def rooted_product(G, H, root: _Node): ... +def rooted_product(G: Graph[_X], H: Graph[_Y], root: _Y) -> Graph[tuple[_X, _Y]]: ... @_dispatchable -def corona_product(G, H): ... +def corona_product(G: Graph[_X], H: Graph[_Y]) -> Graph[tuple[_X, _Y]]: ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi index 37361b017da8..63260ea30639 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi @@ -1,4 +1,4 @@ -from _typeshed import SupportsGetItem +from _typeshed import Incomplete, SupportsGetItem from collections.abc import Callable from typing import Any @@ -10,8 +10,8 @@ def astar_path( G: Graph[_Node], source: _Node, target: _Node, - heuristic: Callable | None = None, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + heuristic: Callable[..., Incomplete] | None = None, + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", *, cutoff: float | None = None, ): ... @@ -20,8 +20,8 @@ def astar_path_length( G: Graph[_Node], source: _Node, target: _Node, - heuristic: Callable | None = None, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + heuristic: Callable[..., Incomplete] | None = None, + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", *, cutoff: float | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi index 56240411c4d5..88e66d572eb0 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi @@ -1,14 +1,14 @@ -from _typeshed import SupportsGetItem +from _typeshed import Incomplete, SupportsGetItem from collections.abc import Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def floyd_warshall_numpy(G: Graph[_Node], nodelist: Iterable | None = None, weight: str | None = "weight"): ... +def floyd_warshall_numpy(G: Graph[_Node], nodelist: Iterable[Incomplete] | None = None, weight: str | None = "weight"): ... @_dispatchable def floyd_warshall_predecessor_and_distance(G: Graph[_Node], weight: str | None = "weight"): ... @_dispatchable -def reconstruct_path(source: _Node, target: _Node, predecessors: SupportsGetItem): ... +def reconstruct_path(source: _Node, target: _Node, predecessors: SupportsGetItem[Incomplete, Incomplete]): ... @_dispatchable def floyd_warshall(G: Graph[_Node], weight: str | None = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi index 60e3b219e26a..f623aeb9ee90 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Callable, Generator from typing import overload @@ -11,7 +12,7 @@ def shortest_path( G: Graph[_Node], source: _Node | None = None, target: _Node | None = None, - weight: str | Callable | None = None, + weight: str | Callable[..., Incomplete] | None = None, method: str | None = "dijkstra", ) -> list[_Node]: ... @overload @@ -19,7 +20,7 @@ def shortest_path( G: Graph[_Node], source: _Node | None = None, target: _Node | None = None, - weight: str | Callable | None = None, + weight: str | Callable[..., Incomplete] | None = None, method: str | None = "dijkstra", ) -> dict[_Node, list[_Node]]: ... @overload @@ -27,7 +28,7 @@ def shortest_path( G: Graph[_Node], source: _Node | None = None, target: _Node | None = None, - weight: str | Callable | None = None, + weight: str | Callable[..., Incomplete] | None = None, method: str | None = "dijkstra", ) -> dict[_Node, list[_Node]]: ... @_dispatchable @@ -35,12 +36,18 @@ def shortest_path_length( G: Graph[_Node], source: _Node | None = None, target: _Node | None = None, - weight: str | Callable | None = None, + weight: str | Callable[..., Incomplete] | None = None, method: str | None = "dijkstra", ): ... @_dispatchable -def average_shortest_path_length(G: Graph[_Node], weight: str | Callable | None = None, method: str | None = None): ... +def average_shortest_path_length( + G: Graph[_Node], weight: str | Callable[..., Incomplete] | None = None, method: str | None = None +): ... @_dispatchable def all_shortest_paths( - G: Graph[_Node], source: _Node, target: _Node, weight: str | Callable | None = None, method: str | None = "dijkstra" + G: Graph[_Node], + source: _Node, + target: _Node, + weight: str | Callable[..., Incomplete] | None = None, + method: str | None = "dijkstra", ) -> Generator[list[_Node], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi index 0a0b0424d726..8c898e28bff5 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi @@ -10,28 +10,28 @@ def dijkstra_path( G: Graph[_Node], source: _Node, target: _Node, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ): ... @_dispatchable def dijkstra_path_length( G: Graph[_Node], source: str, target: str, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ): ... @_dispatchable def single_source_dijkstra_path( G: Graph[_Node], source: _Node, cutoff: float | None = None, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ): ... @_dispatchable def single_source_dijkstra_path_length( G: Graph[_Node], source: str, cutoff: float | None = None, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ): ... @_dispatchable def single_source_dijkstra( @@ -39,21 +39,21 @@ def single_source_dijkstra( source: str, target: str | None = None, cutoff: float | None = None, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ): ... @_dispatchable def multi_source_dijkstra_path( G: Graph[_Node], sources, cutoff: float | None = None, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ): ... @_dispatchable def multi_source_dijkstra_path_length( G: Graph[_Node], sources, cutoff: float | None = None, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ): ... @_dispatchable def multi_source_dijkstra( @@ -61,39 +61,39 @@ def multi_source_dijkstra( sources, target: str | None = None, cutoff: float | None = None, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ): ... @_dispatchable def dijkstra_predecessor_and_distance( G: Graph[_Node], source: str, cutoff: float | None = None, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ): ... @_dispatchable def all_pairs_dijkstra( G: Graph[_Node], cutoff: float | None = None, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ) -> Generator[Incomplete, None, None]: ... @_dispatchable def all_pairs_dijkstra_path_length( G: Graph[_Node], cutoff: float | None = None, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ) -> Generator[Incomplete, None, None]: ... @_dispatchable def all_pairs_dijkstra_path( G: Graph[_Node], cutoff: float | None = None, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ) -> Generator[Incomplete, None, None]: ... @_dispatchable def bellman_ford_predecessor_and_distance( G: Graph[_Node], source: str, target: str | None = None, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", heuristic: bool = False, ): ... @_dispatchable @@ -101,58 +101,58 @@ def bellman_ford_path( G: Graph[_Node], source: _Node, target: _Node, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ): ... @_dispatchable def bellman_ford_path_length( G: Graph[_Node], source: str, target: str, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ): ... @_dispatchable def single_source_bellman_ford_path( - G: Graph[_Node], source: _Node, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight" + G: Graph[_Node], source: _Node, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight" ): ... @_dispatchable def single_source_bellman_ford_path_length( - G: Graph[_Node], source: str, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight" + G: Graph[_Node], source: str, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight" ): ... @_dispatchable def single_source_bellman_ford( G: Graph[_Node], source: str, target: str | None = None, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ): ... @_dispatchable def all_pairs_bellman_ford_path_length( - G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight" + G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight" ) -> Generator[Incomplete, None, None]: ... @_dispatchable def all_pairs_bellman_ford_path( - G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight" + G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight" ) -> Generator[Incomplete, None, None]: ... @_dispatchable def goldberg_radzik( - G: Graph[_Node], source: str, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight" + G: Graph[_Node], source: str, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight" ): ... @_dispatchable def negative_edge_cycle( G: Graph[_Node], - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", heuristic: bool = True, ): ... @_dispatchable def find_negative_cycle( - G: Graph[_Node], source: str, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight" + G: Graph[_Node], source: str, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight" ): ... @_dispatchable def bidirectional_dijkstra( G: Graph[_Node], source: _Node, target: _Node, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight", + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ): ... @_dispatchable -def johnson(G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight"): ... +def johnson(G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/similarity.pyi b/stubs/networkx/networkx/algorithms/similarity.pyi index 14db2bd23c21..92164d71d9d8 100644 --- a/stubs/networkx/networkx/algorithms/similarity.pyi +++ b/stubs/networkx/networkx/algorithms/similarity.pyi @@ -7,60 +7,60 @@ from numpy.random import RandomState @_dispatchable def graph_edit_distance( - G1, - G2, - node_match: Callable | None = None, - edge_match: Callable | None = None, - node_subst_cost=None, - node_del_cost=None, - node_ins_cost=None, - edge_subst_cost=None, - edge_del_cost=None, - edge_ins_cost=None, + G1: Graph[_Node], + G2: Graph[_Node], + node_match: Callable[..., Incomplete] | None = None, + edge_match: Callable[..., Incomplete] | None = None, + node_subst_cost: Callable[..., Incomplete] | None = None, + node_del_cost: Callable[..., Incomplete] | None = None, + node_ins_cost: Callable[..., Incomplete] | None = None, + edge_subst_cost: Callable[..., Incomplete] | None = None, + edge_del_cost: Callable[..., Incomplete] | None = None, + edge_ins_cost: Callable[..., Incomplete] | None = None, roots=None, upper_bound: float | None = None, timeout: float | None = None, ): ... @_dispatchable def optimal_edit_paths( - G1, - G2, - node_match: Callable | None = None, - edge_match: Callable | None = None, - node_subst_cost=None, - node_del_cost=None, - node_ins_cost=None, - edge_subst_cost=None, - edge_del_cost=None, - edge_ins_cost=None, + G1: Graph[_Node], + G2: Graph[_Node], + node_match: Callable[..., Incomplete] | None = None, + edge_match: Callable[..., Incomplete] | None = None, + node_subst_cost: Callable[..., Incomplete] | None = None, + node_del_cost: Callable[..., Incomplete] | None = None, + node_ins_cost: Callable[..., Incomplete] | None = None, + edge_subst_cost: Callable[..., Incomplete] | None = None, + edge_del_cost: Callable[..., Incomplete] | None = None, + edge_ins_cost: Callable[..., Incomplete] | None = None, upper_bound: float | None = None, ): ... @_dispatchable def optimize_graph_edit_distance( - G1, - G2, - node_match: Callable | None = None, - edge_match: Callable | None = None, - node_subst_cost=None, - node_del_cost=None, - node_ins_cost=None, - edge_subst_cost=None, - edge_del_cost=None, - edge_ins_cost=None, + G1: Graph[_Node], + G2: Graph[_Node], + node_match: Callable[..., Incomplete] | None = None, + edge_match: Callable[..., Incomplete] | None = None, + node_subst_cost: Callable[..., Incomplete] | None = None, + node_del_cost: Callable[..., Incomplete] | None = None, + node_ins_cost: Callable[..., Incomplete] | None = None, + edge_subst_cost: Callable[..., Incomplete] | None = None, + edge_del_cost: Callable[..., Incomplete] | None = None, + edge_ins_cost: Callable[..., Incomplete] | None = None, upper_bound: float | None = None, ) -> Generator[Incomplete, None, None]: ... @_dispatchable def optimize_edit_paths( - G1, - G2, - node_match: Callable | None = None, - edge_match: Callable | None = None, - node_subst_cost=None, - node_del_cost=None, - node_ins_cost=None, - edge_subst_cost=None, - edge_del_cost=None, - edge_ins_cost=None, + G1: Graph[_Node], + G2: Graph[_Node], + node_match: Callable[..., Incomplete] | None = None, + edge_match: Callable[..., Incomplete] | None = None, + node_subst_cost: Callable[..., Incomplete] | None = None, + node_del_cost: Callable[..., Incomplete] | None = None, + node_ins_cost: Callable[..., Incomplete] | None = None, + edge_subst_cost: Callable[..., Incomplete] | None = None, + edge_del_cost: Callable[..., Incomplete] | None = None, + edge_ins_cost: Callable[..., Incomplete] | None = None, upper_bound: float | None = None, strictly_decreasing: bool = True, roots=None, @@ -91,7 +91,7 @@ def generate_random_paths( G: Graph[_Node], sample_size: int, path_length: int = 5, - index_map: SupportsGetItem | None = None, + index_map: SupportsGetItem[Incomplete, Incomplete] | None = None, weight: str | None = "weight", seed: int | RandomState | 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 6713aa2af892..a33ebdbb3bdc 100644 --- a/stubs/networkx/networkx/algorithms/simple_paths.pyi +++ b/stubs/networkx/networkx/algorithms/simple_paths.pyi @@ -8,7 +8,7 @@ from networkx.utils.backends import _dispatchable __all__ = ["all_simple_paths", "is_simple_path", "shortest_simple_paths", "all_simple_edge_paths"] @_dispatchable -def is_simple_path(G: Graph[_Node], nodes: Iterable): ... +def is_simple_path(G: Graph[_Node], nodes: Iterable[Incomplete]): ... @_dispatchable def all_simple_paths(G: Graph[_Node], source: _Node, target, cutoff: int | None = None) -> Generator[list[_Node], None, None]: ... @_dispatchable @@ -20,7 +20,7 @@ def shortest_simple_paths( G: Graph[_Node], source: _Node, target: _Node, - weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float] | None = None, + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = None, ) -> Generator[list[_Node], None, None]: ... class PathBuffer: diff --git a/stubs/networkx/networkx/algorithms/structuralholes.pyi b/stubs/networkx/networkx/algorithms/structuralholes.pyi index d83dc63aae46..76e026c4415d 100644 --- a/stubs/networkx/networkx/algorithms/structuralholes.pyi +++ b/stubs/networkx/networkx/algorithms/structuralholes.pyi @@ -1,11 +1,12 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def effective_size(G: Graph[_Node], nodes: Iterable | None = None, weight: str | None = None): ... +def effective_size(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, weight: str | None = None): ... @_dispatchable -def constraint(G: Graph[_Node], nodes: Iterable | None = None, weight: str | None = None): ... +def constraint(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, weight: str | None = None): ... @_dispatchable def local_constraint(G: Graph[_Node], u: _Node, v: _Node, weight: str | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/summarization.pyi b/stubs/networkx/networkx/algorithms/summarization.pyi index 996d709bcb25..05116996663b 100644 --- a/stubs/networkx/networkx/algorithms/summarization.pyi +++ b/stubs/networkx/networkx/algorithms/summarization.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -9,7 +10,7 @@ def dedensify(G: Graph[_Node], threshold: int, prefix=None, copy: bool | None = def snap_aggregation( G: Graph[_Node], node_attributes, - edge_attributes: Iterable | None = (), + edge_attributes: Iterable[Incomplete] | None = (), prefix: str = "Supernode-", supernode_attribute: str = "group", superedge_attribute: str = "types", diff --git a/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi b/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi index 447513a59790..7040e297b596 100644 --- a/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi @@ -6,5 +6,5 @@ from networkx.utils.backends import _dispatchable @_dispatchable def bfs_beam_edges( - G: Graph[_Node], source: _Node, value: Callable, width: int | None = None + G: Graph[_Node], source: _Node, value: Callable[..., Incomplete], width: int | 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 4cfadff353db..9832210f2917 100644 --- a/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi @@ -6,19 +6,27 @@ from networkx.utils.backends import _dispatchable @_dispatchable def bfs_edges( - G: Graph[_Node], source: _Node, reverse: bool | None = False, depth_limit=None, sort_neighbors: Callable | None = None + G: Graph[_Node], + source: _Node, + reverse: bool | None = False, + depth_limit=None, + sort_neighbors: Callable[..., Incomplete] | None = None, ) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable def bfs_tree( - G: Graph[_Node], source: _Node, reverse: bool | None = False, depth_limit=None, sort_neighbors: Callable | None = None + G: Graph[_Node], + source: _Node, + reverse: bool | None = False, + depth_limit=None, + sort_neighbors: Callable[..., Incomplete] | None = None, ): ... @_dispatchable def bfs_predecessors( - G: Graph[_Node], source: _Node, depth_limit=None, sort_neighbors: Callable | None = None + G: Graph[_Node], source: _Node, depth_limit=None, sort_neighbors: Callable[..., Incomplete] | None = None ) -> Generator[Incomplete, None, None]: ... @_dispatchable def bfs_successors( - G: Graph[_Node], source: _Node, depth_limit=None, sort_neighbors: Callable | None = None + G: Graph[_Node], source: _Node, depth_limit=None, sort_neighbors: Callable[..., Incomplete] | None = None ) -> Generator[Incomplete, None, None]: ... @_dispatchable def bfs_layers(G: Graph[_Node], sources) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi index 3953a36b032f..b4f3e1bc0a21 100644 --- a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Callable, Generator from networkx.classes.graph import Graph, _Node @@ -5,25 +6,29 @@ from networkx.utils.backends import _dispatchable @_dispatchable def dfs_edges( - G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable | None = None + G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable[..., Incomplete] | None = None ) -> Generator[tuple[_Node, _Node], None, None]: ... @_dispatchable -def dfs_tree(G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable | None = None): ... +def dfs_tree( + G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable[..., Incomplete] | None = None +): ... @_dispatchable def dfs_predecessors( - G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable | None = None + G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable[..., Incomplete] | None = None ): ... @_dispatchable -def dfs_successors(G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable | None = None): ... +def dfs_successors( + G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable[..., Incomplete] | None = None +): ... @_dispatchable def dfs_postorder_nodes( - G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable | None = None + G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable[..., Incomplete] | None = None ): ... @_dispatchable def dfs_preorder_nodes( - G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable | None = None + G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable[..., Incomplete] | None = None ): ... @_dispatchable def dfs_labeled_edges( - G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable | None = None + G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable[..., Incomplete] | None = None ) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/tree/coding.pyi b/stubs/networkx/networkx/algorithms/tree/coding.pyi index a8dcd0ab273d..14906e0ba3c3 100644 --- a/stubs/networkx/networkx/algorithms/tree/coding.pyi +++ b/stubs/networkx/networkx/algorithms/tree/coding.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -9,8 +10,8 @@ class NotATree(NetworkXException): ... @_dispatchable def to_nested_tuple(T: Graph[_Node], root: _Node, canonical_form: bool = False): ... @_dispatchable -def from_nested_tuple(sequence: tuple, sensible_relabeling: bool = False): ... +def from_nested_tuple(sequence: tuple[Incomplete], sensible_relabeling: bool = False): ... @_dispatchable def to_prufer_sequence(T: Graph[_Node]): ... @_dispatchable -def from_prufer_sequence(sequence: Iterable): ... +def from_prufer_sequence(sequence: Iterable[Incomplete]): ... diff --git a/stubs/networkx/networkx/algorithms/tree/operations.pyi b/stubs/networkx/networkx/algorithms/tree/operations.pyi index d09e04b61d47..a88e48eca6e1 100644 --- a/stubs/networkx/networkx/algorithms/tree/operations.pyi +++ b/stubs/networkx/networkx/algorithms/tree/operations.pyi @@ -1,6 +1,7 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.utils.backends import _dispatchable @_dispatchable -def join_trees(rooted_trees: Iterable, *, label_attribute: str | None = None, first_label: int | None = 0): ... +def join_trees(rooted_trees: Iterable[Incomplete], *, label_attribute: str | None = None, first_label: int | None = 0): ... diff --git a/stubs/networkx/networkx/algorithms/triads.pyi b/stubs/networkx/networkx/algorithms/triads.pyi index ad2140084e19..d6bea369c744 100644 --- a/stubs/networkx/networkx/algorithms/triads.pyi +++ b/stubs/networkx/networkx/algorithms/triads.pyi @@ -7,7 +7,7 @@ from networkx.utils.backends import _dispatchable from numpy.random import RandomState @_dispatchable -def triadic_census(G: DiGraph[_Node], nodelist: Iterable | None = None): ... +def triadic_census(G: DiGraph[_Node], nodelist: Iterable[Incomplete] | None = None): ... @_dispatchable def is_triad(G: Graph[_Node]): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/vitality.pyi b/stubs/networkx/networkx/algorithms/vitality.pyi index c5a515c9f8df..ec105de8f4be 100644 --- a/stubs/networkx/networkx/algorithms/vitality.pyi +++ b/stubs/networkx/networkx/algorithms/vitality.pyi @@ -1,7 +1,9 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable def closeness_vitality( - G: Graph[_Node], node: object | None = None, weight: str | None = None, wiener_index: float | None = None + G: Graph[_Node], node: Incomplete | None = None, weight: str | None = None, wiener_index: float | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/voronoi.pyi b/stubs/networkx/networkx/algorithms/voronoi.pyi index 1a5c95ed07de..806b4b12656c 100644 --- a/stubs/networkx/networkx/algorithms/voronoi.pyi +++ b/stubs/networkx/networkx/algorithms/voronoi.pyi @@ -1,4 +1,4 @@ -from _typeshed import SupportsGetItem +from _typeshed import Incomplete, SupportsGetItem from collections.abc import Callable from typing import Any @@ -7,5 +7,7 @@ from networkx.utils.backends import _dispatchable @_dispatchable def voronoi_cells( - G: Graph[_Node], center_nodes: set, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] = "weight" + G: Graph[_Node], + center_nodes: set[Incomplete], + weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ): ... From 6e03d3db53b6058ad2a6f93f02b282639cae1551 Mon Sep 17 00:00:00 2001 From: Daniel Darabos Date: Mon, 3 Feb 2025 18:41:17 +0100 Subject: [PATCH 7/7] Remove stubs for unreleased modules. --- .../algorithms/approximation/density.pyi | 5 ----- .../networkx/algorithms/community/leiden.pyi | 16 ---------------- 2 files changed, 21 deletions(-) delete mode 100644 stubs/networkx/networkx/algorithms/approximation/density.pyi delete mode 100644 stubs/networkx/networkx/algorithms/community/leiden.pyi diff --git a/stubs/networkx/networkx/algorithms/approximation/density.pyi b/stubs/networkx/networkx/algorithms/approximation/density.pyi deleted file mode 100644 index 64c1cf79ae25..000000000000 --- a/stubs/networkx/networkx/algorithms/approximation/density.pyi +++ /dev/null @@ -1,5 +0,0 @@ -from networkx.classes.graph import Graph, _Node -from networkx.utils.backends import _dispatchable - -@_dispatchable -def densest_subgraph(G: Graph[_Node], iterations: int | None = 1, *, method: str | None = "greedy++"): ... diff --git a/stubs/networkx/networkx/algorithms/community/leiden.pyi b/stubs/networkx/networkx/algorithms/community/leiden.pyi deleted file mode 100644 index d3365cb63f4c..000000000000 --- a/stubs/networkx/networkx/algorithms/community/leiden.pyi +++ /dev/null @@ -1,16 +0,0 @@ -from networkx.classes.graph import Graph, _Node -from networkx.utils.backends import _dispatchable -from numpy.random import RandomState - -@_dispatchable -def leiden_communities( - G: Graph[_Node], - weight: str | None = "weight", - resolution: float | None = 1, - max_level: int | None = None, - seed: int | RandomState | None = None, -): ... -@_dispatchable -def leiden_partitions( - G: Graph[_Node], weight: str | None = "weight", resolution: float | None = 1, seed: int | RandomState | None = None -): ...