From eb2b783977380fa1516c401e58fea4b9fa35ba57 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 13 May 2025 00:16:36 -0400 Subject: [PATCH 01/17] Merged networkx stubs from python-type-stubs --- stubs/networkx/networkx/__init__.pyi | 4 ++ .../networkx/networkx/algorithms/__init__.pyi | 1 + .../algorithms/approximation/clique.pyi | 6 +- .../approximation/clustering_coefficient.pyi | 2 +- .../algorithms/approximation/connectivity.pyi | 4 +- .../approximation/dominating_set.pyi | 6 +- .../algorithms/approximation/kcomponents.pyi | 5 +- .../algorithms/approximation/matching.pyi | 4 +- .../algorithms/approximation/maxcut.pyi | 6 +- .../approximation/traveling_salesman.pyi | 18 ++++-- .../algorithms/approximation/treewidth.pyi | 3 + .../algorithms/approximation/vertex_cover.pyi | 4 +- .../algorithms/assortativity/connectivity.pyi | 9 ++- .../algorithms/assortativity/correlation.pyi | 9 +-- .../algorithms/assortativity/mixing.pyi | 6 +- .../assortativity/neighbor_degree.pyi | 2 +- .../networkx/algorithms/asteroidal.pyi | 8 ++- .../networkx/algorithms/bipartite/basic.pyi | 8 +-- .../algorithms/bipartite/centrality.pyi | 8 ++- .../networkx/algorithms/bipartite/cluster.pyi | 16 +++-- .../algorithms/bipartite/covering.pyi | 2 +- .../algorithms/bipartite/edgelist.pyi | 19 ++++-- .../algorithms/bipartite/generators.pyi | 14 ++--- .../algorithms/bipartite/matching.pyi | 12 ++-- .../networkx/algorithms/bipartite/matrix.pyi | 9 +-- .../algorithms/bipartite/projection.pyi | 4 +- .../algorithms/bipartite/redundancy.pyi | 2 +- .../algorithms/bipartite/spectral.pyi | 4 +- .../networkx/networkx/algorithms/boundary.pyi | 22 +++---- .../algorithms/centrality/closeness.pyi | 5 +- .../centrality/current_flow_betweenness.pyi | 8 ++- .../current_flow_betweenness_subset.pyi | 5 +- .../centrality/current_flow_closeness.pyi | 6 +- .../algorithms/centrality/eigenvector.pyi | 9 +-- .../networkx/algorithms/centrality/group.pyi | 10 +-- .../algorithms/centrality/harmonic.pyi | 2 +- .../networkx/algorithms/centrality/katz.pyi | 7 ++- .../networkx/algorithms/centrality/load.pyi | 4 +- .../algorithms/centrality/percolation.pyi | 7 ++- .../algorithms/centrality/reaching.pyi | 4 +- .../algorithms/centrality/second_order.pyi | 4 +- .../algorithms/centrality/subgraph_alg.pyi | 10 +-- .../algorithms/centrality/trophic.pyi | 7 ++- .../algorithms/centrality/voterank_alg.pyi | 4 +- .../networkx/networkx/algorithms/chordal.pyi | 2 +- stubs/networkx/networkx/algorithms/clique.pyi | 22 +++++-- .../networkx/networkx/algorithms/cluster.pyi | 11 ++-- .../coloring/equitable_coloring.pyi | 12 ++++ .../algorithms/coloring/greedy_coloring.pyi | 21 ++++--- .../algorithms/communicability_alg.pyi | 6 +- .../algorithms/community/asyn_fluid.pyi | 5 +- .../algorithms/community/kernighan_lin.pyi | 2 +- .../community/label_propagation.pyi | 2 +- .../networkx/algorithms/community/louvain.pyi | 4 +- .../networkx/algorithms/community/lukes.pyi | 9 +++ .../algorithms/community/modularity_max.pyi | 2 +- .../networkx/algorithms/community/quality.pyi | 13 +++- .../algorithms/components/attracting.pyi | 8 ++- .../algorithms/components/connected.pyi | 4 +- .../algorithms/components/semiconnected.pyi | 2 +- .../algorithms/connectivity/connectivity.pyi | 4 +- .../networkx/algorithms/connectivity/cuts.pyi | 9 +-- .../connectivity/edge_augmentation.pyi | 23 ++++++- .../connectivity/edge_kcomponents.pyi | 5 +- .../algorithms/connectivity/kcomponents.pyi | 3 +- .../algorithms/connectivity/utils.pyi | 8 ++- stubs/networkx/networkx/algorithms/core.pyi | 4 +- .../networkx/networkx/algorithms/covering.pyi | 6 +- .../networkx/algorithms/d_separation.pyi | 9 ++- stubs/networkx/networkx/algorithms/dag.pyi | 7 ++- .../networkx/algorithms/distance_measures.pyi | 16 +++-- .../networkx/algorithms/distance_regular.pyi | 9 ++- .../networkx/algorithms/dominating.pyi | 4 +- .../algorithms/efficiency_measures.pyi | 6 +- stubs/networkx/networkx/algorithms/euler.pyi | 2 +- .../networkx/algorithms/flow/mincost.pyi | 8 ++- .../algorithms/flow/networksimplex.pyi | 8 ++- .../networkx/algorithms/flow/utils.pyi | 6 +- .../networkx/algorithms/graph_hashing.pyi | 6 +- .../networkx/algorithms/graphical.pyi | 12 ++-- .../networkx/algorithms/hierarchy.pyi | 4 +- .../networkx/networkx/algorithms/isolate.pyi | 4 +- .../algorithms/isomorphism/ismags.pyi | 12 ++-- .../algorithms/isomorphism/isomorphvf2.pyi | 6 +- .../algorithms/isomorphism/matchhelpers.pyi | 22 ++++--- .../isomorphism/temporalisomorphvf2.pyi | 5 +- .../isomorphism/tree_isomorphism.pyi | 11 +++- .../algorithms/isomorphism/vf2userfunc.pyi | 20 +++++- .../algorithms/link_analysis/pagerank_alg.pyi | 2 +- .../networkx/networkx/algorithms/matching.pyi | 18 ++++-- .../algorithms/minors/contraction.pyi | 7 ++- stubs/networkx/networkx/algorithms/mis.pyi | 2 +- .../networkx/algorithms/operators/binary.pyi | 2 +- .../networkx/algorithms/planar_drawing.pyi | 12 +++- .../networkx/algorithms/planarity.pyi | 8 ++- .../networkx/algorithms/reciprocity.pyi | 3 +- .../networkx/networkx/algorithms/regular.pyi | 4 +- .../networkx/networkx/algorithms/richclub.pyi | 6 +- .../algorithms/shortest_paths/dense.pyi | 9 ++- .../algorithms/shortest_paths/unweighted.pyi | 16 +++-- .../algorithms/shortest_paths/weighted.pyi | 32 +++++----- .../networkx/algorithms/similarity.pyi | 6 +- .../networkx/algorithms/simple_paths.pyi | 4 +- .../networkx/algorithms/smallworld.pyi | 4 +- .../networkx/networkx/algorithms/smetric.pyi | 2 +- .../networkx/algorithms/structuralholes.pyi | 14 ++++- stubs/networkx/networkx/algorithms/swap.pyi | 2 +- .../networkx/algorithms/threshold.pyi | 30 ++++++++- .../networkx/algorithms/tournament.pyi | 19 ++++-- .../traversal/breadth_first_search.pyi | 8 ++- .../traversal/depth_first_search.pyi | 4 +- .../networkx/algorithms/traversal/edgebfs.pyi | 6 +- .../networkx/algorithms/traversal/edgedfs.pyi | 6 +- .../networkx/algorithms/tree/branchings.pyi | 20 ++++-- .../networkx/algorithms/tree/coding.pyi | 8 +-- .../algorithms/tree/decomposition.pyi | 3 +- .../networkx/networkx/algorithms/tree/mst.pyi | 14 ++++- stubs/networkx/networkx/algorithms/triads.pyi | 14 +++-- .../networkx/networkx/algorithms/vitality.pyi | 2 +- .../networkx/networkx/algorithms/voronoi.pyi | 6 +- stubs/networkx/networkx/algorithms/wiener.pyi | 2 +- stubs/networkx/networkx/classes/digraph.pyi | 24 ++++++-- stubs/networkx/networkx/classes/function.pyi | 34 +++++------ stubs/networkx/networkx/classes/graph.pyi | 8 +-- .../networkx/classes/multidigraph.pyi | 8 ++- .../networkx/networkx/classes/multigraph.pyi | 17 +++--- .../networkx/networkx/classes/reportviews.pyi | 1 + stubs/networkx/networkx/convert.pyi | 6 +- stubs/networkx/networkx/convert_matrix.pyi | 4 +- stubs/networkx/networkx/drawing/layout.pyi | 61 +++++++++++++------ stubs/networkx/networkx/drawing/nx_agraph.pyi | 1 + stubs/networkx/networkx/drawing/nx_pydot.pyi | 10 +-- stubs/networkx/networkx/drawing/nx_pylab.pyi | 45 ++++++++------ stubs/networkx/networkx/generators/atlas.pyi | 14 ++++- .../networkx/networkx/generators/classic.pyi | 17 +++--- .../networkx/networkx/generators/cographs.pyi | 2 +- .../networkx/generators/community.pyi | 40 ++++++------ .../networkx/generators/degree_seq.pyi | 22 +++++-- .../networkx/networkx/generators/directed.pyi | 14 +++-- .../networkx/generators/duplication.pyi | 6 +- stubs/networkx/networkx/generators/ego.pyi | 6 +- .../networkx/generators/expanders.pyi | 2 +- .../networkx/generators/geometric.pyi | 40 ++++++------ .../generators/internet_as_graphs.pyi | 10 ++- .../networkx/generators/intersection.pyi | 6 +- .../networkx/generators/joint_degree_seq.pyi | 10 +-- .../networkx/networkx/generators/lattice.pyi | 9 +-- stubs/networkx/networkx/generators/line.pyi | 6 +- .../networkx/generators/mycielski.pyi | 8 ++- .../generators/nonisomorphic_trees.pyi | 4 +- .../networkx/generators/random_graphs.pyi | 38 +++++++----- .../generators/spectral_graph_forge.pyi | 6 +- .../networkx/generators/stochastic.pyi | 6 +- stubs/networkx/networkx/generators/trees.pyi | 6 +- stubs/networkx/networkx/generators/triads.pyi | 7 ++- stubs/networkx/networkx/lazy_imports.pyi | 3 +- .../networkx/linalg/algebraicconnectivity.pyi | 8 ++- stubs/networkx/networkx/linalg/attrmatrix.pyi | 15 +++-- .../networkx/linalg/bethehessianmatrix.pyi | 4 +- .../networkx/networkx/linalg/graphmatrix.pyi | 6 +- .../networkx/linalg/laplacianmatrix.pyi | 13 ++-- .../networkx/linalg/modularitymatrix.pyi | 9 ++- stubs/networkx/networkx/linalg/spectrum.pyi | 12 ++-- stubs/networkx/networkx/readwrite/adjlist.pyi | 10 +-- .../networkx/networkx/readwrite/edgelist.pyi | 24 +++++--- stubs/networkx/networkx/readwrite/gexf.pyi | 23 ++++--- stubs/networkx/networkx/readwrite/gml.pyi | 25 ++++++-- stubs/networkx/networkx/readwrite/graph6.pyi | 12 +++- stubs/networkx/networkx/readwrite/graphml.pyi | 22 ++++--- .../readwrite/json_graph/adjacency.pyi | 14 ++++- .../readwrite/json_graph/cytoscape.pyi | 11 +++- .../readwrite/json_graph/node_link.pyi | 8 ++- .../networkx/readwrite/json_graph/tree.pyi | 9 ++- stubs/networkx/networkx/readwrite/leda.pyi | 4 +- .../networkx/readwrite/multiline_adjlist.pyi | 12 ++-- stubs/networkx/networkx/readwrite/p2g.pyi | 11 +++- stubs/networkx/networkx/readwrite/pajek.pyi | 11 ++-- stubs/networkx/networkx/readwrite/sparse6.pyi | 9 ++- stubs/networkx/networkx/utils/__init__.pyi | 21 +------ stubs/networkx/networkx/utils/decorators.pyi | 20 +++--- stubs/networkx/networkx/utils/heaps.pyi | 20 +++--- stubs/networkx/networkx/utils/misc.pyi | 6 +- .../networkx/utils/random_sequence.pyi | 2 +- stubs/networkx/networkx/utils/rcm.pyi | 8 ++- 184 files changed, 1188 insertions(+), 630 deletions(-) diff --git a/stubs/networkx/networkx/__init__.pyi b/stubs/networkx/networkx/__init__.pyi index 7e5d6b1ec86a..bdd328fb405a 100644 --- a/stubs/networkx/networkx/__init__.pyi +++ b/stubs/networkx/networkx/__init__.pyi @@ -1,3 +1,5 @@ +from typing import Final + from networkx.algorithms import * from networkx.classes import * from networkx.classes import filters as filters @@ -24,3 +26,5 @@ from . import ( relabel as relabel, utils as utils, ) + +__version__: Final[str] diff --git a/stubs/networkx/networkx/algorithms/__init__.pyi b/stubs/networkx/networkx/algorithms/__init__.pyi index 57141f108e16..9a9c70d111c1 100644 --- a/stubs/networkx/networkx/algorithms/__init__.pyi +++ b/stubs/networkx/networkx/algorithms/__init__.pyi @@ -118,6 +118,7 @@ from networkx.algorithms.structuralholes import * from networkx.algorithms.summarization import * from networkx.algorithms.swap import * from networkx.algorithms.time_dependent import * +from networkx.algorithms.tournament import is_tournament as is_tournament from networkx.algorithms.traversal import * from networkx.algorithms.tree.branchings import ( ArborescenceIterator as ArborescenceIterator, diff --git a/stubs/networkx/networkx/algorithms/approximation/clique.pyi b/stubs/networkx/networkx/algorithms/approximation/clique.pyi index 4587354a1c07..b906c7a95bcd 100644 --- a/stubs/networkx/networkx/algorithms/approximation/clique.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/clique.pyi @@ -1,12 +1,14 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["clique_removal", "max_clique", "large_clique_size", "maximum_independent_set"] @_dispatchable -def maximum_independent_set(G: Graph[_Node]): ... +def maximum_independent_set(G: Graph[_Node]) -> set[Incomplete]: ... @_dispatchable -def max_clique(G: Graph[_Node]): ... +def max_clique(G: Graph[_Node]) -> set[Incomplete]: ... @_dispatchable def clique_removal(G: Graph[_Node]): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi b/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi index 4c1a7d55c117..cff53629ceb7 100644 --- a/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi @@ -5,4 +5,4 @@ from numpy.random import RandomState __all__ = ["average_clustering"] @_dispatchable -def average_clustering(G: Graph[_Node], trials: int = 1000, seed: int | RandomState | None = None): ... +def average_clustering(G: Graph[_Node], trials: int = 1000, seed: int | RandomState | None = None) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi b/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi index 7adcdcb978f2..2e1986d6806e 100644 --- a/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi @@ -11,4 +11,6 @@ def local_node_connectivity(G: Graph[_Node], source: _Node, target: _Node, cutof @_dispatchable def node_connectivity(G: Graph[_Node], s: _Node | None = None, t: _Node | None = None): ... @_dispatchable -def all_pairs_node_connectivity(G: Graph[_Node], nbunch: Iterable[Incomplete] | None = None, cutoff: int | None = None): ... +def all_pairs_node_connectivity( + G: Graph[_Node], nbunch: Iterable[Incomplete] | None = None, cutoff: int | None = None +) -> dict[Incomplete, dict[Incomplete, Incomplete]]: ... diff --git a/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi b/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi index a24428f63b8e..e37d3713ce42 100644 --- a/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi @@ -1,9 +1,11 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["min_weighted_dominating_set", "min_edge_dominating_set"] @_dispatchable -def min_weighted_dominating_set(G: Graph[_Node], weight: str | None = None): ... +def min_weighted_dominating_set(G: Graph[_Node], weight: str | None = None) -> set[Incomplete]: ... @_dispatchable -def min_edge_dominating_set(G: Graph[_Node]): ... +def min_edge_dominating_set(G: Graph[_Node]) -> set[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi index b1965791435a..e0fe94385cd5 100644 --- a/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi @@ -1,7 +1,10 @@ +from _typeshed import Incomplete +from collections import defaultdict + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["k_components"] @_dispatchable -def k_components(G: Graph[_Node], min_density: float = 0.95): ... +def k_components(G: Graph[_Node], min_density: float = 0.95) -> defaultdict[Incomplete, list[Incomplete]]: ... diff --git a/stubs/networkx/networkx/algorithms/approximation/matching.pyi b/stubs/networkx/networkx/algorithms/approximation/matching.pyi index 799818b498f2..7b5f723d44d0 100644 --- a/stubs/networkx/networkx/algorithms/approximation/matching.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/matching.pyi @@ -1,7 +1,9 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["min_maximal_matching"] @_dispatchable -def min_maximal_matching(G: Graph[_Node]): ... +def min_maximal_matching(G: Graph[_Node]) -> set[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi b/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi index af1c01f9ec8e..403990cef627 100644 --- a/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -12,5 +13,8 @@ def randomized_partitioning( ): ... @_dispatchable def one_exchange( - G: Graph[_Node], initial_cut: set[Incomplete] | None = None, seed: int | RandomState | None = None, weight: str | None = None + G: Graph[_Node], + initial_cut: Iterable[Incomplete] | 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 7d0b61f6f407..aa3d9048d83e 100644 --- a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi @@ -1,5 +1,6 @@ -from _typeshed import Incomplete -from collections.abc import Callable +from _typeshed import Incomplete, SupportsLenAndGetItem +from collections.abc import Callable, Iterable, Mapping +from typing import Literal, TypeVar from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node @@ -14,9 +15,12 @@ __all__ = [ "simulated_annealing_tsp", "threshold_accepting_tsp", ] +_SupportsLenAndGetItemT = TypeVar("_SupportsLenAndGetItemT", bound=SupportsLenAndGetItem[Incomplete]) +def swap_two_nodes(soln: _SupportsLenAndGetItemT, seed) -> _SupportsLenAndGetItemT: ... +def move_one_node(soln: _SupportsLenAndGetItemT, seed) -> _SupportsLenAndGetItemT: ... @_dispatchable -def christofides(G: Graph[_Node], weight: str | None = "weight", tree: Graph[_Node] | None = None): ... +def christofides(G: Graph[_Node], weight: str | None = "weight", tree: Graph[_Node] | None = None) -> list[Incomplete]: ... @_dispatchable def traveling_salesman_problem( G: Graph[_Node], @@ -25,12 +29,16 @@ def traveling_salesman_problem( cycle: bool = True, method: Callable[..., Incomplete] | None = None, **kwargs, -): ... +) -> list[Incomplete]: ... @_dispatchable def asadpour_atsp( G: DiGraph[_Node], weight: str | None = "weight", seed: int | RandomState | None = None, source: str | None = None ): ... @_dispatchable +def held_karp_ascent(G: Graph, weight="weight"): ... +@_dispatchable +def spanning_tree_distribution(G: Graph, z: Mapping[Incomplete, Incomplete]) -> dict[Incomplete, Incomplete]: ... +@_dispatchable def greedy_tsp(G: Graph[_Node], weight: str | None = "weight", source=None): ... @_dispatchable def simulated_annealing_tsp( @@ -48,7 +56,7 @@ def simulated_annealing_tsp( @_dispatchable def threshold_accepting_tsp( G: Graph[_Node], - init_cycle, + init_cycle: Literal["greedy"] | Iterable[Incomplete], weight: str | None = "weight", source=None, threshold: int | None = 1, diff --git a/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi index 0b970f4c5cc1..ad1df7938631 100644 --- a/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi @@ -15,3 +15,6 @@ class MinDegreeHeuristic: def __init__(self, graph) -> None: ... def best_node(self, graph): ... + +def min_fill_in_heuristic(graph) -> Incomplete | None: ... +def treewidth_decomp(G: Graph[Incomplete], heuristic=...) -> tuple[int, Graph[Incomplete]]: ... diff --git a/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi b/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi index ffd5206df85d..abec263a7bd0 100644 --- a/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi @@ -1,7 +1,9 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["min_weighted_vertex_cover"] @_dispatchable -def min_weighted_vertex_cover(G: Graph[_Node], weight: str | None = None): ... +def min_weighted_vertex_cover(G: Graph[_Node], weight: str | None = None) -> set[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi b/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi index a4782a825d00..349d6cff8a3c 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete from collections.abc import Iterable +from typing import Literal from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -8,5 +9,9 @@ __all__ = ["average_degree_connectivity"] @_dispatchable def average_degree_connectivity( - G: Graph[_Node], source="in+out", target="in+out", nodes: Iterable[Incomplete] | None = None, weight: str | None = None -): ... + G: Graph[_Node], + source: Literal["in+out", "out", "in"] = "in+out", + target: Literal["in+out", "out", "in"] = "in+out", + nodes: Iterable[Incomplete] | None = None, + weight: str | None = None, +) -> dict[Incomplete, int | float]: ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi index 2789386434d7..7029272e0899 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi @@ -14,12 +14,13 @@ __all__ = [ @_dispatchable def degree_assortativity_coefficient( G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable[Incomplete] | None = None -): ... +) -> float: ... @_dispatchable def degree_pearson_correlation_coefficient( G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable[Incomplete] | None = None -): ... +) -> float: ... @_dispatchable -def attribute_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None): ... +def attribute_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None) -> float: ... @_dispatchable -def numeric_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None): ... +def numeric_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None) -> float: ... +def attribute_ac(M) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi index 4c5ced294890..84168115f9db 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi @@ -9,7 +9,7 @@ __all__ = ["attribute_mixing_matrix", "attribute_mixing_dict", "degree_mixing_ma @_dispatchable def attribute_mixing_dict( G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None, normalized: bool = False -): ... +) -> dict[Incomplete, Incomplete]: ... @_dispatchable def attribute_mixing_matrix( G: Graph[_Node], @@ -21,7 +21,7 @@ def attribute_mixing_matrix( @_dispatchable def degree_mixing_dict( G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes=None, normalized: bool = False -): ... +) -> dict[Incomplete, Incomplete]: ... @_dispatchable def degree_mixing_matrix( G: Graph[_Node], @@ -33,4 +33,4 @@ def degree_mixing_matrix( mapping: SupportsGetItem[Incomplete, Incomplete] | None = None, ): ... @_dispatchable -def mixing_dict(xy, normalized: bool = False): ... +def mixing_dict(xy, normalized: bool = False) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi b/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi index d86ce3da8211..231c1966d0eb 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi @@ -13,4 +13,4 @@ def average_neighbor_degree( target: str | None = "out", nodes: Iterable[Incomplete] | None = None, weight: str | None = None, -): ... +) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/asteroidal.pyi b/stubs/networkx/networkx/algorithms/asteroidal.pyi index eaa859a3bc22..2caee5d7b3e0 100644 --- a/stubs/networkx/networkx/algorithms/asteroidal.pyi +++ b/stubs/networkx/networkx/algorithms/asteroidal.pyi @@ -1,9 +1,13 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["is_at_free", "find_asteroidal_triple"] @_dispatchable -def find_asteroidal_triple(G: Graph[_Node]): ... +def find_asteroidal_triple(G: Graph[_Node]) -> list[Incomplete] | None: ... +@_dispatchable +def is_at_free(G: Graph[_Node]) -> bool: ... @_dispatchable -def is_at_free(G: Graph[_Node]): ... +def create_component_structure(G: Graph[Incomplete]) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/basic.pyi b/stubs/networkx/networkx/algorithms/bipartite/basic.pyi index 280d44b12d91..cfc789bc9de7 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/basic.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/basic.pyi @@ -7,14 +7,14 @@ from networkx.utils.backends import _dispatchable __all__ = ["is_bipartite", "is_bipartite_node_set", "color", "sets", "density", "degrees"] @_dispatchable -def color(G: Graph[_Node]): ... +def color(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ... @_dispatchable def is_bipartite(G: Graph[_Node]): ... @_dispatchable def is_bipartite_node_set(G: Graph[_Node], nodes): ... @_dispatchable -def sets(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None): ... +def sets(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None) -> tuple[set[Incomplete], set[Incomplete]]: ... @_dispatchable -def density(B: Graph[_Node], nodes): ... +def density(B: Graph[_Node], nodes) -> float: ... @_dispatchable -def degrees(B: Graph[_Node], nodes, weight: str | None = None): ... +def degrees(B: Graph[_Node], nodes, weight: str | None = None) -> tuple[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi b/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi index 976948059f2b..529287ee87d7 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi @@ -1,11 +1,13 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["degree_centrality", "betweenness_centrality", "closeness_centrality"] @_dispatchable -def degree_centrality(G: Graph[_Node], nodes): ... +def degree_centrality(G: Graph[_Node], nodes) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def betweenness_centrality(G: Graph[_Node], nodes): ... +def betweenness_centrality(G: Graph[_Node], nodes) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def closeness_centrality(G: Graph[_Node], nodes, normalized: bool | None = True): ... +def closeness_centrality(G: Graph[_Node], nodes, normalized: bool | None = True) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi b/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi index d4fffe4ed70a..1a341ef85e92 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi @@ -1,17 +1,25 @@ from _typeshed import Incomplete -from collections.abc import Iterable +from collections.abc import Callable, Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["clustering", "average_clustering", "latapy_clustering", "robins_alexander_clustering"] +def cc_dot(nu, nv) -> float: ... +def cc_max(nu, nv) -> float: ... +def cc_min(nu, nv) -> float: ... + +modes: dict[str, Callable[[Incomplete, Incomplete], float]] + @_dispatchable -def latapy_clustering(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, mode: str = "dot"): ... +def latapy_clustering( + G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, mode: str = "dot" +) -> dict[Incomplete, Incomplete]: ... clustering = latapy_clustering @_dispatchable -def average_clustering(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, mode: str = "dot"): ... +def average_clustering(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, mode: str = "dot") -> float: ... @_dispatchable -def robins_alexander_clustering(G: Graph[_Node]): ... +def robins_alexander_clustering(G: Graph[_Node]) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/covering.pyi b/stubs/networkx/networkx/algorithms/bipartite/covering.pyi index c915c19c00f0..ab33bcecf487 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/covering.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/covering.pyi @@ -7,4 +7,4 @@ from networkx.utils.backends import _dispatchable __all__ = ["min_edge_cover"] @_dispatchable -def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable[..., Incomplete] | None = None): ... +def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable[..., Incomplete] | None = None) -> set[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi b/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi index 18fb7d40473f..cb64aaa3f1ce 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi @@ -1,5 +1,5 @@ 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 @@ -7,9 +7,18 @@ from networkx.utils.backends import _dispatchable __all__ = ["generate_edgelist", "write_edgelist", "parse_edgelist", "read_edgelist"] @_dispatchable -def write_edgelist(G, path, comments: str = "#", delimiter: str = " ", data: bool = True, encoding: str = "utf-8") -> None: ... +def write_edgelist( + G: Graph[Incomplete], + path, + comments: str = "#", + delimiter: str = " ", + data: bool | Iterable[Incomplete] = True, + encoding: str = "utf-8", +) -> None: ... @_dispatchable -def generate_edgelist(G, delimiter: str = " ", data: bool = True) -> Generator[Incomplete, None, None]: ... +def generate_edgelist( + G: Graph[Incomplete], delimiter: str = " ", data: bool | Iterable[Incomplete] = True +) -> Generator[str, None, None]: ... @_dispatchable def parse_edgelist( lines, @@ -17,7 +26,7 @@ def parse_edgelist( delimiter: str | None = None, create_using: Graph[_Node] | None = None, nodetype=None, - data=True, + data: bool | Iterable[Incomplete] = True, ): ... @_dispatchable def read_edgelist( @@ -26,7 +35,7 @@ def read_edgelist( delimiter: str | None = None, create_using=None, nodetype=None, - data=True, + data: bool | Iterable[Incomplete] = True, edgetype=None, encoding: str | None = "utf-8", ): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/generators.pyi b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi index f9aef242b895..491ad84d51b0 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/generators.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Iterable +from collections.abc import Collection from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -20,24 +20,24 @@ __all__ = [ def complete_bipartite_graph(n1, n2, create_using: Graph[_Node] | None = None): ... @_dispatchable def configuration_model( - aseq: Iterable[Incomplete], - bseq: Iterable[Incomplete], + aseq: Collection[Incomplete], + bseq: Collection[Incomplete], create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None, ): ... @_dispatchable -def havel_hakimi_graph(aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | None = None): ... +def havel_hakimi_graph(aseq: Collection[Incomplete], bseq: Collection[Incomplete], create_using: Graph[_Node] | None = None): ... @_dispatchable def reverse_havel_hakimi_graph( - aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | None = None + aseq: Collection[Incomplete], bseq: Collection[Incomplete], create_using: Graph[_Node] | None = None ): ... @_dispatchable def alternating_havel_hakimi_graph( - aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | None = None + aseq: Collection[Incomplete], bseq: Collection[Incomplete], create_using: Graph[_Node] | None = None ): ... @_dispatchable def preferential_attachment_graph( - aseq: Iterable[Incomplete], p: float, create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None + aseq: Collection[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 91ef136107e4..d8c79210f491 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi @@ -1,4 +1,4 @@ -from _typeshed import Incomplete, SupportsGetItem +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -7,17 +7,15 @@ from networkx.utils.backends import _dispatchable __all__ = ["maximum_matching", "hopcroft_karp_matching", "eppstein_matching", "to_vertex_cover", "minimum_weight_full_matching"] @_dispatchable -def hopcroft_karp_matching(G: Graph[_Node], top_nodes: Iterable[_Node] | None = None): ... +def hopcroft_karp_matching(G: Graph[_Node], top_nodes: Iterable[_Node] | None = None) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def eppstein_matching(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None): ... +def eppstein_matching(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def to_vertex_cover( - G: Graph[_Node], matching: SupportsGetItem[Incomplete, Incomplete], top_nodes: Iterable[Incomplete] | None = None -): ... +def to_vertex_cover(G: Graph[_Node], matching: Iterable[Incomplete], top_nodes: Iterable[Incomplete] | None = None): ... maximum_matching = hopcroft_karp_matching @_dispatchable def minimum_weight_full_matching( G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None, weight: str | None = "weight" -): ... +) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi index 2e484482aa8d..27914b309b3d 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete -from collections.abc import Iterable +from collections.abc import Collection +from typing import Any from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -9,11 +10,11 @@ __all__ = ["biadjacency_matrix", "from_biadjacency_matrix"] @_dispatchable def biadjacency_matrix( G: Graph[_Node], - row_order: Iterable[_Node], - column_order: Iterable[Incomplete] | None = None, + row_order: Collection[_Node], + column_order: Collection[Incomplete] | None = None, dtype=None, weight: str | None = "weight", format="csr", -): ... +) -> Any: ... # Return is a complex union of scipy classes @_dispatchable 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 9f1fd27d3880..c3dabf1bfb90 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/projection.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/projection.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Callable, Iterable +from collections.abc import Callable, Collection, Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -15,7 +15,7 @@ __all__ = [ @_dispatchable def projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], multigraph: bool = False): ... @_dispatchable -def weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], ratio: bool = False): ... +def weighted_projected_graph(B: Graph[_Node], nodes: Collection[Incomplete], ratio: bool = False): ... @_dispatchable def collaboration_weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete]): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi b/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi index cb7233ef90ab..539e8012ad11 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi @@ -7,4 +7,4 @@ from networkx.utils.backends import _dispatchable __all__ = ["node_redundancy"] @_dispatchable -def node_redundancy(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None): ... +def node_redundancy(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None) -> dict[Incomplete, float]: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi b/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi index 1778bd31cf5a..462e8fef2d73 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi @@ -1,7 +1,9 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["spectral_bipartivity"] @_dispatchable -def spectral_bipartivity(G: Graph[_Node], nodes=None, weight: str = "weight"): ... +def spectral_bipartivity(G: Graph[_Node], nodes=None, weight: str = "weight") -> float | dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/boundary.pyi b/stubs/networkx/networkx/algorithms/boundary.pyi index 08fb9203269f..a6c58a1b2cbf 100644 --- a/stubs/networkx/networkx/algorithms/boundary.pyi +++ b/stubs/networkx/networkx/algorithms/boundary.pyi @@ -13,7 +13,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default: Incomplete | None = None, ) -> Generator[tuple[_Node, _Node], None, None]: ... @@ -22,7 +22,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default: Incomplete | None = None, ) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ... @@ -31,7 +31,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default: Incomplete | None = None, ) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ... @@ -40,7 +40,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default: _U | None = None, ) -> Generator[tuple[_Node, _Node, dict[str, _U]], None, None]: ... @@ -49,7 +49,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default: _U | None = None, ) -> Generator[tuple[_Node, _Node, dict[str, _U]], None, None]: ... @@ -58,7 +58,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default: Incomplete | None = None, ) -> Generator[tuple[_Node, _Node, int], None, None]: ... @@ -67,7 +67,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default: Incomplete | None = None, ) -> Generator[tuple[_Node, _Node, int], None, None]: ... @@ -76,7 +76,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default: Incomplete | None = None, ) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ... @@ -85,7 +85,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default: Incomplete | None = None, ) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ... @@ -94,7 +94,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default: _U | None = None, ) -> Generator[tuple[_Node, _Node, int, dict[str, _U]], None, None]: ... @@ -103,7 +103,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default: _U | None = None, ) -> Generator[tuple[_Node, _Node, int, dict[str, _U]], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi index 72201138a975..cf390e6a0c77 100644 --- a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi @@ -1,4 +1,5 @@ -from _typeshed import Incomplete, SupportsGetItem +from _typeshed import Incomplete +from collections.abc import Mapping from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -13,7 +14,7 @@ def closeness_centrality( def incremental_closeness_centrality( G: Graph[_Node], edge: tuple[Incomplete], - prev_cc: SupportsGetItem[Incomplete, Incomplete] | None = None, + prev_cc: Mapping[Incomplete, Incomplete] | None = 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 7d39f64677cf..c22f749306eb 100644 --- a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState @@ -18,12 +20,12 @@ def approximate_current_flow_betweenness_centrality( epsilon: float = 0.5, kmax: int = 10000, seed: int | RandomState | None = None, -): ... +) -> dict[Incomplete, float]: ... @_dispatchable def current_flow_betweenness_centrality( G: Graph[_Node], normalized: bool | None = True, weight: str | None = None, dtype: type = ..., solver: str = "full" -): ... +) -> dict[Incomplete, Incomplete]: ... @_dispatchable def edge_current_flow_betweenness_centrality( G: Graph[_Node], normalized: bool | None = True, weight: str | None = None, dtype: type = ..., solver: str = "full" -): ... +) -> dict[tuple[Incomplete, Incomplete], float]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi index 9fe21cad877d..b7f38a4c9b31 100644 --- a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -14,7 +15,7 @@ def current_flow_betweenness_centrality_subset( weight: str | None = None, dtype: type = ..., solver: str = "lu", -): ... +) -> dict[Incomplete, float]: ... @_dispatchable def edge_current_flow_betweenness_centrality_subset( G: Graph[_Node], @@ -24,4 +25,4 @@ def edge_current_flow_betweenness_centrality_subset( weight: str | None = None, dtype: type = ..., solver: str = "lu", -): ... +) -> dict[tuple[Incomplete, Incomplete], float]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi b/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi index 00ff9c43f1b1..d7b95eeea326 100644 --- a/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi @@ -1,9 +1,13 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["current_flow_closeness_centrality", "information_centrality"] @_dispatchable -def current_flow_closeness_centrality(G: Graph[_Node], weight: str | None = None, dtype: type = ..., solver: str = "lu"): ... +def current_flow_closeness_centrality( + G: Graph[_Node], weight: str | None = None, dtype: type = ..., solver: str = "lu" +) -> dict[Incomplete, float]: ... information_centrality = current_flow_closeness_centrality diff --git a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi index 5e1af9216cf8..75ee56abc272 100644 --- a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi @@ -1,4 +1,5 @@ -from _typeshed import Incomplete, SupportsGetItem +from _typeshed import Incomplete +from collections.abc import Mapping from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -10,10 +11,10 @@ def eigenvector_centrality( G: Graph[_Node], max_iter: int | None = 100, tol: float | None = 1e-06, - nstart: SupportsGetItem[Incomplete, Incomplete] | None = None, + nstart: Mapping[Incomplete, Incomplete] | None = None, weight: str | None = None, -): ... +) -> dict[Incomplete, float]: ... @_dispatchable def eigenvector_centrality_numpy( G: Graph[_Node], weight: str | None = None, max_iter: int | None = 50, tol: float | None = 0 -): ... +) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/group.pyi b/stubs/networkx/networkx/algorithms/centrality/group.pyi index 0efcdbbe4dcf..1e0c00b226c5 100644 --- a/stubs/networkx/networkx/algorithms/centrality/group.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/group.pyi @@ -26,12 +26,12 @@ def prominent_group( endpoints: bool | None = False, normalized: bool | None = True, greedy: bool | None = False, -): ... +) -> tuple[float, list[Incomplete]]: ... @_dispatchable -def group_closeness_centrality(G: Graph[_Node], S: Iterable[Incomplete], weight: str | None = None): ... +def group_closeness_centrality(G: Graph[_Node], S: Iterable[Incomplete], weight: str | None = None) -> float: ... @_dispatchable -def group_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]): ... +def group_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]) -> float: ... @_dispatchable -def group_in_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]): ... +def group_in_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]) -> float: ... @_dispatchable -def group_out_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]): ... +def group_out_degree_centrality(G: Graph[_Node], S: Iterable[Incomplete]) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi b/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi index 7b75d7ee75ee..4b00562653f8 100644 --- a/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi @@ -9,4 +9,4 @@ __all__ = ["harmonic_centrality"] @_dispatchable def harmonic_centrality( G: Graph[_Node], nbunch: Iterable[Incomplete] | None = None, distance=None, sources: Iterable[Incomplete] | None = None -): ... +) -> dict[Incomplete, int]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/katz.pyi b/stubs/networkx/networkx/algorithms/centrality/katz.pyi index 6f0f4f3bae8b..c932be84faba 100644 --- a/stubs/networkx/networkx/algorithms/centrality/katz.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/katz.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete, SupportsGetItem +from collections.abc import Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -12,10 +13,10 @@ def katz_centrality( beta: float | SupportsGetItem[Incomplete, Incomplete] | None = 1.0, max_iter: int | None = 1000, tol: float | None = 1e-06, - nstart: SupportsGetItem[Incomplete, Incomplete] | None = None, + nstart: Iterable[Incomplete] | None = None, normalized: bool | None = True, weight: str | None = None, -): ... +) -> dict[Incomplete, Incomplete]: ... @_dispatchable def katz_centrality_numpy( G: Graph[_Node], @@ -23,4 +24,4 @@ def katz_centrality_numpy( beta: float | SupportsGetItem[Incomplete, Incomplete] | None = 1.0, normalized: bool = True, weight: str | None = None, -): ... +) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/load.pyi b/stubs/networkx/networkx/algorithms/centrality/load.pyi index cdec3b843e77..d59db805b08f 100644 --- a/stubs/networkx/networkx/algorithms/centrality/load.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/load.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -6,7 +8,7 @@ __all__ = ["load_centrality", "edge_load_centrality"] @_dispatchable def newman_betweenness_centrality( G: Graph[_Node], v=None, cutoff: bool | None = None, normalized: bool | None = True, weight: str | None = None -): ... +) -> float | dict[Incomplete, float]: ... load_centrality = newman_betweenness_centrality diff --git a/stubs/networkx/networkx/algorithms/centrality/percolation.pyi b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi index f6bee5c6bd05..becea462a050 100644 --- a/stubs/networkx/networkx/algorithms/centrality/percolation.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi @@ -1,4 +1,5 @@ -from _typeshed import Incomplete, SupportsGetItem +from _typeshed import Incomplete +from collections.abc import Mapping from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -9,6 +10,6 @@ __all__ = ["percolation_centrality"] def percolation_centrality( G: Graph[_Node], attribute: str | None = "percolation", - states: SupportsGetItem[Incomplete, Incomplete] | None = None, + states: Mapping[Incomplete, Incomplete] | None = None, weight: str | None = None, -): ... +) -> dict[Incomplete, float]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/reaching.pyi b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi index f99040b4f6ef..d5a6e1479aca 100644 --- a/stubs/networkx/networkx/algorithms/centrality/reaching.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi @@ -7,7 +7,7 @@ from networkx.utils.backends import _dispatchable __all__ = ["global_reaching_centrality", "local_reaching_centrality"] @_dispatchable -def global_reaching_centrality(G: DiGraph[_Node], weight: str | None = None, normalized: bool | None = True): ... +def global_reaching_centrality(G: DiGraph[_Node], weight: str | None = None, normalized: bool | None = True) -> float: ... @_dispatchable def local_reaching_centrality( G: DiGraph[_Node], @@ -15,4 +15,4 @@ def local_reaching_centrality( paths: SupportsGetItem[Incomplete, Incomplete] | None = None, weight: str | None = None, normalized: bool | None = True, -): ... +) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/second_order.pyi b/stubs/networkx/networkx/algorithms/centrality/second_order.pyi index cda7cac85c00..d6f64bcd4bda 100644 --- a/stubs/networkx/networkx/algorithms/centrality/second_order.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/second_order.pyi @@ -1,7 +1,9 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["second_order_centrality"] @_dispatchable -def second_order_centrality(G: Graph[_Node], weight: str | None = "weight"): ... +def second_order_centrality(G: Graph[_Node], weight: str | None = "weight") -> dict[Incomplete, float]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi b/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi index 94075f2541b7..21671ced7d77 100644 --- a/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi @@ -1,13 +1,15 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["subgraph_centrality_exp", "subgraph_centrality", "communicability_betweenness_centrality", "estrada_index"] @_dispatchable -def subgraph_centrality_exp(G: Graph[_Node]): ... +def subgraph_centrality_exp(G: Graph[_Node]) -> dict[Incomplete, float]: ... @_dispatchable -def subgraph_centrality(G: Graph[_Node]): ... +def subgraph_centrality(G: Graph[_Node]) -> dict[Incomplete, float]: ... @_dispatchable -def communicability_betweenness_centrality(G: Graph[_Node]): ... +def communicability_betweenness_centrality(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def estrada_index(G: Graph[_Node]): ... +def estrada_index(G: Graph[_Node]) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/trophic.pyi b/stubs/networkx/networkx/algorithms/centrality/trophic.pyi index f0ae0a5b53f1..50ed79871702 100644 --- a/stubs/networkx/networkx/algorithms/centrality/trophic.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/trophic.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from networkx.classes.digraph import DiGraph from networkx.classes.graph import _Node from networkx.utils.backends import _dispatchable @@ -5,8 +6,8 @@ from networkx.utils.backends import _dispatchable __all__ = ["trophic_levels", "trophic_differences", "trophic_incoherence_parameter"] @_dispatchable -def trophic_levels(G: DiGraph[_Node], weight="weight"): ... +def trophic_levels(G: DiGraph[_Node], weight="weight")->dict[Incomplete, Incomplete]: ... @_dispatchable -def trophic_differences(G: DiGraph[_Node], weight="weight"): ... +def trophic_differences(G: DiGraph[_Node], weight="weight")->dict[Incomplete, Incomplete]: ... @_dispatchable -def trophic_incoherence_parameter(G: DiGraph[_Node], weight="weight", cannibalism: bool = False): ... +def trophic_incoherence_parameter(G: DiGraph[_Node], weight="weight", cannibalism: bool = False)-float: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi b/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi index bf5969f63ea0..4dc2bb55728d 100644 --- a/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi @@ -1,7 +1,9 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["voterank"] @_dispatchable -def voterank(G: Graph[_Node], number_of_nodes: int | None = None): ... +def voterank(G: Graph[_Node], number_of_nodes: int | None = None) -> list[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/chordal.pyi b/stubs/networkx/networkx/algorithms/chordal.pyi index 628df41c19a8..44aa7b935657 100644 --- a/stubs/networkx/networkx/algorithms/chordal.pyi +++ b/stubs/networkx/networkx/algorithms/chordal.pyi @@ -26,4 +26,4 @@ def chordal_graph_cliques(G: Graph[_Node]) -> Generator[frozenset[_Node], None, @_dispatchable def chordal_graph_treewidth(G: Graph[_Node]) -> int: ... @_dispatchable -def complete_to_chordal_graph(G) -> tuple[Incomplete, dict[Incomplete, int]]: ... +def complete_to_chordal_graph(G: Graph[Incomplete]) -> tuple[Incomplete, dict[Incomplete, int]]: ... diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi index 3fa315dcb846..2cea326e119d 100644 --- a/stubs/networkx/networkx/algorithms/clique.pyi +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -30,10 +30,24 @@ def make_clique_bipartite( ) -> Graph[_Node]: ... @overload def node_clique_number( - G: Graph[_Node], nodes=None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False + G: Graph[_Node], nodes: Iterable[_Node] | None = None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False ) -> dict[_Node, int]: ... @overload -def node_clique_number(G: Graph[_Node], nodes=None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False) -> int: ... -def number_of_cliques(G, nodes=None, cliques=None) -> int | dict[Incomplete, Incomplete]: ... +def node_clique_number( + G: Graph[_Node], nodes: _Node = None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False +) -> int: ... +def number_of_cliques(G: Graph[Incomplete], nodes=None, cliques=None) -> int | dict[Incomplete, Incomplete]: ... @_dispatchable -def max_weight_clique(G, weight="weight") -> tuple[Incomplete, Incomplete]: ... +def max_weight_clique(G: Graph[Incomplete], weight="weight") -> tuple[list[Incomplete], int]: ... + +class MaxWeightClique: + G: Graph[_Node] + incumbent_nodes: list[Incomplete] + incumbent_weight: int + node_weights: dict[Incomplete, int] + def __init__(self, G: Graph, weight): ... + def update_incumbent_if_improved(self, C, C_weight): ... + def greedily_find_independent_set(self, P): ... + def find_branching_nodes(self, P, target): ... + def expand(self, C, C_weight, P): ... + def find_max_weight_clique(self): ... diff --git a/stubs/networkx/networkx/algorithms/cluster.pyi b/stubs/networkx/networkx/algorithms/cluster.pyi index dfa594aca74b..15a497ec870d 100644 --- a/stubs/networkx/networkx/algorithms/cluster.pyi +++ b/stubs/networkx/networkx/algorithms/cluster.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -6,16 +7,16 @@ from networkx.utils.backends import _dispatchable __all__ = ["triangles", "average_clustering", "clustering", "transitivity", "square_clustering", "generalized_degree"] @_dispatchable -def triangles(G: Graph[_Node], nodes=None): ... +def triangles(G: Graph[_Node], nodes=None) -> int | dict[Incomplete, int]: ... @_dispatchable def average_clustering( G: Graph[_Node], nodes: Iterable[_Node] | None = None, weight: str | None = None, count_zeros: bool = True -): ... +) -> float: ... @_dispatchable -def clustering(G: Graph[_Node], nodes=None, weight: str | None = None): ... +def clustering(G: Graph[_Node], nodes=None, weight: str | None = None) -> float | int | dict[Incomplete, float | int]: ... @_dispatchable -def transitivity(G: Graph[_Node]): ... +def transitivity(G: Graph[_Node]) -> float: ... @_dispatchable -def square_clustering(G: Graph[_Node], nodes: Iterable[_Node] | None = None): ... +def square_clustering(G: Graph[_Node], nodes: Iterable[_Node] | None = None) -> float | int | dict[Incomplete, float | int]: ... @_dispatchable def generalized_degree(G: Graph[_Node], nodes: Iterable[_Node] | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi b/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi index 1e768dd502b5..7e584f1fe140 100644 --- a/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi +++ b/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi @@ -3,5 +3,17 @@ from networkx.utils.backends import _dispatchable __all__ = ["equitable_color"] +@_dispatchable +def is_coloring(G: Graph, coloring): ... +@_dispatchable +def is_equitable(G: Graph, coloring, num_colors=None): ... +def make_C_from_F(F): ... +def make_N_from_L_C(L, C): ... +def make_H_from_C_N(C, N): ... +def change_color(u, X, Y, N, H, F, C, L): ... +def move_witnesses(src_color, dst_color, N, H, F, C, T_cal, L): ... +@_dispatchable +def pad_graph(G: Graph, num_colors): ... +def procedure_P(V_minus, V_plus, N, H, F, C, L, excluded_colors=None): ... @_dispatchable 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 0ce06b531e84..95d68ca34d7d 100644 --- a/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi +++ b/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi @@ -1,5 +1,5 @@ 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 @@ -17,20 +17,23 @@ __all__ = [ ] @_dispatchable -def strategy_largest_first(G, colors): ... +def strategy_largest_first(G: Graph[Incomplete], colors): ... @_dispatchable -def strategy_random_sequential(G, colors, seed: Incomplete | None = None): ... +def strategy_random_sequential(G: Graph[Incomplete], colors, seed: Incomplete | None = None): ... @_dispatchable -def strategy_smallest_last(G, colors): ... +def strategy_smallest_last(G: Graph[Incomplete], colors): ... @_dispatchable -def strategy_independent_set(G, colors) -> Generator[Incomplete, Incomplete, None]: ... +def strategy_independent_set(G: Graph[Incomplete], colors) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable -def strategy_connected_sequential_bfs(G, colors): ... +def strategy_connected_sequential_bfs(G: Graph[Incomplete], colors): ... @_dispatchable -def strategy_connected_sequential_dfs(G, colors): ... +def strategy_connected_sequential_dfs(G: Graph[Incomplete], colors): ... @_dispatchable -def strategy_connected_sequential(G, colors, traversal: str = "bfs") -> Generator[Incomplete, None, None]: ... +def strategy_connected_sequential(G: Graph[Incomplete], colors, traversal: str = "bfs") -> Generator[Incomplete, None, None]: ... @_dispatchable -def strategy_saturation_largest_first(G, colors) -> Generator[Incomplete, None, Incomplete]: ... +def strategy_saturation_largest_first(G: Graph[Incomplete], colors) -> Generator[Incomplete, None, Incomplete]: ... + +STRATEGIES: dict[str, Callable[..., Incomplete]] + @_dispatchable 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 4cbbc0adb2e4..93ab59130d37 100644 --- a/stubs/networkx/networkx/algorithms/communicability_alg.pyi +++ b/stubs/networkx/networkx/algorithms/communicability_alg.pyi @@ -1,9 +1,11 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["communicability", "communicability_exp"] @_dispatchable -def communicability(G: Graph[_Node]): ... +def communicability(G: Graph[_Node]) -> dict[dict[Incomplete, Incomplete], dict[Incomplete, float]]: ... @_dispatchable -def communicability_exp(G: Graph[_Node]): ... +def communicability_exp(G: Graph[_Node]) -> dict[dict[Incomplete, Incomplete], dict[Incomplete, float]]: ... diff --git a/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi b/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi index 5729204d3b82..2b3d11cc5a51 100644 --- a/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi +++ b/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi @@ -1,3 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Iterator + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState @@ -5,4 +8,4 @@ from numpy.random import RandomState __all__ = ["asyn_fluidc"] @_dispatchable -def asyn_fluidc(G: Graph[_Node], k: int, max_iter: int = 100, seed: int | RandomState | None = None): ... +def asyn_fluidc(G: Graph[_Node], k: int, max_iter: int = 100, seed: int | RandomState | None = None) -> Iterator[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi b/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi index 00133f83134e..055bdfe89aab 100644 --- a/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi +++ b/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi @@ -9,7 +9,7 @@ __all__ = ["kernighan_lin_bisection"] @_dispatchable def kernighan_lin_bisection( G: Graph[_Node], - partition: tuple[Incomplete] | None = None, + partition: tuple[Incomplete, Incomplete] | 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 23840b8cbde7..e7aa55f2ebb0 100644 --- a/stubs/networkx/networkx/algorithms/community/label_propagation.pyi +++ b/stubs/networkx/networkx/algorithms/community/label_propagation.pyi @@ -14,4 +14,4 @@ def asyn_lpa_communities( G: Graph[_Node], weight: str | None = None, seed: int | RandomState | None = None ) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable -def label_propagation_communities(G: Graph[_Node]): ... +def label_propagation_communities(G: Graph[_Node]) -> dict_values[Any, set[Any]]: ... diff --git a/stubs/networkx/networkx/algorithms/community/louvain.pyi b/stubs/networkx/networkx/algorithms/community/louvain.pyi index 40cf510a5845..103d4bf6e7d8 100644 --- a/stubs/networkx/networkx/algorithms/community/louvain.pyi +++ b/stubs/networkx/networkx/algorithms/community/louvain.pyi @@ -15,7 +15,7 @@ def louvain_communities( threshold: float | None = 1e-07, max_level: int | None = None, seed: int | RandomState | None = None, -): ... +) -> list[set[Incomplete]]: ... @_dispatchable def louvain_partitions( G: Graph[_Node], @@ -23,4 +23,4 @@ def louvain_partitions( resolution: float | None = 1, threshold: float | None = 1e-07, seed: int | RandomState | None = None, -) -> Generator[Incomplete, None, None]: ... +) -> Generator[list[set[Incomplete]], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/community/lukes.pyi b/stubs/networkx/networkx/algorithms/community/lukes.pyi index 766f478a0336..9c6abd37328d 100644 --- a/stubs/networkx/networkx/algorithms/community/lukes.pyi +++ b/stubs/networkx/networkx/algorithms/community/lukes.pyi @@ -1,7 +1,16 @@ +from typing import Final + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["lukes_partitioning"] +D_EDGE_W: Final = "weight" +D_EDGE_VALUE: Final = 1.0 +D_NODE_W: Final = "weight" +D_NODE_VALUE: Final = 1 +PKEY: Final = "partitions" +CLUSTER_EVAL_CACHE_SIZE: Final = 2048 + @_dispatchable 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 5cfedb7d5271..f737490748a6 100644 --- a/stubs/networkx/networkx/algorithms/community/modularity_max.pyi +++ b/stubs/networkx/networkx/algorithms/community/modularity_max.pyi @@ -6,6 +6,6 @@ __all__ = ["greedy_modularity_communities", "naive_greedy_modularity_communities @_dispatchable def greedy_modularity_communities( G: Graph[_Node], weight: str | None = None, resolution: float | None = 1, cutoff: int | None = 1, best_n: int | None = None -): ... +) -> list[set[Any]] | list[frozenset[Any]]: ... @_dispatchable 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 2ce826f6e83e..0e4a3e13f24b 100644 --- a/stubs/networkx/networkx/algorithms/community/quality.pyi +++ b/stubs/networkx/networkx/algorithms/community/quality.pyi @@ -1,12 +1,23 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.exception import NetworkXError from networkx.utils.backends import _dispatchable +from networkx.utils.decorators import argmap __all__ = ["modularity", "partition_quality"] class NotAPartition(NetworkXError): - def __init__(self, G, collection) -> None: ... + def __init__(self, G: Graph[Incomplete], collection) -> None: ... + +require_partition: argmap +@_dispatchable +def intra_community_edges(G: Graph[Incomplete], partition): ... +@_dispatchable +def inter_community_edges(G: Graph[Incomplete], partition): ... +@_dispatchable +def inter_community_non_edges(G: Graph[Incomplete], partition): ... @_dispatchable def modularity(G: Graph[_Node], communities, weight: str | None = "weight", resolution: float = 1): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/components/attracting.pyi b/stubs/networkx/networkx/algorithms/components/attracting.pyi index 88649cf94a16..09b4d5c1d808 100644 --- a/stubs/networkx/networkx/algorithms/components/attracting.pyi +++ b/stubs/networkx/networkx/algorithms/components/attracting.pyi @@ -3,11 +3,13 @@ from collections.abc import Generator from networkx.utils.backends import _dispatchable +from ...classes.digraph import DiGraph + __all__ = ["number_attracting_components", "attracting_components", "is_attracting_component"] @_dispatchable -def attracting_components(G) -> Generator[Incomplete, None, None]: ... +def attracting_components(G: DiGraph) -> Generator[Incomplete, None, None]: ... @_dispatchable -def number_attracting_components(G): ... +def number_attracting_components(G: DiGraph) -> int: ... @_dispatchable -def is_attracting_component(G): ... +def is_attracting_component(G: DiGraph) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/components/connected.pyi b/stubs/networkx/networkx/algorithms/components/connected.pyi index c13a09e93da7..ba7fae6bd169 100644 --- a/stubs/networkx/networkx/algorithms/components/connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/connected.pyi @@ -11,6 +11,6 @@ def connected_components(G: Graph[_Node]) -> Generator[Incomplete, None, None]: @_dispatchable def number_connected_components(G: Graph[_Node]): ... @_dispatchable -def is_connected(G: Graph[_Node]): ... +def is_connected(G: Graph[_Node]) -> bool: ... @_dispatchable -def node_connected_component(G: Graph[_Node], n: _Node): ... +def node_connected_component(G: Graph[_Node], n: _Node) -> set[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/components/semiconnected.pyi b/stubs/networkx/networkx/algorithms/components/semiconnected.pyi index 9a02ac4e7156..17fc43bac7cf 100644 --- a/stubs/networkx/networkx/algorithms/components/semiconnected.pyi +++ b/stubs/networkx/networkx/algorithms/components/semiconnected.pyi @@ -4,4 +4,4 @@ from networkx.utils.backends import _dispatchable __all__ = ["is_semiconnected"] @_dispatchable -def is_semiconnected(G: Graph[_Node]): ... +def is_semiconnected(G: Graph[_Node]) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi index 8060b1e332c0..ca37ffb15d70 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi @@ -31,11 +31,11 @@ def node_connectivity( G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable[..., Incomplete] | None = None ): ... @_dispatchable -def average_node_connectivity(G: Graph[_Node], flow_func: Callable[..., Incomplete] | None = None): ... +def average_node_connectivity(G: Graph[_Node], flow_func: Callable[..., Incomplete] | None = None) -> float: ... @_dispatchable def all_pairs_node_connectivity( G: Graph[_Node], nbunch: Iterable[Incomplete] | None = None, flow_func: Callable[..., Incomplete] | None = None -): ... +) -> dict[Incomplete, dict[Incomplete, Incomplete]]: ... @_dispatchable def local_edge_connectivity( G: Graph[_Node], diff --git a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi index d9c41c57195d..f9dca59cea2e 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete from collections.abc import Callable +from typing import Never from networkx.algorithms.flow import edmonds_karp from networkx.classes.digraph import DiGraph @@ -17,7 +18,7 @@ def minimum_st_edge_cut( flow_func: Callable[..., Incomplete] | None = None, auxiliary: DiGraph[_Node] | None = None, residual: DiGraph[_Node] | None = None, -): ... +) -> set[tuple[Incomplete, Incomplete]]: ... @_dispatchable def minimum_st_node_cut( G: Graph[_Node], @@ -26,12 +27,12 @@ def minimum_st_node_cut( flow_func: Callable[..., Incomplete] | None = None, auxiliary: DiGraph[_Node] | None = None, residual: DiGraph[_Node] | None = None, -): ... +) -> dict[Never, Never] | set[Incomplete]: ... @_dispatchable def minimum_node_cut( G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable[..., Incomplete] | None = None -): ... +) -> dict[Never, Never] | set[Incomplete]: ... @_dispatchable def minimum_edge_cut( G: Graph[_Node], s: _Node | None = None, t: _Node | None = None, flow_func: Callable[..., Incomplete] | None = None -): ... +) -> set[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi index 31ef0154fd5e..a03d5cf55c7e 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -1,5 +1,6 @@ -from _typeshed import SupportsGetItem +from _typeshed import Incomplete, SupportsGetItem from collections.abc import Generator +from typing import NamedTuple from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -7,9 +8,9 @@ from networkx.utils.backends import _dispatchable __all__ = ["k_edge_augmentation", "is_k_edge_connected", "is_locally_k_edge_connected"] @_dispatchable -def is_k_edge_connected(G: Graph[_Node], k: int): ... +def is_k_edge_connected(G: Graph[_Node], k: int) -> bool: ... @_dispatchable -def is_locally_k_edge_connected(G: Graph[_Node], s: _Node, t: _Node, k: int): ... +def is_locally_k_edge_connected(G: Graph[_Node], s: _Node, t: _Node, k: int) -> bool: ... @_dispatchable def k_edge_augmentation( G: Graph[_Node], @@ -18,3 +19,19 @@ def k_edge_augmentation( weight: str | None = None, partial: bool = False, ) -> Generator[tuple[_Node, _Node], None, None]: ... +def partial_k_edge_augmentation(G: Graph[Incomplete], k, avail, weight: str | None = None): ... +def one_edge_augmentation(G: Graph[Incomplete], avail=None, weight: str | None = None, partial: bool = False): ... +def bridge_augmentation(G: Graph[Incomplete], avail=None, weight: str | None = None): ... + +class MetaEdge(NamedTuple): + meta_uv: Incomplete + uv: Incomplete + w: Incomplete + +def unconstrained_one_edge_augmentation(G: Graph[Incomplete]): ... +def weighted_one_edge_augmentation(G: Graph[Incomplete], avail, weight: str | None = None, partial: bool = False): ... +def unconstrained_bridge_augmentation(G: Graph[Incomplete]): ... +def weighted_bridge_augmentation(G: Graph[Incomplete], avail, weight: str | None = None): ... +def collapse(G: Graph[Incomplete], grouped_nodes): ... +def complement_edges(G: Graph[Incomplete]): ... +def greedy_k_edge_augmentation(G: Graph[Incomplete], k, avail=None, weight: str | None = None, seed=None): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi index 938cae6ec11a..21f10db002b6 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi @@ -18,6 +18,9 @@ class EdgeComponentAuxGraph: H: Incomplete @classmethod - def construct(cls, G): ... + def construct(cls, G: Graph[Incomplete]): ... def k_edge_components(self, k: int) -> Generator[Incomplete, Incomplete, None]: ... def k_edge_subgraphs(self, k: int) -> Generator[Incomplete, Incomplete, None]: ... + +@_dispatchable +def general_k_edge_subgraphs(G: Graph[Incomplete], k): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi index 32010e9ed331..6b7c1e1a3b2a 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi @@ -9,4 +9,5 @@ __all__ = ["k_components"] default_flow_func = edmonds_karp @_dispatchable -def k_components(G: Graph[_Node], flow_func: Callable[..., Incomplete] | None = None): ... +def k_components(G: Graph[_Node], flow_func: Callable[..., Incomplete] | None = None) -> dict[Incomplete, Incomplete]: ... +def build_k_number_dict(kcomps) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/utils.pyi b/stubs/networkx/networkx/algorithms/connectivity/utils.pyi index bac3f5d9297d..e18582e4796d 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/utils.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/utils.pyi @@ -1,8 +1,12 @@ +from _typeshed import Incomplete + from networkx.utils.backends import _dispatchable +from ...classes.graph import Graph + __all__ = ["build_auxiliary_node_connectivity", "build_auxiliary_edge_connectivity"] @_dispatchable -def build_auxiliary_node_connectivity(G): ... +def build_auxiliary_node_connectivity(G: Graph[Incomplete]): ... @_dispatchable -def build_auxiliary_edge_connectivity(G): ... +def build_auxiliary_edge_connectivity(G: Graph[Incomplete]): ... diff --git a/stubs/networkx/networkx/algorithms/core.pyi b/stubs/networkx/networkx/algorithms/core.pyi index acd4b9b7a2f0..386a3c65b0cf 100644 --- a/stubs/networkx/networkx/algorithms/core.pyi +++ b/stubs/networkx/networkx/algorithms/core.pyi @@ -6,7 +6,7 @@ from networkx.utils.backends import _dispatchable __all__ = ["core_number", "k_core", "k_shell", "k_crust", "k_corona", "k_truss", "onion_layers"] @_dispatchable -def core_number(G: Graph[_Node]): ... +def core_number(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ... @_dispatchable def k_core(G: Graph[_Node], k: int | None = None, core_number: SupportsGetItem[Incomplete, Incomplete] | None = None): ... @_dispatchable @@ -18,4 +18,4 @@ def k_corona(G: Graph[_Node], k: int, core_number: SupportsGetItem[Incomplete, I @_dispatchable def k_truss(G: Graph[_Node], k: int): ... @_dispatchable -def onion_layers(G: Graph[_Node]): ... +def onion_layers(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/covering.pyi b/stubs/networkx/networkx/algorithms/covering.pyi index 3dd7daadc967..638925c48ea4 100644 --- a/stubs/networkx/networkx/algorithms/covering.pyi +++ b/stubs/networkx/networkx/algorithms/covering.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Callable +from collections.abc import Callable, Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -7,6 +7,6 @@ from networkx.utils.backends import _dispatchable __all__ = ["min_edge_cover", "is_edge_cover"] @_dispatchable -def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable[..., Incomplete] | None = None): ... +def min_edge_cover(G: Graph[_Node], matching_algorithm: Callable[..., Incomplete] | None = None) -> set[Incomplete]: ... @_dispatchable -def is_edge_cover(G: Graph[_Node], cover: set[Incomplete]): ... +def is_edge_cover(G: Graph[_Node], cover: Iterable[Incomplete]) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/d_separation.pyi b/stubs/networkx/networkx/algorithms/d_separation.pyi index ad2bf15dd428..f5796bb4753d 100644 --- a/stubs/networkx/networkx/algorithms/d_separation.pyi +++ b/stubs/networkx/networkx/algorithms/d_separation.pyi @@ -1,7 +1,8 @@ from _typeshed import Incomplete +from typing_extensions import deprecated 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__ = ["is_d_separator", "is_minimal_d_separator", "find_minimal_d_separator", "d_separated", "minimal_d_separator"] @@ -10,8 +11,10 @@ __all__ = ["is_d_separator", "is_minimal_d_separator", "find_minimal_d_separator def is_d_separator(G, x, y, z) -> bool: ... @_dispatchable def find_minimal_d_separator(G, x, y, *, included=None, restricted=None) -> set[Incomplete] | None: ... -@_dispatchable -def d_separated(G, x, y, z): ... +@deprecated("d_separated is deprecated and will be removed in NetworkX v3.5. Please use `is_d_separator(G, x, y, z)`.") +def d_separated( + G: Graph[Incomplete], x: Incomplete | set[Incomplete], y: Incomplete | set[Incomplete], z: Incomplete | set[Incomplete] +) -> bool: ... @_dispatchable def minimal_d_separator(G, u, v): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/dag.pyi b/stubs/networkx/networkx/algorithms/dag.pyi index b44d34db3690..fc21705c16eb 100644 --- a/stubs/networkx/networkx/algorithms/dag.pyi +++ b/stubs/networkx/networkx/algorithms/dag.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete from collections.abc import Callable, Generator, Iterable +from itertools import chain from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node @@ -24,6 +25,8 @@ __all__ = [ "compute_v_structures", ] +chaini = chain.from_iterable + @_dispatchable def descendants(G: Graph[_Node], source) -> set[_Node]: ... @_dispatchable @@ -60,6 +63,6 @@ def dag_longest_path( @_dispatchable def dag_longest_path_length(G: DiGraph[_Node], weight: str | None = "weight", default_weight: int | None = 1) -> int: ... @_dispatchable -def dag_to_branching(G: Graph[_Node]) -> Graph[_Node]: ... +def dag_to_branching(G: Graph[_Node]) -> DiGraph[_Node]: ... @_dispatchable -def compute_v_structures(G) -> Generator[tuple[Incomplete, Incomplete, Incomplete]]: ... +def compute_v_structures(G: Graph[Incomplete]) -> Generator[tuple[Incomplete, Incomplete, Incomplete]]: ... diff --git a/stubs/networkx/networkx/algorithms/distance_measures.pyi b/stubs/networkx/networkx/algorithms/distance_measures.pyi index a74483194497..994a90a76b85 100644 --- a/stubs/networkx/networkx/algorithms/distance_measures.pyi +++ b/stubs/networkx/networkx/algorithms/distance_measures.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -15,21 +17,25 @@ __all__ = [ ] @_dispatchable -def eccentricity(G: Graph[_Node], v: _Node | None = None, sp=None, weight: str | None = None): ... +def eccentricity( + G: Graph[_Node], v: _Node | None = None, sp=None, weight: str | None = None +) -> Incomplete | dict[Incomplete, Incomplete]: ... @_dispatchable def diameter(G: Graph[_Node], e=None, usebounds=False, weight: str | None = None): ... @_dispatchable def harmonic_diameter(G, sp=None) -> float: ... @_dispatchable -def periphery(G: Graph[_Node], e=None, usebounds=False, weight: str | None = None): ... +def periphery(G: Graph[_Node], e=None, usebounds=False, weight: str | None = None) -> list[Incomplete]: ... @_dispatchable 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 = None): ... +def center(G: Graph[_Node], e=None, usebounds=False, weight: str | None = None) -> list[Incomplete]: ... @_dispatchable -def barycenter(G, weight: str | None = None, attr=None, sp=None): ... +def barycenter(G, weight: str | None = None, attr=None, sp=None) -> list[Incomplete]: ... @_dispatchable -def resistance_distance(G: Graph[_Node], nodeA=None, nodeB=None, weight: str | None = None, invert_weight: bool = True): ... +def resistance_distance( + G: Graph[_Node], nodeA=None, nodeB=None, weight: str | None = None, invert_weight: bool = True +) -> float | dict[Incomplete, float]: ... @_dispatchable def effective_graph_resistance(G, weight=None, invert_weight=True) -> float: ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/distance_regular.pyi b/stubs/networkx/networkx/algorithms/distance_regular.pyi index 616db02e900e..9061e2e596ce 100644 --- a/stubs/networkx/networkx/algorithms/distance_regular.pyi +++ b/stubs/networkx/networkx/algorithms/distance_regular.pyi @@ -1,13 +1,16 @@ +from _typeshed import Incomplete +from collections.abc import Generator + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["is_distance_regular", "is_strongly_regular", "intersection_array", "global_parameters"] @_dispatchable -def is_distance_regular(G: Graph[_Node]): ... +def is_distance_regular(G: Graph[_Node]) -> bool: ... @_dispatchable -def global_parameters(b, c): ... +def global_parameters(b, c) -> Generator[tuple[Incomplete, Incomplete, Incomplete]]: ... @_dispatchable def intersection_array(G: Graph[_Node]): ... @_dispatchable -def is_strongly_regular(G: Graph[_Node]): ... +def is_strongly_regular(G: Graph[_Node]) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/dominating.pyi b/stubs/networkx/networkx/algorithms/dominating.pyi index a1058271ad9b..78e526717ee0 100644 --- a/stubs/networkx/networkx/algorithms/dominating.pyi +++ b/stubs/networkx/networkx/algorithms/dominating.pyi @@ -7,6 +7,6 @@ from networkx.utils.backends import _dispatchable __all__ = ["dominating_set", "is_dominating_set"] @_dispatchable -def dominating_set(G: Graph[_Node], start_with: _Node | None = None): ... +def dominating_set(G: Graph[_Node], start_with: _Node | None = None) -> set[Incomplete]: ... @_dispatchable -def is_dominating_set(G: Graph[_Node], nbunch: Iterable[Incomplete]): ... +def is_dominating_set(G: Graph[_Node], nbunch: Iterable[Incomplete]) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/efficiency_measures.pyi b/stubs/networkx/networkx/algorithms/efficiency_measures.pyi index 13369a99ef06..8c2205b20e5f 100644 --- a/stubs/networkx/networkx/algorithms/efficiency_measures.pyi +++ b/stubs/networkx/networkx/algorithms/efficiency_measures.pyi @@ -4,8 +4,8 @@ from networkx.utils.backends import _dispatchable __all__ = ["efficiency", "local_efficiency", "global_efficiency"] @_dispatchable -def efficiency(G, u: _Node, v: _Node): ... +def efficiency(G, u: _Node, v: _Node) -> float: ... @_dispatchable -def global_efficiency(G): ... +def global_efficiency(G) -> float: ... @_dispatchable -def local_efficiency(G): ... +def local_efficiency(G) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/euler.pyi b/stubs/networkx/networkx/algorithms/euler.pyi index 80f0d6e024e2..49768ecb213e 100644 --- a/stubs/networkx/networkx/algorithms/euler.pyi +++ b/stubs/networkx/networkx/algorithms/euler.pyi @@ -9,7 +9,7 @@ __all__ = ["is_eulerian", "eulerian_circuit", "eulerize", "is_semieulerian", "ha @_dispatchable def is_eulerian(G: Graph[_Node]): ... @_dispatchable -def is_semieulerian(G): ... +def is_semieulerian(G: Graph[_Node]): ... @_dispatchable def eulerian_circuit( G: Graph[_Node], source: _Node | None = None, keys: bool = False diff --git a/stubs/networkx/networkx/algorithms/flow/mincost.pyi b/stubs/networkx/networkx/algorithms/flow/mincost.pyi index 86c8e66dcd6c..ee2cfc8cc1c5 100644 --- a/stubs/networkx/networkx/algorithms/flow/mincost.pyi +++ b/stubs/networkx/networkx/algorithms/flow/mincost.pyi @@ -8,8 +8,12 @@ __all__ = ["min_cost_flow_cost", "min_cost_flow", "cost_of_flow", "max_flow_min_ @_dispatchable def min_cost_flow_cost(G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... @_dispatchable -def min_cost_flow(G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... +def min_cost_flow( + G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight" +) -> tuple[int | Incomplete, dict[Incomplete, dict[Incomplete, Incomplete]]]: ... @_dispatchable def cost_of_flow(G: Graph[_Node], flowDict: SupportsGetItem[Incomplete, Incomplete], weight: str = "weight"): ... @_dispatchable -def max_flow_min_cost(G: Graph[_Node], s: str, t: str, capacity: str = "capacity", weight: str = "weight"): ... +def max_flow_min_cost( + G: Graph[_Node], s: str, t: str, capacity: str = "capacity", weight: str = "weight" +) -> tuple[int | Incomplete, dict[Incomplete, dict[Incomplete, Incomplete]]]: ... diff --git a/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi b/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi index c6028757f936..7f03d98e3479 100644 --- a/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi +++ b/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi @@ -26,7 +26,9 @@ class _DataEssentialsAndFunctions: prev_node_dft: Incomplete last_descendent_dft: Incomplete - def __init__(self, G, multigraph, demand: str = "demand", capacity: str = "capacity", weight: str = "weight") -> None: ... + def __init__( + self, G: Graph[Incomplete], multigraph, demand: str = "demand", capacity: str = "capacity", weight: str = "weight" + ) -> None: ... def initialize_spanning_tree(self, n, faux_inf) -> None: ... def find_apex(self, p, q): ... def trace_path(self, p, w): ... @@ -43,4 +45,6 @@ class _DataEssentialsAndFunctions: def find_leaving_edge(self, Wn, We): ... @_dispatchable -def network_simplex(G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... +def network_simplex( + G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight" +) -> tuple[int | Incomplete, dict[Incomplete, dict[Incomplete, Incomplete]]]: ... diff --git a/stubs/networkx/networkx/algorithms/flow/utils.pyi b/stubs/networkx/networkx/algorithms/flow/utils.pyi index 0ae3a6bba8cc..f29ef014bd3b 100644 --- a/stubs/networkx/networkx/algorithms/flow/utils.pyi +++ b/stubs/networkx/networkx/algorithms/flow/utils.pyi @@ -2,6 +2,8 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable +from ...classes.graph import Graph + __all__ = ["CurrentEdge", "Level", "GlobalRelabelThreshold", "build_residual_network", "detect_unboundedness", "build_flow_dict"] class CurrentEdge: @@ -22,8 +24,8 @@ class GlobalRelabelThreshold: def clear_work(self) -> None: ... @_dispatchable -def build_residual_network(G, capacity): ... +def build_residual_network(G: Graph[Incomplete], capacity): ... @_dispatchable def detect_unboundedness(R, s, t) -> None: ... @_dispatchable -def build_flow_dict(G, R): ... +def build_flow_dict(G: Graph[Incomplete], R): ... diff --git a/stubs/networkx/networkx/algorithms/graph_hashing.pyi b/stubs/networkx/networkx/algorithms/graph_hashing.pyi index 7232060d585f..9829cc627f79 100644 --- a/stubs/networkx/networkx/algorithms/graph_hashing.pyi +++ b/stubs/networkx/networkx/algorithms/graph_hashing.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -10,7 +12,7 @@ def weisfeiler_lehman_graph_hash( node_attr: str | None = None, iterations: int | None = 3, digest_size: int | None = 16, -): ... +) -> str: ... @_dispatchable def weisfeiler_lehman_subgraph_hashes( G: Graph[_Node], @@ -19,4 +21,4 @@ def weisfeiler_lehman_subgraph_hashes( iterations: int | None = 3, digest_size: int | None = 16, include_initial_labels: bool | None = False, -): ... +) -> dict[Incomplete, list[str]]: ... diff --git a/stubs/networkx/networkx/algorithms/graphical.pyi b/stubs/networkx/networkx/algorithms/graphical.pyi index 54936da7634a..9f94564d8eb3 100644 --- a/stubs/networkx/networkx/algorithms/graphical.pyi +++ b/stubs/networkx/networkx/algorithms/graphical.pyi @@ -13,14 +13,14 @@ __all__ = [ ] @_dispatchable -def is_graphical(sequence: Iterable[Incomplete], method="eg"): ... +def is_graphical(sequence: Iterable[Incomplete], method="eg") -> bool: ... @_dispatchable -def is_valid_degree_sequence_havel_hakimi(deg_sequence: Iterable[Incomplete]): ... +def is_valid_degree_sequence_havel_hakimi(deg_sequence: Iterable[Incomplete]) -> bool: ... @_dispatchable -def is_valid_degree_sequence_erdos_gallai(deg_sequence: Iterable[Incomplete]): ... +def is_valid_degree_sequence_erdos_gallai(deg_sequence: Iterable[Incomplete]) -> bool: ... @_dispatchable -def is_multigraphical(sequence: Iterable[Incomplete]): ... +def is_multigraphical(sequence: Iterable[Incomplete]) -> bool: ... @_dispatchable -def is_pseudographical(sequence: Iterable[Incomplete]): ... +def is_pseudographical(sequence: Iterable[Incomplete]) -> bool: ... @_dispatchable -def is_digraphical(in_sequence: Iterable[Incomplete], out_sequence: Iterable[Incomplete]): ... +def is_digraphical(in_sequence: Iterable[Incomplete], out_sequence: Iterable[Incomplete]) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/hierarchy.pyi b/stubs/networkx/networkx/algorithms/hierarchy.pyi index e982bfa88a4f..d53b3829ffdc 100644 --- a/stubs/networkx/networkx/algorithms/hierarchy.pyi +++ b/stubs/networkx/networkx/algorithms/hierarchy.pyi @@ -1,6 +1,8 @@ from networkx.utils.backends import _dispatchable +from ..classes.digraph import DiGraph + __all__ = ["flow_hierarchy"] @_dispatchable -def flow_hierarchy(G, weight: str | None = None): ... +def flow_hierarchy(G: DiGraph, weight: str | None = None) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/isolate.pyi b/stubs/networkx/networkx/algorithms/isolate.pyi index 4a5715d228f4..95a78fa04f4d 100644 --- a/stubs/networkx/networkx/algorithms/isolate.pyi +++ b/stubs/networkx/networkx/algorithms/isolate.pyi @@ -4,8 +4,8 @@ from networkx.utils.backends import _dispatchable __all__ = ["is_isolate", "isolates", "number_of_isolates"] @_dispatchable -def is_isolate(G: Graph[_Node], n: _Node): ... +def is_isolate(G: Graph[_Node], n: _Node) -> bool: ... @_dispatchable def isolates(G: Graph[_Node]): ... @_dispatchable -def number_of_isolates(G: Graph[_Node]): ... +def number_of_isolates(G: Graph[_Node]) -> int: ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi index e0dae00bd5fe..a76499ed63e0 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi @@ -1,6 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator +from ...classes.graph import Graph + __all__ = ["ISMAGS"] class ISMAGS: @@ -11,16 +13,16 @@ class ISMAGS: def __init__( self, - graph, - subgraph, + graph: Graph[Incomplete], + subgraph: Graph[Incomplete], node_match: Incomplete | None = None, edge_match: Incomplete | None = None, cache: Incomplete | None = None, ) -> None: ... def find_isomorphisms(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, Incomplete]: ... def largest_common_subgraph(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, None]: ... - def analyze_symmetry(self, graph, node_partitions, edge_colors): ... - def is_isomorphic(self, symmetry: bool = False): ... - def subgraph_is_isomorphic(self, symmetry: bool = False): ... + def analyze_symmetry(self, graph: Graph[Incomplete], node_partitions, edge_colors): ... + def is_isomorphic(self, symmetry: bool = False) -> bool: ... + def subgraph_is_isomorphic(self, symmetry: bool = False) -> bool: ... def isomorphisms_iter(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, None]: ... def subgraph_isomorphisms_iter(self, symmetry: bool = True): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi b/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi index dd57778fcc7a..46762afbf8a7 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi @@ -1,6 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator +from ...classes.graph import Graph + __all__ = ["GraphMatcher", "DiGraphMatcher"] class GraphMatcher: @@ -12,7 +14,7 @@ class GraphMatcher: old_recursion_limit: Incomplete test: str - def __init__(self, G1, G2) -> None: ... + def __init__(self, G1: Graph[Incomplete], G2: Graph[Incomplete]) -> None: ... def reset_recursion_limit(self) -> None: ... def candidate_pairs_iter(self) -> Generator[Incomplete, None, None]: ... core_1: Incomplete @@ -34,7 +36,7 @@ class GraphMatcher: def syntactic_feasibility(self, G1_node, G2_node): ... class DiGraphMatcher(GraphMatcher): - def __init__(self, G1, G2) -> None: ... + def __init__(self, G1: Graph[Incomplete], G2: Graph[Incomplete]) -> None: ... def candidate_pairs_iter(self) -> Generator[Incomplete, None, None]: ... core_1: Incomplete core_2: Incomplete diff --git a/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi b/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi index 2175fb430a40..4d7f21550bb0 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi @@ -1,4 +1,6 @@ from _typeshed import Incomplete +from collections.abc import Callable, Iterable +from types import FunctionType from networkx.utils.backends import _dispatchable @@ -14,24 +16,26 @@ __all__ = [ "generic_multiedge_match", ] +def copyfunc(f, name=None) -> FunctionType: ... +def allclose(x, y, rtol: float = 1.0000000000000001e-05, atol=1e-08) -> bool: ... @_dispatchable -def categorical_node_match(attr, default): ... +def categorical_node_match(attr: str | Iterable[str], default): ... -categorical_edge_match: Incomplete +categorical_edge_match: FunctionType @_dispatchable -def categorical_multiedge_match(attr, default): ... +def categorical_multiedge_match(attr: str | Iterable[str], default): ... @_dispatchable -def numerical_node_match(attr, default, rtol: float = 1e-05, atol: float = 1e-08): ... +def numerical_node_match(attr: str | Iterable[str], default, rtol: float = 1e-05, atol: float = 1e-08): ... -numerical_edge_match: Incomplete +numerical_edge_match: FunctionType @_dispatchable -def numerical_multiedge_match(attr, default, rtol: float = 1e-05, atol: float = 1e-08): ... +def numerical_multiedge_match(attr: str | Iterable[str], default, rtol: float = 1e-05, atol: float = 1e-08): ... @_dispatchable -def generic_node_match(attr, default, op): ... +def generic_node_match(attr: str | Iterable[str], default, op: Callable[[Incomplete, Incomplete], Incomplete]): ... -generic_edge_match: Incomplete +generic_edge_match: FunctionType @_dispatchable -def generic_multiedge_match(attr, default, op): ... +def generic_multiedge_match(attr: str | Iterable[str], default, op: Callable[[Incomplete, Incomplete], Incomplete]): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi b/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi index 060f3d193541..3a7a377e283e 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete +from ...classes.graph import Graph from .isomorphvf2 import DiGraphMatcher, GraphMatcher __all__ = ["TimeRespectingGraphMatcher", "TimeRespectingDiGraphMatcher"] @@ -8,7 +9,7 @@ class TimeRespectingGraphMatcher(GraphMatcher): temporal_attribute_name: Incomplete delta: Incomplete - def __init__(self, G1, G2, temporal_attribute_name, delta) -> None: ... + def __init__(self, G1: Graph[Incomplete], G2: Graph[Incomplete], temporal_attribute_name, delta) -> None: ... def one_hop(self, Gx, Gx_node, neighbors): ... def two_hop(self, Gx, core_x, Gx_node, neighbors): ... def semantic_feasibility(self, G1_node, G2_node): ... @@ -17,7 +18,7 @@ class TimeRespectingDiGraphMatcher(DiGraphMatcher): temporal_attribute_name: Incomplete delta: Incomplete - def __init__(self, G1, G2, temporal_attribute_name, delta) -> None: ... + def __init__(self, G1: Graph[Incomplete], G2: Graph[Incomplete], 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): ... def one_hop(self, Gx, Gx_node, core_x, pred, succ): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi b/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi index 0497880a4136..978db20c29fb 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi @@ -1,9 +1,16 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["rooted_tree_isomorphism", "tree_isomorphism"] +def root_trees(t1, root1, t2, root2): ... +@_dispatchable +def assign_levels(G: Graph[Incomplete], root): ... +def group_by_levels(levels): ... +def generate_isomorphism(v, w, M, ordered_children): ... @_dispatchable -def rooted_tree_isomorphism(t1, root1, t2, root2): ... +def rooted_tree_isomorphism(t1, root1, t2, root2) -> list[tuple[Incomplete, Incomplete]]: ... @_dispatchable -def tree_isomorphism(t1: Graph[_Node], t2: Graph[_Node]): ... +def tree_isomorphism(t1: Graph[_Node], t2: Graph[_Node]) -> list[tuple[Incomplete, Incomplete]]: ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi b/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi index 3800601bc5e9..67ca3646dea2 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi @@ -1,5 +1,7 @@ from _typeshed import Incomplete +from collections.abc import Callable +from ...classes.graph import Graph from . import isomorphvf2 as vf2 __all__ = ["GraphMatcher", "DiGraphMatcher", "MultiGraphMatcher", "MultiDiGraphMatcher"] @@ -10,8 +12,14 @@ class GraphMatcher(vf2.GraphMatcher): 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 + def __init__( + self, + G1: Graph[Incomplete], + G2: Graph[Incomplete], + node_match: Callable[..., Incomplete] | None = None, + edge_match: Callable[..., Incomplete] | None = None, + ) -> None: ... + def semantic_feasibility(self, G1_node, G2_node): ... class DiGraphMatcher(vf2.DiGraphMatcher): node_match: Incomplete @@ -19,7 +27,13 @@ class DiGraphMatcher(vf2.DiGraphMatcher): G1_adj: Incomplete G2_adj: Incomplete - def __init__(self, G1, G2, node_match: Incomplete | None = None, edge_match: Incomplete | None = None) -> None: ... + def __init__( + self, + G1: Graph[Incomplete], + G2: Graph[Incomplete], + node_match: Callable[..., Incomplete] | None = None, + edge_match: Callable[..., Incomplete] | None = None, + ) -> None: ... def semantic_feasibility(self, G1_node, G2_node): ... class MultiGraphMatcher(GraphMatcher): ... diff --git a/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi b/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi index 93a97d20ea4b..fca4adccedf9 100644 --- a/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi +++ b/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi @@ -16,7 +16,7 @@ def pagerank( nstart: SupportsGetItem[Incomplete, Incomplete] | None = None, weight: str | None = "weight", dangling: SupportsGetItem[Incomplete, Incomplete] | None = None, -): ... +) -> dict[Incomplete, float]: ... @_dispatchable def google_matrix( G: Graph[_Node], diff --git a/stubs/networkx/networkx/algorithms/matching.pyi b/stubs/networkx/networkx/algorithms/matching.pyi index 4753abee8876..cc522628e2e1 100644 --- a/stubs/networkx/networkx/algorithms/matching.pyi +++ b/stubs/networkx/networkx/algorithms/matching.pyi @@ -1,3 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Iterable + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -11,14 +14,17 @@ __all__ = [ ] @_dispatchable -def maximal_matching(G: Graph[_Node]): ... +def maximal_matching(G: Graph[_Node]) -> set[Incomplete]: ... +def matching_dict_to_set(matching) -> set[Incomplete]: ... @_dispatchable -def is_matching(G: Graph[_Node], matching): ... +def is_matching(G: Graph[_Node], matching: Iterable[Incomplete] | dict[Incomplete, Incomplete]) -> bool: ... @_dispatchable -def is_maximal_matching(G: Graph[_Node], matching): ... +def is_maximal_matching(G: Graph[_Node], matching: Iterable[Incomplete] | dict[Incomplete, Incomplete]) -> bool: ... @_dispatchable -def is_perfect_matching(G: Graph[_Node], matching): ... +def is_perfect_matching(G: Graph[_Node], matching: Iterable[Incomplete] | dict[Incomplete, Incomplete]) -> bool: ... @_dispatchable -def min_weight_matching(G: Graph[_Node], weight: str | None = "weight"): ... +def min_weight_matching(G: Graph[_Node], weight: str | None = "weight") -> set[Incomplete]: ... @_dispatchable -def max_weight_matching(G: Graph[_Node], maxcardinality: bool | None = False, weight: str | None = "weight"): ... +def max_weight_matching( + G: Graph[_Node], maxcardinality: bool | None = False, weight: str | None = "weight" +) -> set[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/minors/contraction.pyi b/stubs/networkx/networkx/algorithms/minors/contraction.pyi index 200e9f2fcdca..4552be95180a 100644 --- a/stubs/networkx/networkx/algorithms/minors/contraction.pyi +++ b/stubs/networkx/networkx/algorithms/minors/contraction.pyi @@ -1,13 +1,16 @@ from _typeshed import Incomplete -from collections.abc import Callable +from collections.abc import Callable, Iterable +from itertools import chain from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["contracted_edge", "contracted_nodes", "equivalence_classes", "identified_nodes", "quotient_graph"] +chaini = chain.from_iterable + @_dispatchable -def equivalence_classes(iterable, relation): ... +def equivalence_classes(iterable: Iterable[Incomplete], relation): ... @_dispatchable def quotient_graph( G: Graph[_Node], diff --git a/stubs/networkx/networkx/algorithms/mis.pyi b/stubs/networkx/networkx/algorithms/mis.pyi index bbe4abaeb266..b0b6a9914384 100644 --- a/stubs/networkx/networkx/algorithms/mis.pyi +++ b/stubs/networkx/networkx/algorithms/mis.pyi @@ -10,4 +10,4 @@ __all__ = ["maximal_independent_set"] @_dispatchable def maximal_independent_set( G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, seed: int | RandomState | None = None -): ... +) -> list[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/operators/binary.pyi b/stubs/networkx/networkx/algorithms/operators/binary.pyi index 493b1762c7ad..a33b50529d94 100644 --- a/stubs/networkx/networkx/algorithms/operators/binary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/binary.pyi @@ -23,6 +23,6 @@ _Y_co = TypeVar("_Y_co", bound=Hashable, covariant=True) @_dispatchable def compose(G: Graph[_X_co], H: Graph[_Y_co]) -> DiGraph[_X_co | _Y_co]: ... @_dispatchable -def full_join(G, H, rename=(None, None)): ... +def full_join(G: Graph[Incomplete], H, rename=(None, None)): ... @_dispatchable def union(G: Graph[_X_co], H: Graph[_Y_co], rename: Iterable[Incomplete] | None = ()) -> DiGraph[_X_co | _Y_co]: ... diff --git a/stubs/networkx/networkx/algorithms/planar_drawing.pyi b/stubs/networkx/networkx/algorithms/planar_drawing.pyi index 197e912ec440..d4c6164ed122 100644 --- a/stubs/networkx/networkx/algorithms/planar_drawing.pyi +++ b/stubs/networkx/networkx/algorithms/planar_drawing.pyi @@ -1,6 +1,16 @@ +from _typeshed import Incomplete +from collections.abc import Sequence + from networkx.utils.backends import _dispatchable __all__ = ["combinatorial_embedding_to_pos"] @_dispatchable -def combinatorial_embedding_to_pos(embedding, fully_triangulate: bool = False): ... +def combinatorial_embedding_to_pos(embedding, fully_triangulate: bool = False) -> dict[Incomplete, Incomplete]: ... +def set_position(parent, tree, remaining_nodes, delta_x, y_coordinate, pos): ... +def get_canonical_ordering(embedding, outer_face: Sequence[Incomplete]) -> list[Incomplete]: ... +def triangulate_face(embedding, v1, v2): ... +def triangulate_embedding(embedding, fully_triangulate: bool = True): ... +def make_bi_connected( + embedding, starting_node, outgoing_node, edges_counted: set[tuple[Incomplete, Incomplete]] +) -> list[Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index 43d10d50a84e..b170abc38651 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -11,6 +11,10 @@ __all__ = ["check_planarity", "is_planar", "PlanarEmbedding"] def is_planar(G: Graph[_Node]) -> bool: ... @_dispatchable def check_planarity(G: Graph[_Node], counterexample: bool = False): ... +@_dispatchable +def get_counterexample(G: Graph[Incomplete]) -> Graph[Incomplete]: ... +@_dispatchable +def get_counterexample_recursive(G: Graph[Incomplete]) -> Graph[Incomplete]: ... class Interval: low: Incomplete @@ -47,10 +51,10 @@ class LRPlanarity: lowpt_edge: Incomplete left_ref: Incomplete right_ref: Incomplete - embedding: Incomplete + embedding: PlanarEmbedding def __init__(self, G) -> None: ... - def lr_planarity(self): ... + def lr_planarity(self) -> PlanarEmbedding | None: ... def lr_planarity_recursive(self): ... def dfs_orientation(self, v): ... def dfs_orientation_recursive(self, v) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/reciprocity.pyi b/stubs/networkx/networkx/algorithms/reciprocity.pyi index 2208e9e00507..de7191d31c0e 100644 --- a/stubs/networkx/networkx/algorithms/reciprocity.pyi +++ b/stubs/networkx/networkx/algorithms/reciprocity.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -6,6 +7,6 @@ from networkx.utils.backends import _dispatchable __all__ = ["reciprocity", "overall_reciprocity"] @_dispatchable -def reciprocity(G: Graph[_Node], nodes: Iterable[_Node] | None = None): ... +def reciprocity(G: Graph[_Node], nodes: Iterable[_Node] | None = None) -> float | dict[Incomplete, float | None]: ... @_dispatchable def overall_reciprocity(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/regular.pyi b/stubs/networkx/networkx/algorithms/regular.pyi index 04d966f9416f..7505f6d5a521 100644 --- a/stubs/networkx/networkx/algorithms/regular.pyi +++ b/stubs/networkx/networkx/algorithms/regular.pyi @@ -4,8 +4,8 @@ from networkx.utils.backends import _dispatchable __all__ = ["is_regular", "is_k_regular", "k_factor"] @_dispatchable -def is_regular(G: Graph[_Node]): ... +def is_regular(G: Graph[_Node]) -> bool: ... @_dispatchable -def is_k_regular(G: Graph[_Node], k): ... +def is_k_regular(G: Graph[_Node], k) -> bool: ... @_dispatchable 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 abf5cd680b9a..2f2b25d7b987 100644 --- a/stubs/networkx/networkx/algorithms/richclub.pyi +++ b/stubs/networkx/networkx/algorithms/richclub.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState @@ -5,4 +7,6 @@ from numpy.random import RandomState __all__ = ["rich_club_coefficient"] @_dispatchable -def rich_club_coefficient(G: Graph[_Node], normalized: bool = True, Q: float = 100, seed: int | RandomState | None = None): ... +def rich_club_coefficient( + G: Graph[_Node], normalized: bool = True, Q: float = 100, seed: int | RandomState | None = None +) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi index ce36193312ab..96c6399f63cb 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete, SupportsGetItem +from collections import defaultdict from collections.abc import Collection from networkx.classes.graph import Graph, _Node @@ -9,8 +10,10 @@ __all__ = ["floyd_warshall", "floyd_warshall_predecessor_and_distance", "reconst @_dispatchable def floyd_warshall_numpy(G: Graph[_Node], nodelist: Collection[_Node] | None = None, weight: str | None = "weight"): ... @_dispatchable -def floyd_warshall_predecessor_and_distance(G: Graph[_Node], weight: str | None = "weight"): ... +def floyd_warshall_predecessor_and_distance( + G: Graph[_Node], weight: str | None = "weight" +) -> tuple[dict[Incomplete, dict[Incomplete, Incomplete]], dict[Incomplete, dict[Incomplete, float]]]: ... @_dispatchable -def reconstruct_path(source: _Node, target: _Node, predecessors: SupportsGetItem[Incomplete, Incomplete]): ... +def reconstruct_path(source: _Node, target: _Node, predecessors: SupportsGetItem[Incomplete, Incomplete]) -> list[Incomplete]: ... @_dispatchable -def floyd_warshall(G: Graph[_Node], weight: str | None = "weight"): ... +def floyd_warshall(G: Graph[_Node], weight: str | None = "weight") -> dict[Incomplete, defaultdict[Incomplete, float]]: ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi index 7b5248b19985..e7008bdc9b2b 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi @@ -16,19 +16,25 @@ __all__ = [ ] @_dispatchable -def single_source_shortest_path_length(G: Graph[_Node], source: _Node, cutoff: int | None = None): ... +def single_source_shortest_path_length(G: Graph[_Node], source: _Node, cutoff: int | None = None) -> dict[Incomplete, int]: ... @_dispatchable def single_target_shortest_path_length(G: Graph[_Node], target: _Node, cutoff: int | None = None): ... @_dispatchable def all_pairs_shortest_path_length(G: Graph[_Node], cutoff: int | None = None) -> Generator[Incomplete, None, None]: ... @_dispatchable -def bidirectional_shortest_path(G: Graph[_Node], source: _Node, target: _Node): ... +def bidirectional_shortest_path(G: Graph[_Node], source: _Node, target: _Node) -> list[Incomplete]: ... @_dispatchable -def single_source_shortest_path(G: Graph[_Node], source: _Node, cutoff: int | None = None): ... +def single_source_shortest_path( + G: Graph[_Node], source: _Node, cutoff: int | None = None +) -> dict[Incomplete, list[Incomplete]]: ... @_dispatchable -def single_target_shortest_path(G: Graph[_Node], target: _Node, cutoff: int | None = None): ... +def single_target_shortest_path( + G: Graph[_Node], target: _Node, cutoff: int | None = None +) -> dict[Incomplete, list[Incomplete]]: ... @_dispatchable -def all_pairs_shortest_path(G: Graph[_Node], cutoff: int | None = None) -> Generator[Incomplete, None, None]: ... +def all_pairs_shortest_path( + G: Graph[_Node], cutoff: int | None = None +) -> Generator[tuple[Incomplete, dict[Incomplete, list[Incomplete]]]]: ... @_dispatchable def predecessor( G: Graph[_Node], source: _Node, target: _Node | None = None, cutoff: int | None = None, return_seen: bool | None = None diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi index 28fb31c561ec..bee162cf7da4 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi @@ -39,7 +39,7 @@ def dijkstra_path( source: _Node, target: _Node, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> dict[Incomplete, list[Incomplete]] | list[Incomplete]: ... @_dispatchable def dijkstra_path_length( G: Graph[_Node], @@ -53,14 +53,14 @@ def single_source_dijkstra_path( source: _Node, cutoff: float | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> dict[Incomplete, list[Incomplete]] | list[Incomplete]: ... @_dispatchable def single_source_dijkstra_path_length( G: Graph[_Node], source: _Node, cutoff: float | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> dict[Incomplete, Incomplete]: ... @_dispatchable def single_source_dijkstra( G: Graph[_Node], @@ -68,21 +68,21 @@ def single_source_dijkstra( target: _Node | None = None, cutoff: float | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> tuple[Incomplete, Incomplete]: ... @_dispatchable def multi_source_dijkstra_path( G: Graph[_Node], sources, cutoff: float | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> dict[Incomplete, list[Incomplete]] | list[Incomplete]: ... @_dispatchable def multi_source_dijkstra_path_length( G: Graph[_Node], sources, cutoff: float | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> dict[Incomplete, Incomplete]: ... @_dispatchable def multi_source_dijkstra( G: Graph[_Node], @@ -90,14 +90,14 @@ def multi_source_dijkstra( target: _Node | None = None, cutoff: float | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> tuple[Incomplete, Incomplete]: ... @_dispatchable def dijkstra_predecessor_and_distance( G: Graph[_Node], source: _Node, cutoff: float | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> tuple[dict[Incomplete, list[Incomplete]], dict[Incomplete, Incomplete]]: ... @_dispatchable def all_pairs_dijkstra( G: Graph[_Node], @@ -115,7 +115,7 @@ def all_pairs_dijkstra_path( G: Graph[_Node], cutoff: float | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -) -> Generator[Incomplete, None, None]: ... +) -> Generator[tuple[Incomplete, Incomplete], None, None]: ... @_dispatchable def bellman_ford_predecessor_and_distance( G: Graph[_Node], @@ -123,14 +123,14 @@ def bellman_ford_predecessor_and_distance( target: _Node | None = None, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", heuristic: bool = False, -): ... +) -> tuple[Incomplete, Incomplete]: ... @_dispatchable def bellman_ford_path( G: Graph[_Node], source: _Node, target: _Node, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> list[Incomplete] | dict[Incomplete, list[Incomplete]]: ... @_dispatchable def bellman_ford_path_length( G: Graph[_Node], @@ -141,11 +141,11 @@ def bellman_ford_path_length( @_dispatchable def single_source_bellman_ford_path( G: Graph[_Node], source: _Node, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight" -): ... +) -> list[Incomplete] | dict[Incomplete, list[Incomplete]]: ... @_dispatchable def single_source_bellman_ford_path_length( G: Graph[_Node], source: _Node, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight" -): ... +) -> dict[Incomplete, int]: ... @_dispatchable def single_source_bellman_ford( G: Graph[_Node], @@ -160,11 +160,11 @@ def all_pairs_bellman_ford_path_length( @_dispatchable def all_pairs_bellman_ford_path( G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight" -) -> Generator[Incomplete, None, None]: ... +) -> Generator[tuple[Incomplete, Incomplete], None, None]: ... @_dispatchable def goldberg_radzik( G: Graph[_Node], source: _Node, weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight" -): ... +) -> tuple[dict[Incomplete, None], dict[Incomplete, int | float]]: ... @_dispatchable def negative_edge_cycle( G: Graph[_Node], @@ -183,4 +183,4 @@ def bidirectional_dijkstra( weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ): ... @_dispatchable -def johnson(G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight"): ... +def johnson(G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight")->dict[Any, dict[Any, list[Any]]]:: ... diff --git a/stubs/networkx/networkx/algorithms/similarity.pyi b/stubs/networkx/networkx/algorithms/similarity.pyi index 822a9e46dff8..6b3673d0280d 100644 --- a/stubs/networkx/networkx/algorithms/similarity.pyi +++ b/stubs/networkx/networkx/algorithms/similarity.pyi @@ -84,7 +84,7 @@ def simrank_similarity( importance_factor: float = 0.9, max_iterations: int = 1000, tolerance: float = 0.0001, -): ... +) -> float | dict[Incomplete, Incomplete]: ... @_dispatchable def panther_similarity( G: Graph[_Node], @@ -95,7 +95,7 @@ def panther_similarity( delta: float = 0.1, eps=None, weight: str | None = "weight", -): ... +) -> dict[bytes, bytes]: ... @_dispatchable def generate_random_paths( G: Graph[_Node], @@ -104,4 +104,4 @@ def generate_random_paths( index_map: SupportsGetItem[Incomplete, Incomplete] | None = None, weight: str | None = "weight", seed: int | RandomState | None = None, -) -> Generator[Incomplete, None, None]: ... +) -> Generator[list[Incomplete], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/simple_paths.pyi b/stubs/networkx/networkx/algorithms/simple_paths.pyi index a33ebdbb3bdc..2aa418a8a859 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, SupportsGetItem -from collections.abc import Callable, Generator, Iterable +from collections.abc import Callable, Collection, Generator 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: Iterable[Incomplete]): ... +def is_simple_path(G: Graph[_Node], nodes: Collection[Incomplete]) -> bool: ... @_dispatchable def all_simple_paths(G: Graph[_Node], source: _Node, target, cutoff: int | None = None) -> Generator[list[_Node], None, None]: ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/smallworld.pyi b/stubs/networkx/networkx/algorithms/smallworld.pyi index 665226a3d6ee..3e163c121c7c 100644 --- a/stubs/networkx/networkx/algorithms/smallworld.pyi +++ b/stubs/networkx/networkx/algorithms/smallworld.pyi @@ -11,6 +11,6 @@ def lattice_reference( G: Graph[_Node], niter: int = 5, D=None, connectivity: bool = True, seed: int | RandomState | None = None ): ... @_dispatchable -def sigma(G: Graph[_Node], niter: int = 100, nrand: int = 10, seed: int | RandomState | None = None): ... +def sigma(G: Graph[_Node], niter: int = 100, nrand: int = 10, seed: int | RandomState | None = None) -> float: ... @_dispatchable -def omega(G: Graph[_Node], niter: int = 5, nrand: int = 10, seed: int | RandomState | None = None): ... +def omega(G: Graph[_Node], niter: int = 5, nrand: int = 10, seed: int | RandomState | None = None) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/smetric.pyi b/stubs/networkx/networkx/algorithms/smetric.pyi index e1cf4fd2563f..60f6d0ab5d25 100644 --- a/stubs/networkx/networkx/algorithms/smetric.pyi +++ b/stubs/networkx/networkx/algorithms/smetric.pyi @@ -4,4 +4,4 @@ from networkx.utils.backends import _dispatchable __all__ = ["s_metric"] @_dispatchable -def s_metric(G: Graph[_Node]): ... +def s_metric(G: Graph[_Node]) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/structuralholes.pyi b/stubs/networkx/networkx/algorithms/structuralholes.pyi index 8d1519350ad6..b976f042e5b7 100644 --- a/stubs/networkx/networkx/algorithms/structuralholes.pyi +++ b/stubs/networkx/networkx/algorithms/structuralholes.pyi @@ -7,8 +7,16 @@ from networkx.utils.backends import _dispatchable __all__ = ["constraint", "local_constraint", "effective_size"] @_dispatchable -def effective_size(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, weight: str | None = None): ... +def mutual_weight(G: Graph[Incomplete], u, v, weight=None) -> Incomplete | int: ... @_dispatchable -def constraint(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, weight: str | None = None): ... +def normalized_mutual_weight(G: Graph[Incomplete], u, v, norm=..., weight=None) -> float: ... @_dispatchable -def local_constraint(G: Graph[_Node], u: _Node, v: _Node, weight: str | None = None): ... +def effective_size( + G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, weight: str | None = None +) -> dict[Incomplete, Incomplete]: ... +@_dispatchable +def constraint( + G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, weight: str | None = None +) -> dict[Incomplete, Incomplete]: ... +@_dispatchable +def local_constraint(G: Graph[_Node], u: _Node, v: _Node, weight: str | None = None) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/swap.pyi b/stubs/networkx/networkx/algorithms/swap.pyi index 529b895d61c0..7378a13a814e 100644 --- a/stubs/networkx/networkx/algorithms/swap.pyi +++ b/stubs/networkx/networkx/algorithms/swap.pyi @@ -12,4 +12,4 @@ def double_edge_swap(G: Graph[_Node], nswap: int = 1, max_tries: int = 100, seed @_dispatchable def connected_double_edge_swap( G: Graph[_Node], nswap: int = 1, _window_threshold: int = 3, seed: int | RandomState | None = None -): ... +) -> int: ... diff --git a/stubs/networkx/networkx/algorithms/threshold.pyi b/stubs/networkx/networkx/algorithms/threshold.pyi index d92695ec45d9..309a0fa2178d 100644 --- a/stubs/networkx/networkx/algorithms/threshold.pyi +++ b/stubs/networkx/networkx/algorithms/threshold.pyi @@ -4,6 +4,34 @@ from networkx.utils.backends import _dispatchable __all__ = ["is_threshold_graph", "find_threshold_graph"] @_dispatchable -def is_threshold_graph(G: Graph[_Node]): ... +def is_threshold_graph(G: Graph[_Node]) -> bool: ... +def is_threshold_sequence(degree_sequence): ... +def creation_sequence(degree_sequence, with_labels=False, compact=False): ... +def make_compact(creation_sequence): ... +def uncompact(creation_sequence): ... +def creation_sequence_to_weights(creation_sequence): ... +def weights_to_creation_sequence(weights, threshold=1, with_labels=False, compact=False): ... +@_dispatchable +def threshold_graph(creation_sequence, create_using=None): ... +@_dispatchable +def find_alternating_4_cycle(G: Graph): ... @_dispatchable def find_threshold_graph(G: Graph[_Node], create_using: Graph[_Node] | None = None): ... +@_dispatchable +def find_creation_sequence(G: Graph): ... +def triangles(creation_sequence): ... +def triangle_sequence(creation_sequence): ... +def cluster_sequence(creation_sequence): ... +def degree_sequence(creation_sequence): ... +def density(creation_sequence): ... +def degree_correlation(creation_sequence): ... +def shortest_path(creation_sequence, u, v): ... +def shortest_path_length(creation_sequence, i): ... +def betweenness_sequence(creation_sequence, normalized=True): ... +def eigenvectors(creation_sequence): ... +def spectral_projection(u, eigenpairs): ... +def eigenvalues(creation_sequence): ... +def random_threshold_sequence(n, p, seed=None): ... +def right_d_threshold_sequence(n, m): ... +def left_d_threshold_sequence(n, m): ... +def swap_d(cs, p_split=1.0, p_combine=1.0, seed=None): ... diff --git a/stubs/networkx/networkx/algorithms/tournament.pyi b/stubs/networkx/networkx/algorithms/tournament.pyi index f80e6e5b9834..a220912f5038 100644 --- a/stubs/networkx/networkx/algorithms/tournament.pyi +++ b/stubs/networkx/networkx/algorithms/tournament.pyi @@ -1,18 +1,25 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState +from ..classes.digraph import DiGraph + __all__ = ["hamiltonian_path", "is_reachable", "is_strongly_connected", "is_tournament", "random_tournament", "score_sequence"] +def index_satisfying(iterable, condition): ... +@_dispatchable +def is_tournament(G: Graph[_Node]) -> bool: ... @_dispatchable -def is_tournament(G: Graph[_Node]): ... +def hamiltonian_path(G: Graph[_Node]) -> list[Incomplete]: ... @_dispatchable -def hamiltonian_path(G: Graph[_Node]): ... +def random_tournament(n: int, seed: int | RandomState | None = None) -> DiGraph: ... @_dispatchable -def random_tournament(n: int, seed: int | RandomState | None = None): ... +def score_sequence(G: Graph[_Node]) -> list[Incomplete]: ... @_dispatchable -def score_sequence(G: Graph[_Node]): ... +def tournament_matrix(G: Graph): ... @_dispatchable -def is_reachable(G: Graph[_Node], s: _Node, t: _Node): ... +def is_reachable(G: Graph[_Node], s: _Node, t: _Node) -> bool: ... @_dispatchable -def is_strongly_connected(G: Graph[_Node]): ... +def is_strongly_connected(G: Graph[_Node]) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi b/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi index 226ebaaa07f1..5dd99a54d7ee 100644 --- a/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi @@ -17,7 +17,9 @@ __all__ = [ ] @_dispatchable -def generic_bfs_edges(G, source, neighbors=None, depth_limit=None) -> Generator[tuple[Incomplete, Incomplete]]: ... +def generic_bfs_edges( + G: Graph[Incomplete], source, neighbors=None, depth_limit=None +) -> Generator[tuple[Incomplete, Incomplete]]: ... @_dispatchable def bfs_edges( G: Graph[_Node], @@ -45,6 +47,8 @@ def bfs_successors( @_dispatchable def bfs_layers(G: Graph[_Node], sources) -> Generator[Incomplete, None, None]: ... @_dispatchable -def bfs_labeled_edges(G, sources) -> Generator[tuple[Incomplete, Incomplete, Literal["tree", "level", "forward", "reverse"]]]: ... +def bfs_labeled_edges( + G: Graph[Incomplete], sources +) -> Generator[tuple[Incomplete, Incomplete, Literal["tree", "level", "forward", "reverse"]]]: ... @_dispatchable 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 f66eee33c824..4f69602e218a 100644 --- a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi @@ -25,11 +25,11 @@ def dfs_tree( @_dispatchable def dfs_predecessors( G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable[..., Incomplete] | None = None -): ... +) -> dict[Incomplete, Incomplete]: ... @_dispatchable def dfs_successors( G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable[..., Incomplete] | None = None -): ... +) -> dict[Incomplete, list[Incomplete]]: ... @_dispatchable def dfs_postorder_nodes( G: Graph[_Node], source: _Node | None = None, depth_limit=None, *, sort_neighbors: Callable[..., Incomplete] | None = None diff --git a/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi b/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi index 19c0db4ef67d..3e158e360ec1 100644 --- a/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi @@ -1,10 +1,14 @@ from _typeshed import Incomplete from collections.abc import Generator +from typing import Final from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +FORWARD: Final = "forward" +REVERSE: Final = "reverse" + __all__ = ["edge_bfs"] @_dispatchable -def edge_bfs(G: Graph[_Node], source=None, orientation=None) -> Generator[Incomplete, None, Incomplete]: ... +def edge_bfs(G: Graph[_Node], source=None, orientation=None) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi b/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi index d46c0229d271..7f2dbccf97ba 100644 --- a/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi @@ -1,10 +1,14 @@ from _typeshed import Incomplete from collections.abc import Generator +from typing import Final from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +FORWARD: Final = "forward" +REVERSE: Final = "reverse" + __all__ = ["edge_dfs"] @_dispatchable -def edge_dfs(G: Graph[_Node], source=None, orientation=None) -> Generator[Incomplete, None, Incomplete]: ... +def edge_dfs(G: Graph[_Node], source=None, orientation=None) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi index bc07c60e06eb..07c09af4b076 100644 --- a/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -1,9 +1,10 @@ from _typeshed import Incomplete -from collections.abc import Iterator from dataclasses import dataclass +from typing import Final +from typing_extensions import Self from networkx.classes.digraph import DiGraph -from networkx.classes.graph import _Node +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState @@ -18,6 +19,11 @@ __all__ = [ "ArborescenceIterator", ] +KINDS: set[str] +STYLES: dict[str, str] +INF: Final = ... + +def random_string(L=15, seed=None): ... @_dispatchable def branching_weight(G: DiGraph[_Node], attr: str = "weight", default: float = 1): ... @_dispatchable @@ -57,8 +63,14 @@ class ArborescenceIterator: partition_key: str init_partition: Incomplete - def __init__(self, G, weight: str = "weight", minimum: bool = True, init_partition: Incomplete | None = None) -> None: ... + def __init__( + self, + G: Graph[Incomplete], + weight: str = "weight", + minimum: bool = True, + init_partition: tuple[Incomplete, Incomplete] | None = None, + ) -> None: ... partition_queue: Incomplete - def __iter__(self) -> Iterator[Incomplete]: ... + def __iter__(self) -> Self: ... def __next__(self): ... diff --git a/stubs/networkx/networkx/algorithms/tree/coding.pyi b/stubs/networkx/networkx/algorithms/tree/coding.pyi index afd2ee79e2a1..78b31e7e8238 100644 --- a/stubs/networkx/networkx/algorithms/tree/coding.pyi +++ b/stubs/networkx/networkx/algorithms/tree/coding.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Iterable +from collections.abc import Collection from networkx.classes.graph import Graph, _Node from networkx.exception import NetworkXException @@ -12,8 +12,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[Incomplete], sensible_relabeling: bool = False): ... +def from_nested_tuple(sequence: Collection[Incomplete], sensible_relabeling: bool = False): ... @_dispatchable -def to_prufer_sequence(T: Graph[_Node]): ... +def to_prufer_sequence(T: Graph[_Node]) -> list[Incomplete]: ... @_dispatchable -def from_prufer_sequence(sequence: Iterable[Incomplete]): ... +def from_prufer_sequence(sequence: Collection[Incomplete]): ... diff --git a/stubs/networkx/networkx/algorithms/tree/decomposition.pyi b/stubs/networkx/networkx/algorithms/tree/decomposition.pyi index 79889442969e..21c2e0fa53f5 100644 --- a/stubs/networkx/networkx/algorithms/tree/decomposition.pyi +++ b/stubs/networkx/networkx/algorithms/tree/decomposition.pyi @@ -1,6 +1,7 @@ +from networkx import Graph from networkx.utils.backends import _dispatchable __all__ = ["junction_tree"] @_dispatchable -def junction_tree(G): ... +def junction_tree(G: Graph) -> Graph: ... diff --git a/stubs/networkx/networkx/algorithms/tree/mst.pyi b/stubs/networkx/networkx/algorithms/tree/mst.pyi index 30854ffd12e0..3b8307896840 100644 --- a/stubs/networkx/networkx/algorithms/tree/mst.pyi +++ b/stubs/networkx/networkx/algorithms/tree/mst.pyi @@ -1,8 +1,9 @@ from _typeshed import Incomplete -from collections.abc import Iterator +from collections.abc import Callable, Generator from dataclasses import dataclass from enum import Enum from typing import Literal +from typing_extensions import Self from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -25,6 +26,15 @@ class EdgePartition(Enum): INCLUDED = 1 EXCLUDED = 2 +@_dispatchable +def boruvka_mst_edges(G: Graph[Incomplete], minimum=True, weight="weight", keys=False, data=True, ignore_nan=False): ... +@_dispatchable +def kruskal_mst_edges(G: Graph[Incomplete], minimum, weight="weight", keys=True, data=True, ignore_nan=False, partition=None): ... +@_dispatchable +def prim_mst_edges(G: Graph[Incomplete], minimum, weight="weight", keys=True, data=True, ignore_nan=False): ... + +ALGORITHMS: dict[str, Callable[..., Generator[Incomplete, Incomplete, Incomplete]]] = ... + @_dispatchable def minimum_spanning_edges( G: Graph[_Node], @@ -72,7 +82,7 @@ class SpanningTreeIterator: def __init__(self, G, weight: str = "weight", minimum: bool = True, ignore_nan: bool = False) -> None: ... partition_queue: Incomplete - def __iter__(self) -> Iterator[Incomplete]: ... + def __iter__(self) -> Self: ... def __next__(self): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/triads.pyi b/stubs/networkx/networkx/algorithms/triads.pyi index 8c0c61034b7c..761e51731efb 100644 --- a/stubs/networkx/networkx/algorithms/triads.pyi +++ b/stubs/networkx/networkx/algorithms/triads.pyi @@ -1,5 +1,7 @@ from _typeshed import Incomplete +from collections import defaultdict from collections.abc import Collection, Generator +from typing import Final from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node @@ -8,17 +10,21 @@ from numpy.random import RandomState __all__ = ["triadic_census", "is_triad", "all_triplets", "all_triads", "triads_by_type", "triad_type", "random_triad"] +TRICODES: Final[tuple[int, ...]] +TRIAD_NAMES: Final[tuple[str, ...]] +TRICODE_TO_NAME: dict[int, str] + @_dispatchable -def triadic_census(G: DiGraph[_Node], nodelist: Collection[_Node] | None = None): ... +def triadic_census(G: DiGraph[_Node], nodelist: Collection[_Node] | None = None) -> dict[str, int]: ... @_dispatchable -def is_triad(G: Graph[_Node]): ... +def is_triad(G: Graph[_Node]) -> bool: ... @_dispatchable def all_triplets(G: DiGraph[_Node]): ... @_dispatchable def all_triads(G: DiGraph[_Node]) -> Generator[Incomplete, None, None]: ... @_dispatchable -def triads_by_type(G: DiGraph[_Node]): ... +def triads_by_type(G: DiGraph[_Node]) -> defaultdict[Incomplete, list[Incomplete]]: ... @_dispatchable -def triad_type(G: DiGraph[_Node]): ... +def triad_type(G: DiGraph[_Node]) -> str | None: ... @_dispatchable 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 a9b84a11c10e..571aa0d4db44 100644 --- a/stubs/networkx/networkx/algorithms/vitality.pyi +++ b/stubs/networkx/networkx/algorithms/vitality.pyi @@ -8,4 +8,4 @@ __all__ = ["closeness_vitality"] @_dispatchable def closeness_vitality( G: Graph[_Node], node: Incomplete | None = None, weight: str | None = None, wiener_index: float | None = None -): ... +) -> float | dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/voronoi.pyi b/stubs/networkx/networkx/algorithms/voronoi.pyi index cd21b3d0c246..1abe370f2087 100644 --- a/stubs/networkx/networkx/algorithms/voronoi.pyi +++ b/stubs/networkx/networkx/algorithms/voronoi.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete, SupportsGetItem -from collections.abc import Callable +from collections.abc import Callable, Collection from typing import Any from networkx.classes.graph import Graph, _Node @@ -10,6 +10,6 @@ __all__ = ["voronoi_cells"] @_dispatchable def voronoi_cells( G: Graph[_Node], - center_nodes: set[Incomplete], + center_nodes: Collection[Incomplete], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", -): ... +) -> dict[Incomplete, set[Incomplete]]: ... diff --git a/stubs/networkx/networkx/algorithms/wiener.pyi b/stubs/networkx/networkx/algorithms/wiener.pyi index 87e87f305c3a..27130c3a4389 100644 --- a/stubs/networkx/networkx/algorithms/wiener.pyi +++ b/stubs/networkx/networkx/algorithms/wiener.pyi @@ -4,7 +4,7 @@ from networkx.utils.backends import _dispatchable __all__ = ["wiener_index", "schultz_index", "gutman_index"] @_dispatchable -def wiener_index(G: Graph[_Node], weight: str | None = None): ... +def wiener_index(G: Graph[_Node], weight: str | None = None) -> float: ... @_dispatchable def schultz_index(G, weight=None) -> float: ... @_dispatchable diff --git a/stubs/networkx/networkx/classes/digraph.pyi b/stubs/networkx/networkx/classes/digraph.pyi index 281da1a62514..f74cf10d5c19 100644 --- a/stubs/networkx/networkx/classes/digraph.pyi +++ b/stubs/networkx/networkx/classes/digraph.pyi @@ -1,10 +1,20 @@ from _typeshed import Incomplete from collections.abc import Iterator from functools import cached_property +from typing_extensions import Self from networkx.classes.coreviews import AdjacencyView from networkx.classes.graph import Graph, _Node -from networkx.classes.reportviews import DiDegreeView, OutEdgeView +from networkx.classes.reportviews import ( + DiDegreeView, + InDegreeView, + InMultiDegreeView, + OutDegreeView, + OutEdgeView, + OutMultiDegreeView, +) + +__all__ = ["DiGraph"] __all__ = ["DiGraph"] @@ -16,15 +26,17 @@ class DiGraph(Graph[_Node]): def has_successor(self, u: _Node, v: _Node) -> bool: ... def has_predecessor(self, u: _Node, v: _Node) -> bool: ... def successors(self, n: _Node) -> Iterator[_Node]: ... + neighbors = successors def predecessors(self, n: _Node) -> Iterator[_Node]: ... @cached_property def out_edges(self) -> OutEdgeView[_Node]: ... @cached_property def in_edges(self) -> OutEdgeView[_Node]: ... @cached_property - def in_degree(self) -> DiDegreeView[_Node]: ... + def degree(self) -> DiDegreeView[_Node]: ... + @cached_property + def in_degree(self) -> InDegreeView[_Node] | InMultiDegreeView[_Node]: ... # Include subtypes' possible return types @cached_property - def out_degree(self) -> DiDegreeView[_Node]: ... - def to_undirected(self, reciprocal: bool = False, as_view: bool = False): ... # type: ignore[override] # Has an additional `reciprocal` keyword argument - def reverse(self, copy: bool = True) -> DiGraph[_Node]: ... - def copy(self, as_view: bool = False) -> DiGraph[_Node]: ... + def out_degree(self) -> OutDegreeView[_Node] | OutMultiDegreeView[_Node]: ... # Include subtypes' possible return types + def to_undirected(self, reciprocal: bool = False, as_view: bool = False) -> Graph[_Node]: ... # type: ignore[override] # Has an additional `reciprocal` keyword argument + def reverse(self, copy: bool = True) -> Self: ... diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index aa2d8623aec2..6bc5cc82c727 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -52,32 +52,32 @@ __all__ = [ _U = TypeVar("_U") -def nodes(G): ... -def edges(G, nbunch: Incomplete | None = None): ... -def degree(G, nbunch: Incomplete | None = None, weight: Incomplete | None = None): ... -def neighbors(G, n): ... -def number_of_nodes(G): ... -def number_of_edges(G): ... -def density(G): ... -def degree_histogram(G): ... +def nodes(G: Graph[Incomplete]): ... +def edges(G: Graph[Incomplete], nbunch: Incomplete | None = None): ... +def degree(G: Graph[Incomplete], nbunch: Incomplete | None = None, weight: Incomplete | None = None): ... +def neighbors(G: Graph[Incomplete], n): ... +def number_of_nodes(G: Graph[Incomplete]): ... +def number_of_edges(G: Graph[Incomplete]): ... +def density(G: Graph[Incomplete]): ... +def degree_histogram(G: Graph[Incomplete]) -> list[int]: ... @overload def is_directed(G: PlanarEmbedding[Hashable]) -> Literal[False]: ... # type: ignore[misc] # Incompatible return types @overload def is_directed(G: DiGraph[Hashable]) -> Literal[True]: ... # type: ignore[misc] # Incompatible return types @overload def is_directed(G: Graph[Hashable]) -> Literal[False]: ... -def freeze(G): ... -def is_frozen(G): ... +def freeze(G: Graph[Incomplete]): ... +def is_frozen(G: Graph[Incomplete]): ... def add_star(G_to_add_to, nodes_for_star, **attr) -> None: ... def add_path(G_to_add_to, nodes_for_path, **attr) -> None: ... def add_cycle(G_to_add_to, nodes_for_cycle, **attr) -> None: ... -def subgraph(G, nbunch): ... +def subgraph(G: Graph[Incomplete], nbunch: _NBunch[_Node]): ... def induced_subgraph(G: Graph[_Node], nbunch: _NBunch[_Node]) -> Graph[_Node]: ... -def edge_subgraph(G, edges): ... -def restricted_view(G, nodes, edges): ... +def edge_subgraph(G: Graph[Incomplete], edges: Iterable[Incomplete]): ... +def restricted_view(G: Graph[Incomplete], nodes: Iterable[Incomplete], edges: Iterable[Incomplete]): ... def to_directed(graph): ... def to_undirected(graph): ... -def create_empty_copy(G, with_data: bool = True): ... +def create_empty_copy(G: Graph[Incomplete], with_data: bool = True): ... # incomplete: Can "Any scalar value" be enforced? @overload @@ -104,7 +104,7 @@ def non_edges(graph: Graph[_Node]) -> Generator[tuple[_Node, _Node], None, None] def common_neighbors(G: Graph[_Node], u: _Node, v: _Node) -> Generator[_Node, None, None]: ... def is_weighted(G: Graph[_Node], edge: tuple[_Node, _Node] | None = None, weight: str = "weight") -> bool: ... @_dispatchable -def is_negatively_weighted(G: Graph[_Node], edge: tuple[_Node, _Node] | None = None, weight: str = "weight"): ... +def is_negatively_weighted(G: Graph[_Node], edge: tuple[_Node, _Node] | None = None, weight: str = "weight") -> bool: ... def is_empty(G: Graph[Hashable]) -> bool: ... def nodes_with_selfloops(G: Graph[_Node]) -> Generator[_Node, None, None]: ... @overload @@ -136,5 +136,5 @@ def selfloop_edges( G: Graph[_Node], data: str, keys: Literal[True], default: _U | None = None ) -> Generator[tuple[_Node, _Node, int, _U], None, None]: ... def number_of_selfloops(G: Graph[Hashable]) -> int: ... -def is_path(G, path) -> bool: ... -def path_weight(G, path, weight) -> int: ... +def is_path(G: Graph[Incomplete], path: Iterable[Incomplete]) -> bool: ... +def path_weight(G: Graph[Incomplete], path: Iterable[Incomplete], weight: str) -> int: ... diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi index 0679630a9c07..2e7055ced3b9 100644 --- a/stubs/networkx/networkx/classes/graph.pyi +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -7,7 +7,7 @@ from typing_extensions import Self, TypeAlias import numpy from networkx.classes.coreviews import AdjacencyView, AtlasView from networkx.classes.digraph import DiGraph -from networkx.classes.reportviews import DiDegreeView, NodeView, OutEdgeView +from networkx.classes.reportviews import DegreeView, DiDegreeView, NodeView, OutEdgeView _Node = TypeVar("_Node", bound=Hashable) _NodeWithData: TypeAlias = tuple[_Node, dict[str, Any]] @@ -48,10 +48,10 @@ class Graph(Collection[_Node]): def name(self) -> str: ... @name.setter def name(self, s: str) -> None: ... - def __getitem__(self, n: _Node) -> AtlasView[_Node, str, Any]: ... def __iter__(self) -> Iterator[_Node]: ... def __contains__(self, n: object) -> bool: ... def __len__(self) -> int: ... + def __getitem__(self, n: _Node) -> AtlasView[_Node, str, Any]: ... def add_node(self, node_for_adding: _Node, **attr: Any) -> None: ... # attr: Set or change node attributes using key=value def add_nodes_from(self, nodes_for_adding: Iterable[_NodePlus[_Node]], **attr) -> None: ... def remove_node(self, n: _Node) -> None: ... @@ -82,7 +82,7 @@ class Graph(Collection[_Node]): def get_edge_data(self, u: _Node, v: _Node, default: Incomplete | None = None) -> Mapping[str, Incomplete]: ... def adjacency(self) -> Iterator[tuple[_Node, Mapping[_Node, Mapping[str, Incomplete]]]]: ... @cached_property - def degree(self) -> DiDegreeView[_Node]: ... + def degree(self) -> DegreeView[_Node] | DiDegreeView[_Node]: ... # Include subtypes' possible return types def clear(self) -> None: ... def clear_edges(self) -> None: ... def is_multigraph(self) -> bool: ... @@ -90,7 +90,7 @@ class Graph(Collection[_Node]): def copy(self, as_view: bool = False) -> Self: ... def to_directed(self, as_view: bool = False) -> DiGraph[_Node]: ... def to_undirected(self, as_view: bool = False) -> Graph[_Node]: ... - def subgraph(self, nodes: Iterable[_Node]) -> Graph[_Node]: ... + def subgraph(self, nodes: _NBunch[_Node]) -> Graph[_Node]: ... def edge_subgraph(self, edges: Iterable[_Edge[_Node]]) -> Graph[_Node]: ... @overload def size(self, weight: None = None) -> int: ... diff --git a/stubs/networkx/networkx/classes/multidigraph.pyi b/stubs/networkx/networkx/classes/multidigraph.pyi index 0bf2f2fe87cd..66a275274bba 100644 --- a/stubs/networkx/networkx/classes/multidigraph.pyi +++ b/stubs/networkx/networkx/classes/multidigraph.pyi @@ -5,7 +5,9 @@ from networkx.classes.coreviews import MultiAdjacencyView from networkx.classes.digraph import DiGraph from networkx.classes.graph import _Node from networkx.classes.multigraph import MultiGraph -from networkx.classes.reportviews import InMultiDegreeView, OutMultiDegreeView, OutMultiEdgeView +from networkx.classes.reportviews import DiMultiDegreeView, InMultiDegreeView, OutMultiDegreeView, OutMultiEdgeView + +__all__ = ["MultiDiGraph"] __all__ = ["MultiDiGraph"] @@ -19,11 +21,11 @@ class MultiDiGraph(MultiGraph[_Node], DiGraph[_Node]): @cached_property def out_edges(self) -> OutMultiEdgeView[_Node]: ... @cached_property + def degree(self) -> DiMultiDegreeView[_Node]: ... + @cached_property def in_edges(self) -> OutMultiEdgeView[_Node]: ... @cached_property def in_degree(self) -> InMultiDegreeView[_Node]: ... @cached_property def out_degree(self) -> OutMultiDegreeView[_Node]: ... def to_undirected(self, reciprocal: bool = False, as_view: bool = False) -> MultiGraph[_Node]: ... # type: ignore[override] - def reverse(self, copy: bool = True) -> MultiDiGraph[_Node]: ... - def copy(self, as_view: bool = False) -> MultiDiGraph[_Node]: ... diff --git a/stubs/networkx/networkx/classes/multigraph.pyi b/stubs/networkx/networkx/classes/multigraph.pyi index 1fce3b56522e..48d5435f345f 100644 --- a/stubs/networkx/networkx/classes/multigraph.pyi +++ b/stubs/networkx/networkx/classes/multigraph.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Mapping from functools import cached_property from typing import ClassVar from typing_extensions import TypeAlias @@ -6,7 +7,7 @@ from typing_extensions import TypeAlias from networkx.classes.coreviews import MultiAdjacencyView from networkx.classes.graph import Graph, _MapFactory, _Node from networkx.classes.multidigraph import MultiDiGraph -from networkx.classes.reportviews import OutMultiEdgeView +from networkx.classes.reportviews import DiMultiDegreeView, MultiDegreeView, MultiEdgeView, OutMultiEdgeView _MultiEdge: TypeAlias = tuple[_Node, _Node, int] # noqa: Y047 @@ -14,19 +15,21 @@ __all__ = ["MultiGraph"] class MultiGraph(Graph[_Node]): edge_key_dict_factory: ClassVar[_MapFactory] + def to_directed_class(self) -> type[MultiDiGraph[_Node]]: ... + def to_undirected_class(self) -> type[MultiGraph[_Node]]: ... def __init__(self, incoming_graph_data: Incomplete | None = None, multigraph_input: bool | None = None, **attr) -> None: ... @cached_property def adj(self) -> MultiAdjacencyView[_Node, _Node, dict[str, Incomplete]]: ... def new_edge_key(self, u: _Node, v: _Node) -> int: ... def add_edge(self, u_for_edge, v_for_edge, key: Incomplete | None = None, **attr): ... # type: ignore[override] # Has an additional `key` keyword argument def remove_edge(self, u, v, key: Incomplete | None = None): ... - def has_edge(self, u, v, key: Incomplete | None = None): ... + def has_edge(self, u, v, key: Incomplete | None = None) -> bool: ... + @cached_property + def edges(self) -> MultiEdgeView[_Node] | OutMultiEdgeView[_Node]: ... # Include subtypes' possible return types def get_edge_data( # type: ignore[override] # Has an additional `key` keyword argument self, u, v, key: Incomplete | None = None, default: Incomplete | None = None - ): ... - def copy(self, as_view: bool = False) -> MultiGraph[_Node]: ... + ) -> Mapping[str, Incomplete]: ... + @cached_property + def degree(self) -> MultiDegreeView[_Node] | DiMultiDegreeView[_Node]: ... # Include subtypes' possible return types def to_directed(self, as_view: bool = False) -> MultiDiGraph[_Node]: ... def to_undirected(self, as_view: bool = False) -> MultiGraph[_Node]: ... - def number_of_edges(self, u: _Node | None = None, v: _Node | None = None) -> int: ... - @cached_property - def edges(self) -> OutMultiEdgeView[_Node]: ... diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index 0337ba24c45d..44ad01a7eda0 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -206,6 +206,7 @@ class InEdgeView(OutEdgeView[_Node]): ) -> InEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... class OutMultiEdgeView(OutEdgeView[_Node]): + dataview: type[OutMultiEdgeDataView | MultiEdgeDataView | InMultiEdgeDataView] # Include subtypes' possible types def __iter__(self) -> Iterator[tuple[_Node, _Node, Incomplete]]: ... # type: ignore[override] def __getitem__(self, e: tuple[_Node, _Node, Incomplete]) -> dict[str, Any]: ... # type: ignore[override] dataview = OutMultiEdgeDataView diff --git a/stubs/networkx/networkx/convert.pyi b/stubs/networkx/networkx/convert.pyi index a85a117a939c..170c3765420d 100644 --- a/stubs/networkx/networkx/convert.pyi +++ b/stubs/networkx/networkx/convert.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Callable, Collection, Iterable +from collections.abc import Callable, Collection, Iterable, Mapping from networkx.classes.graph import Graph, _Data, _Node from networkx.utils.backends import _dispatchable @@ -25,7 +25,9 @@ def to_dict_of_dicts( G: Graph[_Node], nodelist: Collection[_Node] | None = None, edge_data=None ) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def from_dict_of_dicts(d, create_using=None, multigraph_input=False) -> Graph[Incomplete]: ... +def from_dict_of_dicts( + d: Mapping[Incomplete, Mapping[Incomplete, Incomplete]], create_using=None, multigraph_input=False +) -> Graph[Incomplete]: ... @_dispatchable def to_edgelist(G: Graph[_Node], nodelist: Collection[_Node] | None = None): ... @_dispatchable diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index 2cc8aab6e8b6..6a9ab69c2460 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -80,9 +80,9 @@ def from_pandas_edgelist( edge_key: str | None = None, ) -> Graph[Incomplete]: ... @_dispatchable -def to_scipy_sparse_array(G, nodelist=None, dtype=None, weight="weight", format="csr"): ... +def to_scipy_sparse_array(G: Graph, nodelist: Collection[_Node] | None = None, dtype=None, weight="weight", format="csr"): ... @_dispatchable -def from_scipy_sparse_array(A, parallel_edges=False, create_using=None, edge_attribute="weight"): ... +def from_scipy_sparse_array(A, parallel_edges: bool = False, create_using=None, edge_attribute: str = "weight"): ... @_dispatchable def to_numpy_array( G: Graph[_Node], diff --git a/stubs/networkx/networkx/drawing/layout.pyi b/stubs/networkx/networkx/drawing/layout.pyi index fae316ed4d09..68cb019b0634 100644 --- a/stubs/networkx/networkx/drawing/layout.pyi +++ b/stubs/networkx/networkx/drawing/layout.pyi @@ -1,6 +1,9 @@ from _typeshed import Incomplete import numpy +from numpy.typing import ArrayLike + +from ..classes.graph import Graph __all__ = [ "bipartite_layout", @@ -21,21 +24,30 @@ __all__ = [ "arf_layout", ] -def random_layout(G, center: Incomplete | None = None, dim: int = 2, seed: Incomplete | None = None): ... -def circular_layout(G, scale: float = 1, center: Incomplete | None = None, dim: int = 2): ... +def random_layout( + G: Graph[Incomplete], center: ArrayLike | None = None, dim: int = 2, seed: Incomplete | None = None +) -> dict[Incomplete, Incomplete]: ... +def circular_layout( + G: Graph[Incomplete], scale: float = 1, center: ArrayLike | None = None, dim: int = 2 +) -> dict[Incomplete, Incomplete]: ... def shell_layout( - G, + G: Graph[Incomplete], nlist: Incomplete | None = None, rotate: Incomplete | None = None, scale: float = 1, - center: Incomplete | None = None, + center: ArrayLike | None = None, dim: int = 2, -): ... +) -> dict[Incomplete, Incomplete]: ... def bipartite_layout( - G, nodes, align: str = "vertical", scale: float = 1, center: Incomplete | None = None, aspect_ratio: float = ... -): ... + G: Graph[Incomplete], + nodes, + align: str = "vertical", + scale: float = 1, + center: ArrayLike | None = None, + aspect_ratio: float = ..., +) -> dict[Incomplete, Incomplete]: ... def spring_layout( - G, + G: Graph[Incomplete], k: Incomplete | None = None, pos: Incomplete | None = None, fixed: Incomplete | None = None, @@ -43,32 +55,41 @@ def spring_layout( threshold: float = 0.0001, weight: str = "weight", scale: float = 1, - center: Incomplete | None = None, + center: ArrayLike | None = None, dim: int = 2, seed: Incomplete | None = None, -): ... +) -> dict[Incomplete, Incomplete]: ... fruchterman_reingold_layout = spring_layout def kamada_kawai_layout( - G, + G: Graph[Incomplete], dist: Incomplete | None = None, pos: Incomplete | None = None, weight: str = "weight", scale: float = 1, - center: Incomplete | None = None, + center: ArrayLike | None = None, dim: int = 2, -): ... -def spectral_layout(G, weight: str = "weight", scale: float = 1, center: Incomplete | None = None, dim: int = 2): ... -def planar_layout(G, scale: float = 1, center: Incomplete | None = None, dim: int = 2): ... +) -> dict[Incomplete, Incomplete]: ... +def spectral_layout( + G: Graph[Incomplete], weight: str = "weight", scale: float = 1, center: ArrayLike | None = None, dim: int = 2 +) -> dict[Incomplete, Incomplete]: ... +def planar_layout( + G: Graph[Incomplete], scale: float = 1, center: ArrayLike | None = None, dim: int = 2 +) -> dict[Incomplete, Incomplete]: ... def spiral_layout( - G, scale: float = 1, center: Incomplete | None = None, dim: int = 2, resolution: float = 0.35, equidistant: bool = False -): ... + G: Graph[Incomplete], + scale: float = 1, + center: ArrayLike | None = None, + dim: int = 2, + resolution: float = 0.35, + equidistant: bool = False, +) -> dict[Incomplete, Incomplete]: ... def multipartite_layout( - G, subset_key: str = "subset", align: str = "vertical", scale: float = 1, center: Incomplete | None = None -): ... + G: Graph[Incomplete], subset_key: str = "subset", align: str = "vertical", scale: float = 1, center: ArrayLike | None = None +) -> dict[Incomplete, Incomplete]: ... def arf_layout( - G, + G: Graph[Incomplete], pos: Incomplete | None = None, scaling: float = 1, a: float = 1.1, diff --git a/stubs/networkx/networkx/drawing/nx_agraph.pyi b/stubs/networkx/networkx/drawing/nx_agraph.pyi index 0c744f10e408..d025372bf85d 100644 --- a/stubs/networkx/networkx/drawing/nx_agraph.pyi +++ b/stubs/networkx/networkx/drawing/nx_agraph.pyi @@ -6,6 +6,7 @@ from typing_extensions import TypeAlias from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable +__all__ = ["from_agraph", "to_agraph", "write_dot", "read_dot", "graphviz_layout", "pygraphviz_layout", "view_pygraphviz"] # from pygraphviz.agraph import AGraph as _AGraph _AGraph: TypeAlias = Incomplete diff --git a/stubs/networkx/networkx/drawing/nx_pydot.pyi b/stubs/networkx/networkx/drawing/nx_pydot.pyi index dbb039f03b56..d36a968f6409 100644 --- a/stubs/networkx/networkx/drawing/nx_pydot.pyi +++ b/stubs/networkx/networkx/drawing/nx_pydot.pyi @@ -2,13 +2,15 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["write_dot", "read_dot", "graphviz_layout", "pydot_layout", "to_pydot", "from_pydot"] -def write_dot(G, path) -> None: ... +def write_dot(G: Graph[Incomplete], path) -> None: ... @_dispatchable -def read_dot(path): ... +def read_dot(path) -> Graph[Incomplete]: ... @_dispatchable def from_pydot(P): ... def to_pydot(N): ... -def graphviz_layout(G, prog: str = "neato", root: Incomplete | None = None): ... -def pydot_layout(G, prog: str = "neato", root: Incomplete | None = None): ... +def graphviz_layout(G: Graph[Incomplete], prog: str = "neato", root: Incomplete | None = None): ... +def pydot_layout(G: Graph[Incomplete], prog: str = "neato", root: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/drawing/nx_pylab.pyi b/stubs/networkx/networkx/drawing/nx_pylab.pyi index 9ed051b6707b..0ce9242baa8c 100644 --- a/stubs/networkx/networkx/drawing/nx_pylab.pyi +++ b/stubs/networkx/networkx/drawing/nx_pylab.pyi @@ -1,5 +1,7 @@ from _typeshed import Incomplete -from collections.abc import Collection +from collections.abc import Collection, Iterable, Mapping + +from ..classes.graph import Graph __all__ = [ "draw", @@ -18,13 +20,13 @@ __all__ = [ "draw_forceatlas2", ] -def draw(G, pos: Incomplete | None = None, ax: Incomplete | None = None, **kwds) -> None: ... +def draw(G: Graph[Incomplete], pos: Incomplete | None = None, ax: Incomplete | None = None, **kwds) -> None: ... def draw_networkx( - G, pos: Incomplete | None = None, arrows: Incomplete | None = None, with_labels: bool = True, **kwds + G: Graph[Incomplete], pos: Incomplete | None = None, arrows: Incomplete | None = None, with_labels: bool = True, **kwds ) -> None: ... def draw_networkx_nodes( - G, - pos, + G: Graph[Incomplete], + pos: Mapping[Incomplete, Incomplete], nodelist: Collection[Incomplete] | None = None, node_size: Incomplete | int = 300, node_color: str = "#1f78b4", @@ -41,8 +43,8 @@ def draw_networkx_nodes( hide_ticks: bool = True, ): ... def draw_networkx_edges( - G, - pos, + G: Graph[Incomplete], + pos: Mapping[Incomplete, Incomplete], edgelist: Incomplete | None = None, width: float = 1.0, edge_color: str = "k", @@ -51,8 +53,8 @@ def draw_networkx_edges( arrowstyle: Incomplete | None = None, arrowsize: int = 10, edge_cmap: Incomplete | None = None, - edge_vmin: Incomplete | None = None, - edge_vmax: Incomplete | None = None, + edge_vmin: float | None = None, + edge_vmax: float | None = None, ax: Incomplete | None = None, arrows: Incomplete | None = None, label: Incomplete | None = None, @@ -65,8 +67,8 @@ def draw_networkx_edges( hide_ticks: bool = True, ): ... def draw_networkx_labels( - G, - pos, + G: Graph[Incomplete], + pos: Mapping[Incomplete, Incomplete], labels: Incomplete | None = None, font_size: int = 12, font_color: str = "k", @@ -81,8 +83,8 @@ def draw_networkx_labels( hide_ticks: bool = True, ): ... def draw_networkx_edge_labels( - G, - pos, + G: Graph[Incomplete], + pos: Mapping[Incomplete, Incomplete], edge_labels: Incomplete | None = None, label_pos: float = 0.5, font_size: int = 10, @@ -101,11 +103,14 @@ def draw_networkx_edge_labels( connectionstyle: str = "arc3", hide_ticks: bool = True, ): ... -def draw_circular(G, **kwargs) -> None: ... -def draw_kamada_kawai(G, **kwargs) -> None: ... -def draw_random(G, **kwargs) -> None: ... -def draw_spectral(G, **kwargs) -> None: ... -def draw_spring(G, **kwargs) -> None: ... -def draw_shell(G, nlist: Incomplete | None = None, **kwargs) -> None: ... -def draw_planar(G, **kwargs) -> None: ... +def draw_circular(G: Graph[Incomplete], **kwargs) -> None: ... +def draw_kamada_kawai(G: Graph[Incomplete], **kwargs) -> None: ... +def draw_random(G: Graph[Incomplete], **kwargs) -> None: ... +def draw_spectral(G: Graph[Incomplete], **kwargs) -> None: ... +def draw_spring(G: Graph[Incomplete], **kwargs) -> None: ... +def draw_shell(G: Graph[Incomplete], nlist: Incomplete | None = None, **kwargs) -> None: ... +def draw_planar(G: Graph[Incomplete], **kwargs) -> None: ... def draw_forceatlas2(G, **kwargs) -> None: ... +def apply_alpha( + colors, alpha: float | Iterable[float], elem_list, cmap=None, vmin: float | None = None, vmax: float | None = None +): ... diff --git a/stubs/networkx/networkx/generators/atlas.pyi b/stubs/networkx/networkx/generators/atlas.pyi index 4fffc13ca131..76d64d323f64 100644 --- a/stubs/networkx/networkx/generators/atlas.pyi +++ b/stubs/networkx/networkx/generators/atlas.pyi @@ -1,8 +1,18 @@ +from _typeshed import Incomplete +from importlib.abc import Traversable +from typing import Final + from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["graph_atlas", "graph_atlas_g"] +NUM_GRAPHS: Final = 1253 + +ATLAS_FILE: Traversable + @_dispatchable -def graph_atlas(i): ... +def graph_atlas(i: int) -> Graph[Incomplete]: ... @_dispatchable -def graph_atlas_g(): ... +def graph_atlas_g() -> list[Graph[Incomplete]]: ... diff --git a/stubs/networkx/networkx/generators/classic.pyi b/stubs/networkx/networkx/generators/classic.pyi index 99b8a6d8413b..fd4e470a9bf1 100644 --- a/stubs/networkx/networkx/generators/classic.pyi +++ b/stubs/networkx/networkx/generators/classic.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Iterable from networkx.classes import Graph from networkx.utils.backends import _dispatchable @@ -28,15 +29,15 @@ __all__ = [ ] @_dispatchable -def full_rary_tree(r, n, create_using: Incomplete | None = None): ... +def full_rary_tree(r: int, n: int, create_using: Incomplete | None = None): ... @_dispatchable def kneser_graph(n, k) -> Graph[Incomplete]: ... @_dispatchable -def balanced_tree(r, h, create_using: Incomplete | None = None): ... +def balanced_tree(r: int, h: int, create_using: Incomplete | None = None): ... @_dispatchable def barbell_graph(m1, m2, create_using: Incomplete | None = None): ... @_dispatchable -def binomial_tree(n, create_using: Incomplete | None = None): ... +def binomial_tree(n: int, create_using: Incomplete | None = None): ... @_dispatchable def complete_graph(n, create_using: Incomplete | None = None): ... @_dispatchable @@ -48,7 +49,7 @@ def cycle_graph(n, create_using: Incomplete | None = None): ... @_dispatchable def dorogovtsev_goltsev_mendes_graph(n, create_using: Incomplete | None = None): ... @_dispatchable -def empty_graph(n: Incomplete | int = 0, create_using: Incomplete | None = None, default=...): ... +def empty_graph(n: int | Iterable[Incomplete] = 0, create_using: Incomplete | None = None, default=...): ... @_dispatchable def ladder_graph(n, create_using: Incomplete | None = None): ... @_dispatchable @@ -56,16 +57,16 @@ def lollipop_graph(m, n, create_using: Incomplete | None = None): ... @_dispatchable def null_graph(create_using: Incomplete | None = None): ... @_dispatchable -def path_graph(n, create_using: Incomplete | None = None): ... +def path_graph(n: int | Iterable[Incomplete], create_using: Incomplete | None = None): ... @_dispatchable -def star_graph(n, create_using: Incomplete | None = None): ... +def star_graph(n: int | Iterable[Incomplete], create_using: Incomplete | None = None): ... @_dispatchable def tadpole_graph(m, n, create_using=None) -> Graph[Incomplete] | Incomplete: ... @_dispatchable def trivial_graph(create_using: Incomplete | None = None): ... @_dispatchable -def turan_graph(n, r): ... +def turan_graph(n: int, r: int): ... @_dispatchable -def wheel_graph(n, create_using: Incomplete | None = None): ... +def wheel_graph(n: int | Iterable[Incomplete], create_using: Incomplete | None = None): ... @_dispatchable def complete_multipartite_graph(*subset_sizes): ... diff --git a/stubs/networkx/networkx/generators/cographs.pyi b/stubs/networkx/networkx/generators/cographs.pyi index a3081cae6274..2b37b256787b 100644 --- a/stubs/networkx/networkx/generators/cographs.pyi +++ b/stubs/networkx/networkx/generators/cographs.pyi @@ -5,4 +5,4 @@ from networkx.utils.backends import _dispatchable __all__ = ["random_cograph"] @_dispatchable -def random_cograph(n, seed: Incomplete | None = None): ... +def random_cograph(n: int, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/community.pyi b/stubs/networkx/networkx/generators/community.pyi index d95c6eeee30b..b43955a9528c 100644 --- a/stubs/networkx/networkx/generators/community.pyi +++ b/stubs/networkx/networkx/generators/community.pyi @@ -17,24 +17,26 @@ __all__ = [ ] @_dispatchable -def caveman_graph(l, k): ... +def caveman_graph(l: int, k: int): ... @_dispatchable -def connected_caveman_graph(l, k): ... +def connected_caveman_graph(l: int, k: int): ... @_dispatchable -def relaxed_caveman_graph(l, k, p, seed: Incomplete | None = None): ... +def relaxed_caveman_graph(l: int, k: int, p: float, seed: Incomplete | None = None): ... @_dispatchable -def random_partition_graph(sizes, p_in, p_out, seed: Incomplete | None = None, directed: bool = False): ... +def random_partition_graph(sizes: Collection[int], p_in: float, p_out: float, seed: Incomplete | None = None, directed=False): ... @_dispatchable -def planted_partition_graph(l, k, p_in, p_out, seed: Incomplete | None = None, directed: bool = False): ... +def planted_partition_graph(l: int, k: int, p_in: float, p_out: float, seed: Incomplete | None = None, directed=False): ... @_dispatchable -def gaussian_random_partition_graph(n, s, v, p_in, p_out, directed: bool = False, seed: Incomplete | None = None): ... +def gaussian_random_partition_graph( + n: int, s: float, v: float, p_in: float, p_out: float, directed=False, seed: Incomplete | None = None +): ... @_dispatchable -def ring_of_cliques(num_cliques, clique_size): ... +def ring_of_cliques(num_cliques: int, clique_size: int): ... @_dispatchable -def windmill_graph(n, k): ... +def windmill_graph(n: int, k: int): ... @_dispatchable def stochastic_block_model( - sizes, + sizes: Collection[int], p, nodelist: Collection[Incomplete] | None = None, seed: Incomplete | None = None, @@ -44,16 +46,16 @@ def stochastic_block_model( ): ... @_dispatchable def LFR_benchmark_graph( - n, - tau1, - tau2, - mu, - average_degree: Incomplete | None = None, - min_degree: Incomplete | None = None, - max_degree: Incomplete | None = None, - min_community: Incomplete | None = None, - max_community: Incomplete | None = None, - tol: float = 1e-07, + n: int, + tau1: float, + tau2: float, + mu: float, + average_degree: float | None = None, + min_degree: int | None = None, + max_degree: int | None = None, + min_community: int | None = None, + max_community: int | None = None, + tol: float = 1.0e-7, max_iters: int = 500, seed: Incomplete | None = None, ): ... diff --git a/stubs/networkx/networkx/generators/degree_seq.pyi b/stubs/networkx/networkx/generators/degree_seq.pyi index b24d74eea48e..3395239f0166 100644 --- a/stubs/networkx/networkx/generators/degree_seq.pyi +++ b/stubs/networkx/networkx/generators/degree_seq.pyi @@ -1,7 +1,14 @@ from _typeshed import Incomplete +from collections.abc import Collection +from itertools import chain from networkx.utils.backends import _dispatchable +from ..classes.digraph import DiGraph +from ..classes.graph import Graph +from ..classes.multidigraph import MultiDiGraph +from ..classes.multigraph import MultiGraph + __all__ = [ "configuration_model", "directed_configuration_model", @@ -11,23 +18,28 @@ __all__ = [ "degree_sequence_tree", "random_degree_sequence_graph", ] +chaini = chain.from_iterable @_dispatchable -def configuration_model(deg_sequence, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... +def configuration_model( + deg_sequence, create_using: Incomplete | None = None, seed: Incomplete | None = None +) -> MultiGraph[Incomplete]: ... @_dispatchable def directed_configuration_model( in_degree_sequence, out_degree_sequence, create_using: Incomplete | None = None, seed: Incomplete | None = None -): ... +) -> MultiDiGraph[Incomplete]: ... @_dispatchable -def expected_degree_graph(w, seed: Incomplete | None = None, selfloops: bool = True): ... +def expected_degree_graph(w: Collection[float], seed: Incomplete | None = None, selfloops: bool = True) -> Graph[Incomplete]: ... @_dispatchable def havel_hakimi_graph(deg_sequence, create_using: Incomplete | None = None): ... @_dispatchable -def directed_havel_hakimi_graph(in_deg_sequence, out_deg_sequence, create_using: Incomplete | None = None): ... +def directed_havel_hakimi_graph( + in_deg_sequence, out_deg_sequence, create_using: Incomplete | None = None +) -> DiGraph[Incomplete]: ... @_dispatchable def degree_sequence_tree(deg_sequence, create_using: Incomplete | None = None): ... @_dispatchable -def random_degree_sequence_graph(sequence, seed: Incomplete | None = None, tries: int = 10): ... +def random_degree_sequence_graph(sequence, seed: Incomplete | None = None, tries: int = 10) -> Graph[Incomplete]: ... class DegreeSequenceRandomGraph: rng: Incomplete diff --git a/stubs/networkx/networkx/generators/directed.pyi b/stubs/networkx/networkx/generators/directed.pyi index bb8f174dcde3..dcbe9016e918 100644 --- a/stubs/networkx/networkx/generators/directed.pyi +++ b/stubs/networkx/networkx/generators/directed.pyi @@ -2,14 +2,18 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable +from ..classes import MultiDiGraph + __all__ = ["gn_graph", "gnc_graph", "gnr_graph", "random_k_out_graph", "scale_free_graph"] @_dispatchable -def gn_graph(n, kernel: Incomplete | None = None, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... +def gn_graph( + n: int, kernel: Incomplete | None = None, create_using: Incomplete | None = None, seed: Incomplete | None = None +): ... @_dispatchable -def gnr_graph(n, p, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... +def gnr_graph(n: int, p: float, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... @_dispatchable -def gnc_graph(n, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... +def gnc_graph(n: int, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... @_dispatchable def scale_free_graph( n, @@ -23,4 +27,6 @@ def scale_free_graph( initial_graph: Incomplete | None = None, ): ... @_dispatchable -def random_k_out_graph(n, k, alpha, self_loops: bool = True, seed: Incomplete | None = None): ... +def random_uniform_k_out_graph(n: int, k: int, self_loops: bool = True, with_replacement: bool = True, seed=None): ... +@_dispatchable +def random_k_out_graph(n: int, k: int, alpha: float, self_loops: bool = True, seed: Incomplete | None = None) -> MultiDiGraph: ... diff --git a/stubs/networkx/networkx/generators/duplication.pyi b/stubs/networkx/networkx/generators/duplication.pyi index 4b62c92c75e2..1f72a298ff89 100644 --- a/stubs/networkx/networkx/generators/duplication.pyi +++ b/stubs/networkx/networkx/generators/duplication.pyi @@ -2,9 +2,11 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["partial_duplication_graph", "duplication_divergence_graph"] @_dispatchable -def partial_duplication_graph(N, n, p, q, seed: Incomplete | None = None): ... +def partial_duplication_graph(N: int, n: int, p: float, q: float, seed: Incomplete | None = None): ... @_dispatchable -def duplication_divergence_graph(n, p, seed: Incomplete | None = None): ... +def duplication_divergence_graph(n: int, p: float, seed: Incomplete | None = None) -> Graph[Incomplete]: ... diff --git a/stubs/networkx/networkx/generators/ego.pyi b/stubs/networkx/networkx/generators/ego.pyi index 83725a552c50..04a8ad211625 100644 --- a/stubs/networkx/networkx/generators/ego.pyi +++ b/stubs/networkx/networkx/generators/ego.pyi @@ -2,7 +2,11 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["ego_graph"] @_dispatchable -def ego_graph(G, n, radius: float = 1, center: bool = True, undirected: bool = False, distance: Incomplete | None = None): ... +def ego_graph( + G: Graph[Incomplete], n, radius: float = 1, center: bool = True, undirected: bool = False, distance: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/generators/expanders.pyi b/stubs/networkx/networkx/generators/expanders.pyi index f59596b797b2..4f3c87ee6e16 100644 --- a/stubs/networkx/networkx/generators/expanders.pyi +++ b/stubs/networkx/networkx/generators/expanders.pyi @@ -12,7 +12,7 @@ __all__ = [ ] @_dispatchable -def margulis_gabber_galil_graph(n, create_using: Incomplete | None = None): ... +def margulis_gabber_galil_graph(n: int, create_using: Incomplete | None = None): ... @_dispatchable def chordal_cycle_graph(p, create_using: Incomplete | None = None): ... @_dispatchable diff --git a/stubs/networkx/networkx/generators/geometric.pyi b/stubs/networkx/networkx/generators/geometric.pyi index abaaba251721..023b80e76bf5 100644 --- a/stubs/networkx/networkx/generators/geometric.pyi +++ b/stubs/networkx/networkx/generators/geometric.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Iterable, Mapping from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable @@ -15,54 +16,59 @@ __all__ = [ ] @_dispatchable -def geometric_edges(G, radius, p: float = 2): ... +def geometric_edges(G, radius: float, p: float = 2): ... @_dispatchable def random_geometric_graph( - n, radius, dim: int = 2, pos: Incomplete | None = None, p: float = 2, seed: Incomplete | None = None + n: int | Iterable[Incomplete], + radius: float, + dim: int = 2, + pos: Mapping[Incomplete, Incomplete] | None = None, + p: float = 2, + seed: Incomplete | None = None, ): ... @_dispatchable def soft_random_geometric_graph( - n, - radius, + n: int | Iterable[Incomplete], + radius: float, dim: int = 2, - pos: Incomplete | None = None, + pos: Mapping[Incomplete, Incomplete] | None = None, p: float = 2, p_dist: Incomplete | None = None, seed: Incomplete | None = None, ): ... @_dispatchable def geographical_threshold_graph( - n, + n: int | Iterable[Incomplete], theta, dim: int = 2, - pos: Incomplete | None = None, - weight: Incomplete | None = None, + pos: Mapping[Incomplete, Incomplete] | None = None, + weight: Mapping[Incomplete, Incomplete] | None = None, metric: Incomplete | None = None, p_dist: Incomplete | None = None, seed: Incomplete | None = None, ): ... @_dispatchable def waxman_graph( - n, + n: int | Iterable[Incomplete], beta: float = 0.4, alpha: float = 0.1, - L: Incomplete | None = None, + L: float | None = None, domain=(0, 0, 1, 1), metric: Incomplete | None = None, seed: Incomplete | None = None, -): ... +) -> Graph[Incomplete]: ... # docstring marks p as int, but it still works with floats. So I think it's better for consistency @_dispatchable -def navigable_small_world_graph(n, p: float = 1, q: int = 1, r: float = 2, dim: int = 2, seed: Incomplete | None = None): ... +def navigable_small_world_graph(n: int, p: float = 1, q: int = 1, r: float = 2, dim: int = 2, seed: Incomplete | None = None): ... @_dispatchable def thresholded_random_geometric_graph( - n, - radius, - theta, + n: int | Iterable[Incomplete], + radius: float, + theta: float, dim: int = 2, - pos: Incomplete | None = None, - weight: Incomplete | None = None, + pos: Mapping[Incomplete, Incomplete] | None = None, + weight: Mapping[Incomplete, Incomplete] | None = None, p: float = 2, seed: Incomplete | None = None, ): ... diff --git a/stubs/networkx/networkx/generators/internet_as_graphs.pyi b/stubs/networkx/networkx/generators/internet_as_graphs.pyi index 8c9542f45480..4f525f03405d 100644 --- a/stubs/networkx/networkx/generators/internet_as_graphs.pyi +++ b/stubs/networkx/networkx/generators/internet_as_graphs.pyi @@ -1,9 +1,13 @@ from _typeshed import Incomplete +from collections.abc import Mapping from networkx.utils.backends import _dispatchable __all__ = ["random_internet_as_graph"] +def uniform_int_from_avg(a, m, seed): ... +def choose_pref_attach(degs: Mapping[Incomplete, Incomplete], seed): ... + class AS_graph_generator: seed: Incomplete n_t: Incomplete @@ -26,9 +30,9 @@ class AS_graph_generator: def choose_peer_pref_attach(self, node_list): ... def choose_node_pref_attach(self, node_list): ... def add_customer(self, i, j) -> None: ... - def add_node(self, i, kind, reg2prob, avg_deg, t_edge_prob): ... - def add_m_peering_link(self, m, to_kind): ... - def add_cp_peering_link(self, cp, to_kind): ... + def add_node(self, i, kind: str, reg2prob: float, avg_deg: float, t_edge_prob: float): ... + def add_m_peering_link(self, m, to_kind: str) -> bool: ... + def add_cp_peering_link(self, cp, to_kind: str) -> bool: ... regions: Incomplete def graph_regions(self, rn) -> None: ... def add_peering_links(self, from_kind, to_kind) -> None: ... diff --git a/stubs/networkx/networkx/generators/intersection.pyi b/stubs/networkx/networkx/generators/intersection.pyi index 73a5a7528c22..f969f7707a4b 100644 --- a/stubs/networkx/networkx/generators/intersection.pyi +++ b/stubs/networkx/networkx/generators/intersection.pyi @@ -5,8 +5,8 @@ from networkx.utils.backends import _dispatchable __all__ = ["uniform_random_intersection_graph", "k_random_intersection_graph", "general_random_intersection_graph"] @_dispatchable -def uniform_random_intersection_graph(n, m, p, seed: Incomplete | None = None): ... +def uniform_random_intersection_graph(n: int, m: int, p: float, seed: Incomplete | None = None): ... @_dispatchable -def k_random_intersection_graph(n, m, k, seed: Incomplete | None = None): ... +def k_random_intersection_graph(n: int, m: int, k: float, seed: Incomplete | None = None): ... @_dispatchable -def general_random_intersection_graph(n, m, p, seed: Incomplete | None = None): ... +def general_random_intersection_graph(n: int, m: int, p, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/joint_degree_seq.pyi b/stubs/networkx/networkx/generators/joint_degree_seq.pyi index b9f976ac343b..3a291152db67 100644 --- a/stubs/networkx/networkx/generators/joint_degree_seq.pyi +++ b/stubs/networkx/networkx/generators/joint_degree_seq.pyi @@ -2,13 +2,15 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["is_valid_joint_degree", "is_valid_directed_joint_degree", "joint_degree_graph", "directed_joint_degree_graph"] @_dispatchable -def is_valid_joint_degree(joint_degrees): ... +def is_valid_joint_degree(joint_degrees) -> bool: ... @_dispatchable -def joint_degree_graph(joint_degrees, seed: Incomplete | None = None): ... +def joint_degree_graph(joint_degrees, seed: Incomplete | None = None) -> Graph[Incomplete]: ... @_dispatchable -def is_valid_directed_joint_degree(in_degrees, out_degrees, nkk): ... +def is_valid_directed_joint_degree(in_degrees, out_degrees, nkk) -> bool: ... @_dispatchable -def directed_joint_degree_graph(in_degrees, out_degrees, nkk, seed: Incomplete | None = None): ... +def directed_joint_degree_graph(in_degrees, out_degrees, nkk, seed: Incomplete | None = None) -> Graph[Incomplete]: ... diff --git a/stubs/networkx/networkx/generators/lattice.pyi b/stubs/networkx/networkx/generators/lattice.pyi index 29d8e5fa972f..5825351e2b6b 100644 --- a/stubs/networkx/networkx/generators/lattice.pyi +++ b/stubs/networkx/networkx/generators/lattice.pyi @@ -1,20 +1,21 @@ from _typeshed import Incomplete +from collections.abc import Iterable from networkx.utils.backends import _dispatchable __all__ = ["grid_2d_graph", "grid_graph", "hypercube_graph", "triangular_lattice_graph", "hexagonal_lattice_graph"] @_dispatchable -def grid_2d_graph(m, n, periodic: bool = False, create_using: Incomplete | None = None): ... +def grid_2d_graph(m, n, periodic: bool | tuple[bool, bool] = False, create_using: Incomplete | None = None): ... @_dispatchable -def grid_graph(dim, periodic: bool = False): ... +def grid_graph(dim, periodic: bool | Iterable[bool] = False): ... @_dispatchable def hypercube_graph(n): ... @_dispatchable def triangular_lattice_graph( - m, n, periodic: bool = False, with_positions: bool = True, create_using: Incomplete | None = None + m: int, n: int, periodic: bool = False, with_positions: bool = True, create_using: Incomplete | None = None ): ... @_dispatchable def hexagonal_lattice_graph( - m, n, periodic: bool = False, with_positions: bool = True, create_using: Incomplete | None = None + m: int, n: int, periodic: bool = False, with_positions: bool = True, create_using: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/generators/line.pyi b/stubs/networkx/networkx/generators/line.pyi index 01a36dc8312f..e6f4b397eb5d 100644 --- a/stubs/networkx/networkx/generators/line.pyi +++ b/stubs/networkx/networkx/generators/line.pyi @@ -2,9 +2,11 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["line_graph", "inverse_line_graph"] @_dispatchable -def line_graph(G, create_using: Incomplete | None = None): ... +def line_graph(G: Graph[Incomplete], create_using: Incomplete | None = None): ... @_dispatchable -def inverse_line_graph(G): ... +def inverse_line_graph(G: Graph[Incomplete]): ... diff --git a/stubs/networkx/networkx/generators/mycielski.pyi b/stubs/networkx/networkx/generators/mycielski.pyi index cc40796b7627..cd58d6f51116 100644 --- a/stubs/networkx/networkx/generators/mycielski.pyi +++ b/stubs/networkx/networkx/generators/mycielski.pyi @@ -1,8 +1,12 @@ +from _typeshed import Incomplete + from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["mycielskian", "mycielski_graph"] @_dispatchable -def mycielskian(G, iterations: int = 1): ... +def mycielskian(G: Graph[Incomplete], iterations: int = 1): ... @_dispatchable -def mycielski_graph(n): ... +def mycielski_graph(n: int): ... diff --git a/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi b/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi index bf4ee819b70c..e97bb5ca60c0 100644 --- a/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi +++ b/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi @@ -6,6 +6,6 @@ from networkx.utils.backends import _dispatchable __all__ = ["nonisomorphic_trees", "number_of_nonisomorphic_trees"] @_dispatchable -def nonisomorphic_trees(order, create: str = "graph") -> Generator[Incomplete, None, None]: ... +def nonisomorphic_trees(order: int, create: str = "graph") -> Generator[Incomplete, None, None]: ... @_dispatchable -def number_of_nonisomorphic_trees(order): ... +def number_of_nonisomorphic_trees(order: int): ... diff --git a/stubs/networkx/networkx/generators/random_graphs.pyi b/stubs/networkx/networkx/generators/random_graphs.pyi index a0e78626e796..7463608b5854 100644 --- a/stubs/networkx/networkx/generators/random_graphs.pyi +++ b/stubs/networkx/networkx/generators/random_graphs.pyi @@ -2,6 +2,8 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = [ "fast_gnp_random_graph", "gnp_random_graph", @@ -25,40 +27,44 @@ __all__ = [ ] @_dispatchable -def fast_gnp_random_graph(n, p, seed: Incomplete | None = None, directed: bool = False): ... +def fast_gnp_random_graph(n: int, p: float, seed: Incomplete | None = None, directed: bool = False): ... @_dispatchable -def gnp_random_graph(n, p, seed: Incomplete | None = None, directed: bool = False): ... +def gnp_random_graph(n: int, p: float, seed: Incomplete | None = None, directed: bool = False): ... binomial_graph = gnp_random_graph erdos_renyi_graph = gnp_random_graph @_dispatchable -def dense_gnm_random_graph(n, m, seed: Incomplete | None = None): ... +def dense_gnm_random_graph(n: int, m: int, seed: Incomplete | None = None): ... @_dispatchable -def gnm_random_graph(n, m, seed: Incomplete | None = None, directed: bool = False): ... +def gnm_random_graph(n: int, m: int, seed: Incomplete | None = None, directed: bool = False): ... @_dispatchable -def newman_watts_strogatz_graph(n, k, p, seed: Incomplete | None = None): ... +def newman_watts_strogatz_graph(n: int, k: int, p: float, seed: Incomplete | None = None): ... @_dispatchable -def watts_strogatz_graph(n, k, p, seed: Incomplete | None = None): ... +def watts_strogatz_graph(n: int, k: int, p: float, seed: Incomplete | None = None): ... @_dispatchable -def connected_watts_strogatz_graph(n, k, p, tries: int = 100, seed: Incomplete | None = None): ... +def connected_watts_strogatz_graph(n: int, k: int, p: float, tries: int = 100, seed: Incomplete | None = None): ... @_dispatchable -def random_regular_graph(d, n, seed: Incomplete | None = None): ... +def random_regular_graph(d, n: int, seed: Incomplete | None = None): ... @_dispatchable -def barabasi_albert_graph(n, m, seed: Incomplete | None = None, initial_graph: Incomplete | None = None): ... +def barabasi_albert_graph( + n: int, m: int, seed: Incomplete | None = None, initial_graph: Graph[Incomplete] | None = None +) -> Graph[Incomplete]: ... @_dispatchable -def dual_barabasi_albert_graph(n, m1, m2, p, seed: Incomplete | None = None, initial_graph: Incomplete | None = None): ... +def dual_barabasi_albert_graph( + n: int, m1, m2, p: float, seed: Incomplete | None = None, initial_graph: Graph[Incomplete] | None = None +) -> Graph[Incomplete]: ... @_dispatchable -def extended_barabasi_albert_graph(n, m, p, q, seed: Incomplete | None = None): ... +def extended_barabasi_albert_graph(n: int, m: int, p: float, q, seed: Incomplete | None = None) -> Graph[Incomplete]: ... @_dispatchable -def powerlaw_cluster_graph(n, m, p, seed: Incomplete | None = None): ... +def powerlaw_cluster_graph(n: int, m: int, p: float, seed: Incomplete | None = None): ... @_dispatchable -def random_lobster(n, p1, p2, seed: Incomplete | None = None): ... +def random_lobster(n: int, p1: float, p2: float, seed: Incomplete | None = None): ... @_dispatchable def random_shell_graph(constructor, seed: Incomplete | None = None): ... @_dispatchable -def random_powerlaw_tree(n, gamma: float = 3, seed: Incomplete | None = None, tries: int = 100): ... +def random_powerlaw_tree(n: int, gamma: float = 3, seed: Incomplete | None = None, tries: int = 100): ... @_dispatchable -def random_powerlaw_tree_sequence(n, gamma: float = 3, seed: Incomplete | None = None, tries: int = 100): ... +def random_powerlaw_tree_sequence(n: int, gamma: float = 3, seed: Incomplete | None = None, tries: int = 100): ... @_dispatchable -def random_kernel_graph(n, kernel_integral, kernel_root: Incomplete | None = None, seed: Incomplete | None = None): ... +def random_kernel_graph(n: int, kernel_integral, kernel_root: Incomplete | None = None, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/spectral_graph_forge.pyi b/stubs/networkx/networkx/generators/spectral_graph_forge.pyi index 6fc6902a354f..beb70434ad01 100644 --- a/stubs/networkx/networkx/generators/spectral_graph_forge.pyi +++ b/stubs/networkx/networkx/generators/spectral_graph_forge.pyi @@ -2,7 +2,11 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["spectral_graph_forge"] @_dispatchable -def spectral_graph_forge(G, alpha, transformation: str = "identity", seed: Incomplete | None = None): ... +def spectral_graph_forge( + G: Graph[Incomplete], alpha: float, transformation: str = "identity", seed: Incomplete | None = None +) -> Graph[Incomplete]: ... diff --git a/stubs/networkx/networkx/generators/stochastic.pyi b/stubs/networkx/networkx/generators/stochastic.pyi index 045818852fea..8c2ace919ad3 100644 --- a/stubs/networkx/networkx/generators/stochastic.pyi +++ b/stubs/networkx/networkx/generators/stochastic.pyi @@ -1,6 +1,10 @@ +from _typeshed import Incomplete + from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["stochastic_graph"] @_dispatchable -def stochastic_graph(G, copy: bool = True, weight: str = "weight"): ... +def stochastic_graph(G: Graph[Incomplete], copy: bool = True, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/generators/trees.pyi b/stubs/networkx/networkx/generators/trees.pyi index 8652af12a6a7..5f359a320d92 100644 --- a/stubs/networkx/networkx/generators/trees.pyi +++ b/stubs/networkx/networkx/generators/trees.pyi @@ -2,6 +2,8 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable +from ..classes.digraph import DiGraph + __all__ = [ "prefix_tree", "prefix_tree_recursive", @@ -14,9 +16,9 @@ __all__ = [ ] @_dispatchable -def prefix_tree(paths): ... +def prefix_tree(paths) -> DiGraph: ... @_dispatchable -def prefix_tree_recursive(paths): ... +def prefix_tree_recursive(paths) -> DiGraph: ... @_dispatchable def random_labeled_tree(n, *, seed=None): ... @_dispatchable diff --git a/stubs/networkx/networkx/generators/triads.pyi b/stubs/networkx/networkx/generators/triads.pyi index e0ce3d43241b..24f64e61a9e8 100644 --- a/stubs/networkx/networkx/generators/triads.pyi +++ b/stubs/networkx/networkx/generators/triads.pyi @@ -1,6 +1,11 @@ +from typing import Final + +from networkx import DiGraph from networkx.utils.backends import _dispatchable __all__ = ["triad_graph"] +TRIAD_EDGES: Final[dict[str, list[str]]] + @_dispatchable -def triad_graph(triad_name): ... +def triad_graph(triad_name: str) -> DiGraph: ... diff --git a/stubs/networkx/networkx/lazy_imports.pyi b/stubs/networkx/networkx/lazy_imports.pyi index b932e90af2c2..c6d82cb4b897 100644 --- a/stubs/networkx/networkx/lazy_imports.pyi +++ b/stubs/networkx/networkx/lazy_imports.pyi @@ -1,9 +1,10 @@ import types from _typeshed import Incomplete +from collections.abc import Mapping __all__ = ["attach", "_lazy_import"] -def attach(module_name, submodules: Incomplete | None = None, submod_attrs: Incomplete | None = None): ... +def attach(module_name: str, submodules: set[str] | None = None, submod_attrs: Mapping[str, Incomplete] | None = None): ... class DelayedImportErrorModule(types.ModuleType): def __init__(self, frame_data, *args, **kwargs) -> None: ... diff --git a/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi b/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi index fa12fa8c1acd..1a0cc78cc522 100644 --- a/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi +++ b/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi @@ -2,6 +2,8 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["algebraic_connectivity", "fiedler_vector", "spectral_ordering", "spectral_bisection"] class _PCGSolver: @@ -14,7 +16,7 @@ class _LUSolver: @_dispatchable def algebraic_connectivity( - G, + G: Graph[Incomplete], weight: str = "weight", normalized: bool = False, tol: float = 1e-08, @@ -23,7 +25,7 @@ def algebraic_connectivity( ): ... @_dispatchable def fiedler_vector( - G, + G: Graph[Incomplete], weight: str = "weight", normalized: bool = False, tol: float = 1e-08, @@ -32,7 +34,7 @@ def fiedler_vector( ): ... @_dispatchable def spectral_ordering( - G, + G: Graph[Incomplete], weight: str = "weight", normalized: bool = False, tol: float = 1e-08, diff --git a/stubs/networkx/networkx/linalg/attrmatrix.pyi b/stubs/networkx/networkx/linalg/attrmatrix.pyi index 3e645842ec26..0e2dce1aa0c5 100644 --- a/stubs/networkx/networkx/linalg/attrmatrix.pyi +++ b/stubs/networkx/networkx/linalg/attrmatrix.pyi @@ -1,14 +1,17 @@ from _typeshed import Incomplete +from collections.abc import Callable from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["attr_matrix", "attr_sparse_matrix"] @_dispatchable def attr_matrix( - G, - edge_attr: Incomplete | None = None, - node_attr: Incomplete | None = None, + G: Graph[Incomplete], + edge_attr: str | Callable[[Incomplete, Incomplete], Incomplete] | None = None, + node_attr: str | Callable[[Incomplete], Incomplete] | None = None, normalized: bool = False, rc_order: Incomplete | None = None, dtype: Incomplete | None = None, @@ -16,9 +19,9 @@ def attr_matrix( ): ... @_dispatchable def attr_sparse_matrix( - G, - edge_attr: Incomplete | None = None, - node_attr: Incomplete | None = None, + G: Graph[Incomplete], + edge_attr: str | Callable[[Incomplete, Incomplete], Incomplete] | None = None, + node_attr: str | Callable[[Incomplete], Incomplete] | None = None, normalized: bool = False, rc_order: Incomplete | None = None, dtype: Incomplete | None = None, diff --git a/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi b/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi index 2e98b1cdb995..bd0ac5865de3 100644 --- a/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi +++ b/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi @@ -3,7 +3,9 @@ from collections.abc import Collection from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["bethe_hessian_matrix"] @_dispatchable -def bethe_hessian_matrix(G, r: Incomplete | None = None, nodelist: Collection[Incomplete] | None = None): ... +def bethe_hessian_matrix(G: Graph[Incomplete], r: float | None = None, nodelist: Collection[Incomplete] | None = None): ... diff --git a/stubs/networkx/networkx/linalg/graphmatrix.pyi b/stubs/networkx/networkx/linalg/graphmatrix.pyi index 97fb7371cb81..0b2b8abd5094 100644 --- a/stubs/networkx/networkx/linalg/graphmatrix.pyi +++ b/stubs/networkx/networkx/linalg/graphmatrix.pyi @@ -3,11 +3,13 @@ from collections.abc import Collection from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["incidence_matrix", "adjacency_matrix"] @_dispatchable def incidence_matrix( - G, + G: Graph[Incomplete], nodelist: Collection[Incomplete] | None = None, edgelist: Incomplete | None = None, oriented: bool = False, @@ -15,5 +17,5 @@ def incidence_matrix( ): ... @_dispatchable def adjacency_matrix( - G, nodelist: Collection[Incomplete] | None = None, dtype: Incomplete | None = None, weight: str = "weight" + G: Graph[Incomplete], nodelist: Collection[Incomplete] | None = None, dtype: Incomplete | None = None, weight: str = "weight" ): ... diff --git a/stubs/networkx/networkx/linalg/laplacianmatrix.pyi b/stubs/networkx/networkx/linalg/laplacianmatrix.pyi index ebbfd847905e..9a4ce95367b6 100644 --- a/stubs/networkx/networkx/linalg/laplacianmatrix.pyi +++ b/stubs/networkx/networkx/linalg/laplacianmatrix.pyi @@ -3,6 +3,9 @@ from collections.abc import Collection from networkx.utils.backends import _dispatchable +from ..classes.digraph import DiGraph +from ..classes.graph import Graph + __all__ = [ "laplacian_matrix", "normalized_laplacian_matrix", @@ -12,14 +15,14 @@ __all__ = [ ] @_dispatchable -def laplacian_matrix(G, nodelist: Collection[Incomplete] | None = None, weight: str = "weight"): ... +def laplacian_matrix(G: Graph[Incomplete], nodelist: Collection[Incomplete] | None = None, weight: str = "weight"): ... @_dispatchable -def normalized_laplacian_matrix(G, nodelist: Collection[Incomplete] | None = None, weight: str = "weight"): ... +def normalized_laplacian_matrix(G: Graph[Incomplete], nodelist: Collection[Incomplete] | None = None, weight: str = "weight"): ... @_dispatchable -def total_spanning_tree_weight(G, weight: Incomplete | None = None): ... +def total_spanning_tree_weight(G: Graph[Incomplete], weight: str | None = None) -> float: ... @_dispatchable def directed_laplacian_matrix( - G, + G: DiGraph[Incomplete], nodelist: Collection[Incomplete] | None = None, weight: str = "weight", walk_type: Incomplete | None = None, @@ -27,7 +30,7 @@ def directed_laplacian_matrix( ): ... @_dispatchable def directed_combinatorial_laplacian_matrix( - G, + G: DiGraph[Incomplete], nodelist: Collection[Incomplete] | None = None, weight: str = "weight", walk_type: Incomplete | None = None, diff --git a/stubs/networkx/networkx/linalg/modularitymatrix.pyi b/stubs/networkx/networkx/linalg/modularitymatrix.pyi index 03b0e1ef1193..0cfb25d1b6f8 100644 --- a/stubs/networkx/networkx/linalg/modularitymatrix.pyi +++ b/stubs/networkx/networkx/linalg/modularitymatrix.pyi @@ -3,9 +3,14 @@ from collections.abc import Collection from networkx.utils.backends import _dispatchable +from ..classes.digraph import DiGraph +from ..classes.graph import Graph + __all__ = ["modularity_matrix", "directed_modularity_matrix"] @_dispatchable -def modularity_matrix(G, nodelist: Collection[Incomplete] | None = None, weight: Incomplete | None = None): ... +def modularity_matrix(G: Graph[Incomplete], nodelist: Collection[Incomplete] | None = None, weight: Incomplete | None = None): ... @_dispatchable -def directed_modularity_matrix(G, nodelist: Collection[Incomplete] | None = None, weight: Incomplete | None = None): ... +def directed_modularity_matrix( + G: DiGraph[Incomplete], nodelist: Collection[Incomplete] | None = None, weight: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/linalg/spectrum.pyi b/stubs/networkx/networkx/linalg/spectrum.pyi index 3051a272c3ec..397dc5d7ff62 100644 --- a/stubs/networkx/networkx/linalg/spectrum.pyi +++ b/stubs/networkx/networkx/linalg/spectrum.pyi @@ -2,6 +2,8 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = [ "laplacian_spectrum", "adjacency_spectrum", @@ -11,12 +13,12 @@ __all__ = [ ] @_dispatchable -def laplacian_spectrum(G, weight: str = "weight"): ... +def laplacian_spectrum(G: Graph[Incomplete], weight: str = "weight"): ... @_dispatchable -def normalized_laplacian_spectrum(G, weight: str = "weight"): ... +def normalized_laplacian_spectrum(G: Graph[Incomplete], weight: str = "weight"): ... @_dispatchable -def adjacency_spectrum(G, weight: str = "weight"): ... +def adjacency_spectrum(G: Graph[Incomplete], weight: str = "weight"): ... @_dispatchable -def modularity_spectrum(G): ... +def modularity_spectrum(G: Graph[Incomplete]): ... @_dispatchable -def bethe_hessian_spectrum(G, r: Incomplete | None = None): ... +def bethe_hessian_spectrum(G: Graph[Incomplete], r: float | None = None): ... diff --git a/stubs/networkx/networkx/readwrite/adjlist.pyi b/stubs/networkx/networkx/readwrite/adjlist.pyi index b9cbfef32166..083d7221835b 100644 --- a/stubs/networkx/networkx/readwrite/adjlist.pyi +++ b/stubs/networkx/networkx/readwrite/adjlist.pyi @@ -3,15 +3,17 @@ from collections.abc import Generator from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["generate_adjlist", "write_adjlist", "parse_adjlist", "read_adjlist"] -def generate_adjlist(G, delimiter: str = " ") -> Generator[Incomplete, None, None]: ... -def write_adjlist(G, path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8") -> None: ... +def generate_adjlist(G: Graph[Incomplete], delimiter: str = " ") -> Generator[str, None, None]: ... +def write_adjlist(G: Graph[Incomplete], path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8") -> None: ... @_dispatchable def parse_adjlist( lines, comments: str = "#", - delimiter: Incomplete | None = None, + delimiter: str | None = None, create_using: Incomplete | None = None, nodetype: Incomplete | None = None, ): ... @@ -19,7 +21,7 @@ def parse_adjlist( def read_adjlist( path, comments: str = "#", - delimiter: Incomplete | None = None, + delimiter: str | None = None, create_using: Incomplete | None = None, nodetype: Incomplete | None = None, encoding: str = "utf-8", diff --git a/stubs/networkx/networkx/readwrite/edgelist.pyi b/stubs/networkx/networkx/readwrite/edgelist.pyi index ddb2b6d889a9..96fbcdfcee1c 100644 --- a/stubs/networkx/networkx/readwrite/edgelist.pyi +++ b/stubs/networkx/networkx/readwrite/edgelist.pyi @@ -3,6 +3,8 @@ from collections.abc import Generator from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = [ "generate_edgelist", "write_edgelist", @@ -12,34 +14,40 @@ __all__ = [ "write_weighted_edgelist", ] -def generate_edgelist(G, delimiter: str = " ", data: bool = True) -> Generator[Incomplete, None, None]: ... -def write_edgelist(G, path, comments: str = "#", delimiter: str = " ", data: bool = True, encoding: str = "utf-8") -> None: ... +def generate_edgelist( + G: Graph[Incomplete], delimiter: str = " ", data: bool | Incomplete = True +) -> Generator[Incomplete, None, None]: ... +def write_edgelist( + G: Graph[Incomplete], path, comments: str = "#", delimiter: str = " ", data: bool | Incomplete = True, encoding: str = "utf-8" +) -> None: ... @_dispatchable def parse_edgelist( lines, comments: str = "#", - delimiter: Incomplete | None = None, + delimiter: str | None = None, create_using: Incomplete | None = None, nodetype: Incomplete | None = None, - data: bool = True, + data: bool | Incomplete = True, ): ... @_dispatchable def read_edgelist( path, comments: str = "#", - delimiter: Incomplete | None = None, + delimiter: str | None = None, create_using: Incomplete | None = None, nodetype: Incomplete | None = None, - data: bool = True, + data: bool | Incomplete = True, edgetype: Incomplete | None = None, encoding: str = "utf-8", ): ... -def write_weighted_edgelist(G, path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8") -> None: ... +def write_weighted_edgelist( + G: Graph[Incomplete], path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8" +) -> None: ... @_dispatchable def read_weighted_edgelist( path, comments: str = "#", - delimiter: Incomplete | None = None, + delimiter: str | None = None, create_using: Incomplete | None = None, nodetype: Incomplete | None = None, encoding: str = "utf-8", diff --git a/stubs/networkx/networkx/readwrite/gexf.pyi b/stubs/networkx/networkx/readwrite/gexf.pyi index 8de89fcd392f..8da51bddf4fd 100644 --- a/stubs/networkx/networkx/readwrite/gexf.pyi +++ b/stubs/networkx/networkx/readwrite/gexf.pyi @@ -1,23 +1,28 @@ from _typeshed import Incomplete from collections.abc import Generator +from typing import Literal from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["write_gexf", "read_gexf", "relabel_gexf_graph", "generate_gexf"] -def write_gexf(G, path, encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft") -> None: ... +def write_gexf( + G: Graph[Incomplete], path, encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft" +) -> None: ... def generate_gexf( - G, encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft" + G: Graph[Incomplete], encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft" ) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable def read_gexf(path, node_type: Incomplete | None = None, relabel: bool = False, version: str = "1.2draft"): ... class GEXF: - versions: Incomplete + versions: dict[str, dict[str, str]] xml_type: Incomplete python_type: Incomplete def construct_types(self) -> None: ... - convert_bool: Incomplete + convert_bool: dict[Literal["true", "false", "True", "False", "0", 0, "1", 1], bool] NS_GEXF: Incomplete NS_VIZ: Incomplete NS_XSI: Incomplete @@ -39,8 +44,8 @@ class GEXFWriter(GEXF): ) -> None: ... graph_element: Incomplete def add_graph(self, G) -> None: ... - def add_nodes(self, G, graph_element) -> None: ... - def add_edges(self, G, graph_element) -> None: ... + def add_nodes(self, G: Graph[Incomplete], graph_element) -> None: ... + def add_edges(self, G: Graph[Incomplete], graph_element) -> None: ... def add_attributes(self, node_or_edge, xml_obj, data, default): ... def get_attr_id(self, title, attr_type, edge_or_node, default, mode): ... def add_viz(self, element, node_data): ... @@ -59,14 +64,14 @@ class GEXFReader(GEXF): def __call__(self, stream): ... timeformat: Incomplete def make_graph(self, graph_xml): ... - def add_node(self, G, node_xml, node_attr, node_pid: Incomplete | None = None) -> None: ... + def add_node(self, G: Graph[Incomplete], node_xml, node_attr, node_pid: Incomplete | None = None) -> None: ... def add_start_end(self, data, xml): ... def add_viz(self, data, node_xml): ... def add_parents(self, data, node_xml): ... def add_slices(self, data, node_or_edge_xml): ... def add_spells(self, data, node_or_edge_xml): ... - def add_edge(self, G, edge_element, edge_attr) -> None: ... + def add_edge(self, G: Graph[Incomplete], edge_element, edge_attr) -> None: ... def decode_attr_elements(self, gexf_keys, obj_xml): ... def find_gexf_attributes(self, attributes_element): ... -def relabel_gexf_graph(G): ... +def relabel_gexf_graph(G: Graph[Incomplete]): ... diff --git a/stubs/networkx/networkx/readwrite/gml.pyi b/stubs/networkx/networkx/readwrite/gml.pyi index 63fae3c7b3e1..59f6cc11a491 100644 --- a/stubs/networkx/networkx/readwrite/gml.pyi +++ b/stubs/networkx/networkx/readwrite/gml.pyi @@ -1,18 +1,25 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Callable, Generator, Iterable from enum import Enum -from typing import Generic, NamedTuple, TypeVar +from typing import Final, Generic, NamedTuple, TypeVar from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + _T = TypeVar("_T") __all__ = ["read_gml", "parse_gml", "generate_gml", "write_gml"] +def escape(text): ... +def unescape(text): ... +def literal_destringizer(rep: str): ... @_dispatchable -def read_gml(path, label: str = "label", destringizer: Incomplete | None = None): ... +def read_gml(path, label: str = "label", destringizer: Callable[[Incomplete], Incomplete] | None = None): ... @_dispatchable -def parse_gml(lines, label: str = "label", destringizer: Incomplete | None = None): ... +def parse_gml( + lines: str | Iterable[str], label: str = "label", destringizer: Callable[[Incomplete], Incomplete] | None = None +): ... class Pattern(Enum): KEYS = 0 @@ -29,5 +36,11 @@ class Token(NamedTuple, Generic[_T]): line: int position: int -def generate_gml(G, stringizer: Incomplete | None = None) -> Generator[Incomplete, Incomplete, None]: ... -def write_gml(G, path, stringizer: Incomplete | None = None) -> None: ... +LIST_START_VALUE: Final = "_networkx_list_start" + +def parse_gml_lines(lines, label, destringizer): ... +def literal_stringizer(value) -> str: ... +def generate_gml( + G: Graph[Incomplete], stringizer: Callable[[Incomplete], str] | None = None +) -> Generator[Incomplete, Incomplete, None]: ... +def write_gml(G: Graph[Incomplete], path, stringizer: Callable[[Incomplete], str] | None = None) -> None: ... diff --git a/stubs/networkx/networkx/readwrite/graph6.pyi b/stubs/networkx/networkx/readwrite/graph6.pyi index 092bffdf2d77..826b55c4b58c 100644 --- a/stubs/networkx/networkx/readwrite/graph6.pyi +++ b/stubs/networkx/networkx/readwrite/graph6.pyi @@ -1,12 +1,18 @@ from _typeshed import Incomplete +from collections.abc import Iterable from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["from_graph6_bytes", "read_graph6", "to_graph6_bytes", "write_graph6"] @_dispatchable -def from_graph6_bytes(bytes_in): ... -def to_graph6_bytes(G, nodes: Incomplete | None = None, header: bool = True): ... +def from_graph6_bytes(bytes_in) -> Graph[Incomplete]: ... +def to_graph6_bytes(G: Graph[Incomplete], nodes: Iterable[Incomplete] | None = None, header: bool = True): ... @_dispatchable def read_graph6(path): ... -def write_graph6(G, path, nodes: Incomplete | None = None, header: bool = True): ... +def write_graph6(G: Graph[Incomplete], path, nodes: Iterable[Incomplete] | None = None, header: bool = True): ... +def write_graph6_file(G: Graph[Incomplete], f, nodes: Iterable[Incomplete] | None = None, header: bool = True): ... +def data_to_n(data): ... +def n_to_data(n): ... diff --git a/stubs/networkx/networkx/readwrite/graphml.pyi b/stubs/networkx/networkx/readwrite/graphml.pyi index 2ef976b5118c..abd4da9a3bf1 100644 --- a/stubs/networkx/networkx/readwrite/graphml.pyi +++ b/stubs/networkx/networkx/readwrite/graphml.pyi @@ -1,9 +1,11 @@ from _typeshed import Incomplete from collections.abc import Generator -from typing import Final +from typing import Final, Literal from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = [ "write_graphml", "read_graphml", @@ -16,7 +18,7 @@ __all__ = [ ] def write_graphml_xml( - G, + G: Graph[Incomplete], path, encoding: str = "utf-8", prettyprint: bool = True, @@ -25,7 +27,7 @@ def write_graphml_xml( edge_id_from_attribute: Incomplete | None = None, ) -> None: ... def write_graphml_lxml( - G, + G: Graph[Incomplete], path, encoding: str = "utf-8", prettyprint: bool = True, @@ -34,7 +36,7 @@ def write_graphml_lxml( edge_id_from_attribute: Incomplete | None = None, ): ... def generate_graphml( - G, + G: Graph[Incomplete], encoding: str = "utf-8", prettyprint: bool = True, named_key_ids: bool = False, @@ -43,7 +45,7 @@ def generate_graphml( @_dispatchable def read_graphml(path, node_type=..., edge_key_type=..., force_multigraph: bool = False): ... @_dispatchable -def parse_graphml(graphml_string, node_type=..., edge_key_type=..., force_multigraph: bool = False): ... +def parse_graphml(graphml_string: str, node_type=..., edge_key_type=..., force_multigraph: bool = False): ... class GraphML: NS_GRAPHML: Final[str] @@ -53,7 +55,7 @@ class GraphML: xml_type: Incomplete python_type: Incomplete def construct_types(self) -> None: ... - convert_bool: Incomplete + convert_bool: dict[Literal["true", "false", "0", 0, "1", 1], bool] def get_xml_type(self, key): ... class GraphMLWriter(GraphML): @@ -80,8 +82,8 @@ class GraphMLWriter(GraphML): def get_key(self, name, attr_type, scope, default): ... def add_data(self, name, element_type, value, scope: str = "all", default: Incomplete | None = None): ... def add_attributes(self, scope, xml_obj, data, default) -> None: ... - def add_nodes(self, G, graph_element) -> None: ... - def add_edges(self, G, graph_element) -> None: ... + def add_nodes(self, G: Graph[Incomplete], graph_element) -> None: ... + def add_edges(self, G: Graph[Incomplete], graph_element) -> None: ... def add_graph_element(self, G) -> None: ... def add_graphs(self, graph_list) -> None: ... def dump(self, stream) -> None: ... @@ -126,7 +128,7 @@ class GraphMLReader(GraphML): xml: Incomplete def __call__(self, path: Incomplete | None = None, string: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... def make_graph(self, graph_xml, graphml_keys, defaults, G: Incomplete | None = None): ... - def add_node(self, G, node_xml, graphml_keys, defaults) -> None: ... - def add_edge(self, G, edge_element, graphml_keys) -> None: ... + def add_node(self, G: Graph[Incomplete], node_xml, graphml_keys, defaults) -> None: ... + def add_edge(self, G: Graph[Incomplete], edge_element, graphml_keys) -> None: ... def decode_data_elements(self, graphml_keys, obj_xml): ... def find_graphml_keys(self, graph_element): ... diff --git a/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi b/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi index f1745015fad3..a820f3575f1e 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi @@ -1,8 +1,16 @@ +from _typeshed import Incomplete +from collections.abc import Mapping +from typing import Any + from networkx.utils.backends import _dispatchable +from ...classes.graph import Graph + __all__ = ["adjacency_data", "adjacency_graph"] +# Any: Complex type union +def adjacency_data(G: Graph[Incomplete], attrs: Mapping[str, Incomplete] = {"id": "id", "key": "key"}) -> dict[str, Any]: ... @_dispatchable -def adjacency_data(G, attrs={"id": "id", "key": "key"}): ... -@_dispatchable -def adjacency_graph(data, directed: bool = False, multigraph: bool = True, attrs={"id": "id", "key": "key"}): ... +def adjacency_graph( + data, directed: bool = False, multigraph: bool = True, attrs: Mapping[str, Incomplete] = {"id": "id", "key": "key"} +): ... diff --git a/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi b/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi index 6b5155209711..9598ccb32cdc 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi @@ -1,7 +1,14 @@ +from _typeshed import Incomplete +from collections.abc import Mapping +from typing import Any + from networkx.utils.backends import _dispatchable +from ...classes.graph import Graph + __all__ = ["cytoscape_data", "cytoscape_graph"] -def cytoscape_data(G, name: str = "name", ident: str = "id"): ... +# Any: Complex type union +def cytoscape_data(G: Graph[Incomplete], name: str = "name", ident: str = "id") -> dict[str, Any]: ... @_dispatchable -def cytoscape_graph(data, name: str = "name", ident: str = "id"): ... +def cytoscape_graph(data: Mapping[str, Incomplete], name: str = "name", ident: str = "id"): ... diff --git a/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi b/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi index 2f15c525d5bb..7fa38ff946f3 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi @@ -1,11 +1,14 @@ from _typeshed import Incomplete +from collections.abc import Mapping from networkx.utils.backends import _dispatchable +from ...classes.graph import Graph + __all__ = ["node_link_data", "node_link_graph"] def node_link_data( - G, + G: Graph[Incomplete], *, source: str = "source", target: str = "target", @@ -17,10 +20,9 @@ def node_link_data( ): ... @_dispatchable def node_link_graph( - data, + data: Mapping[str, Incomplete], directed: bool = False, multigraph: bool = True, - attrs: Incomplete | None = None, *, source: str = "source", target: str = "target", diff --git a/stubs/networkx/networkx/readwrite/json_graph/tree.pyi b/stubs/networkx/networkx/readwrite/json_graph/tree.pyi index 1b215465316e..d4b2b1d40b24 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/tree.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/tree.pyi @@ -1,7 +1,12 @@ +from _typeshed import Incomplete +from collections.abc import Mapping + from networkx.utils.backends import _dispatchable +from ...classes.graph import Graph + __all__ = ["tree_data", "tree_graph"] -def tree_data(G, root, ident: str = "id", children: str = "children"): ... +def tree_data(G: Graph[Incomplete], root, ident: str = "id", children: str = "children"): ... @_dispatchable -def tree_graph(data, ident: str = "id", children: str = "children"): ... +def tree_graph(data: Mapping[str, Incomplete], ident: str = "id", children: str = "children"): ... diff --git a/stubs/networkx/networkx/readwrite/leda.pyi b/stubs/networkx/networkx/readwrite/leda.pyi index 733005d1ce64..5df28f467ebc 100644 --- a/stubs/networkx/networkx/readwrite/leda.pyi +++ b/stubs/networkx/networkx/readwrite/leda.pyi @@ -1,3 +1,5 @@ +from collections.abc import Iterable + from networkx.utils.backends import _dispatchable __all__ = ["read_leda", "parse_leda"] @@ -5,4 +7,4 @@ __all__ = ["read_leda", "parse_leda"] @_dispatchable def read_leda(path, encoding: str = "UTF-8"): ... @_dispatchable -def parse_leda(lines): ... +def parse_leda(lines: str | Iterable[str]): ... diff --git a/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi b/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi index a83096ae39d3..3ca9815c2e41 100644 --- a/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi +++ b/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi @@ -3,15 +3,19 @@ from collections.abc import Generator from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["generate_multiline_adjlist", "write_multiline_adjlist", "parse_multiline_adjlist", "read_multiline_adjlist"] -def generate_multiline_adjlist(G, delimiter: str = " ") -> Generator[Incomplete, None, None]: ... -def write_multiline_adjlist(G, path, delimiter: str = " ", comments: str = "#", encoding: str = "utf-8") -> None: ... +def generate_multiline_adjlist(G: Graph[Incomplete], delimiter: str = " ") -> Generator[str, None, None]: ... +def write_multiline_adjlist( + G: Graph[Incomplete], path, delimiter: str = " ", comments: str = "#", encoding: str = "utf-8" +) -> None: ... @_dispatchable def parse_multiline_adjlist( lines, comments: str = "#", - delimiter: Incomplete | None = None, + delimiter: str | None = None, create_using: Incomplete | None = None, nodetype: Incomplete | None = None, edgetype: Incomplete | None = None, @@ -20,7 +24,7 @@ def parse_multiline_adjlist( def read_multiline_adjlist( path, comments: str = "#", - delimiter: Incomplete | None = None, + delimiter: str | None = None, create_using: Incomplete | None = None, nodetype: Incomplete | None = None, edgetype: Incomplete | None = None, diff --git a/stubs/networkx/networkx/readwrite/p2g.pyi b/stubs/networkx/networkx/readwrite/p2g.pyi index f9da22dd2611..1bdf5ac58355 100644 --- a/stubs/networkx/networkx/readwrite/p2g.pyi +++ b/stubs/networkx/networkx/readwrite/p2g.pyi @@ -1,7 +1,12 @@ +from _typeshed import Incomplete + from networkx.utils.backends import _dispatchable -def write_p2g(G, path, encoding: str = "utf-8") -> None: ... +from ..classes.graph import Graph +from ..classes.multidigraph import MultiDiGraph + +def write_p2g(G: Graph[Incomplete], path, encoding: str = "utf-8") -> None: ... @_dispatchable -def read_p2g(path, encoding: str = "utf-8"): ... +def read_p2g(path, encoding: str = "utf-8") -> MultiDiGraph: ... @_dispatchable -def parse_p2g(lines): ... +def parse_p2g(lines) -> MultiDiGraph: ... diff --git a/stubs/networkx/networkx/readwrite/pajek.pyi b/stubs/networkx/networkx/readwrite/pajek.pyi index b34dfb83a4d8..081a1ad60865 100644 --- a/stubs/networkx/networkx/readwrite/pajek.pyi +++ b/stubs/networkx/networkx/readwrite/pajek.pyi @@ -1,13 +1,16 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Generator, Iterable from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["read_pajek", "parse_pajek", "generate_pajek", "write_pajek"] -def generate_pajek(G) -> Generator[Incomplete, None, None]: ... -def write_pajek(G, path, encoding: str = "UTF-8") -> None: ... +def generate_pajek(G: Graph[Incomplete]) -> Generator[Incomplete, None, None]: ... +def write_pajek(G: Graph[Incomplete], path, encoding: str = "UTF-8") -> None: ... @_dispatchable def read_pajek(path, encoding: str = "UTF-8"): ... @_dispatchable -def parse_pajek(lines): ... +def parse_pajek(lines: str | Iterable[str]): ... +def make_qstr(t): ... diff --git a/stubs/networkx/networkx/readwrite/sparse6.pyi b/stubs/networkx/networkx/readwrite/sparse6.pyi index 10a140c0afca..0ad32cacff42 100644 --- a/stubs/networkx/networkx/readwrite/sparse6.pyi +++ b/stubs/networkx/networkx/readwrite/sparse6.pyi @@ -1,12 +1,15 @@ from _typeshed import Incomplete +from collections.abc import Iterable from networkx.utils.backends import _dispatchable +from ..classes.graph import Graph + __all__ = ["from_sparse6_bytes", "read_sparse6", "to_sparse6_bytes", "write_sparse6"] @_dispatchable -def from_sparse6_bytes(string): ... -def to_sparse6_bytes(G, nodes: Incomplete | None = None, header: bool = True): ... +def from_sparse6_bytes(string: str) -> Graph[Incomplete]: ... +def to_sparse6_bytes(G: Graph[Incomplete], nodes: Iterable[Incomplete] | None = None, header: bool = True): ... @_dispatchable def read_sparse6(path): ... -def write_sparse6(G, path, nodes: Incomplete | None = None, header: bool = True) -> None: ... +def write_sparse6(G: Graph[Incomplete], path, nodes: Incomplete | None = None, header: bool = True) -> None: ... diff --git a/stubs/networkx/networkx/utils/__init__.pyi b/stubs/networkx/networkx/utils/__init__.pyi index 5d8fb921b076..c615a6e8a8d1 100644 --- a/stubs/networkx/networkx/utils/__init__.pyi +++ b/stubs/networkx/networkx/utils/__init__.pyi @@ -1,26 +1,9 @@ -from networkx.utils.backends import _dispatchable as _dispatchable +from networkx.utils.backends import * from networkx.utils.configs import * from networkx.utils.configs import NetworkXConfig from networkx.utils.decorators import * from networkx.utils.heaps import * - -# should be import * but pytype doesn't understand that _clear_cache is part of __all__ -from networkx.utils.misc import ( - PythonRandomInterface as PythonRandomInterface, - PythonRandomViaNumpyBits as PythonRandomViaNumpyBits, - _clear_cache as _clear_cache, - arbitrary_element as arbitrary_element, - create_py_random_state as create_py_random_state, - create_random_state as create_random_state, - dict_to_numpy_array as dict_to_numpy_array, - edges_equal as edges_equal, - flatten as flatten, - graphs_equal as graphs_equal, - groups as groups, - make_list_of_ints as make_list_of_ints, - nodes_equal as nodes_equal, - pairwise as pairwise, -) +from networkx.utils.misc import * from networkx.utils.random_sequence import * from networkx.utils.rcm import * from networkx.utils.union_find import * diff --git a/stubs/networkx/networkx/utils/decorators.pyi b/stubs/networkx/networkx/utils/decorators.pyi index af8b401c8600..f4ace0642ba8 100644 --- a/stubs/networkx/networkx/utils/decorators.pyi +++ b/stubs/networkx/networkx/utils/decorators.pyi @@ -1,21 +1,25 @@ from _typeshed import Incomplete +from collections.abc import Callable +from pathlib import Path from typing import NamedTuple +from .misc import _RandomState + __all__ = ["not_implemented_for", "open_file", "nodes_or_number", "np_random_state", "py_random_state", "argmap"] def not_implemented_for(*graph_types): ... -def open_file(path_arg, mode: str = "r"): ... +def open_file(path_arg: str | Path | Incomplete, mode: str = "r"): ... def nodes_or_number(which_args): ... -def np_random_state(random_state_argument): ... -def py_random_state(random_state_argument): ... +def np_random_state(random_state_argument: _RandomState): ... +def py_random_state(random_state_argument: _RandomState): ... class argmap: - def __init__(self, func, *args, try_finally: bool = False) -> None: ... - def __call__(self, f): ... - def compile(self, f): ... - def assemble(self, f): ... + def __init__(self, func: Callable[..., Incomplete], *args, try_finally: bool = False) -> None: ... + def __call__(self, f: Callable[..., Incomplete]) -> Callable[..., Incomplete]: ... + def compile(self, f: Callable[..., Incomplete]) -> Callable[..., Incomplete]: ... + def assemble(self, f: Callable[..., Incomplete]): ... @classmethod - def signature(cls, f): ... + def signature(cls, f: Callable[..., Incomplete]): ... class Signature(NamedTuple): name: Incomplete diff --git a/stubs/networkx/networkx/utils/heaps.pyi b/stubs/networkx/networkx/utils/heaps.pyi index 43cd69b1b358..b5cd6a75e82a 100644 --- a/stubs/networkx/networkx/utils/heaps.pyi +++ b/stubs/networkx/networkx/utils/heaps.pyi @@ -9,10 +9,10 @@ class MinHeap: def __init__(self, key, value) -> None: ... def __init__(self) -> None: ... - def min(self) -> None: ... - def pop(self) -> None: ... - def get(self, key, default: Incomplete | None = None) -> None: ... - def insert(self, key, value, allow_increase: bool = False) -> None: ... + def min(self) -> tuple[Incomplete, Incomplete]: ... + def pop(self) -> tuple[Incomplete, Incomplete]: ... + def get(self, key, default: Incomplete | None = None): ... + def insert(self, key, value, allow_increase: bool = False) -> bool: ... def __nonzero__(self): ... def __bool__(self) -> bool: ... def __len__(self) -> int: ... @@ -27,14 +27,14 @@ class PairingHeap(MinHeap): def __init__(self, key, value) -> None: ... def __init__(self) -> None: ... - def min(self): ... - def pop(self): ... + def min(self) -> tuple[Incomplete, Incomplete]: ... + def pop(self) -> tuple[Incomplete, Incomplete]: ... def get(self, key, default: Incomplete | None = None): ... - def insert(self, key, value, allow_increase: bool = False): ... + def insert(self, key, value, allow_increase: bool = False) -> bool: ... class BinaryHeap(MinHeap): def __init__(self) -> None: ... - def min(self): ... - def pop(self): ... + def min(self) -> tuple[Incomplete, Incomplete]: ... + def pop(self) -> tuple[Incomplete, Incomplete]: ... def get(self, key, default: Incomplete | None = None): ... - def insert(self, key, value, allow_increase: bool = False): ... + def insert(self, key, value, allow_increase: bool = False) -> bool: ... diff --git a/stubs/networkx/networkx/utils/misc.pyi b/stubs/networkx/networkx/utils/misc.pyi index 261e030b1df2..eecd676e5702 100644 --- a/stubs/networkx/networkx/utils/misc.pyi +++ b/stubs/networkx/networkx/utils/misc.pyi @@ -53,7 +53,7 @@ class PythonRandomInterface: def paretovariate(self, shape): ... def create_py_random_state(random_state: _RandomState = None): ... -def nodes_equal(nodes1, nodes2): ... -def edges_equal(edges1, edges2): ... -def graphs_equal(graph1, graph2): ... +def nodes_equal(nodes1, nodes2) -> bool: ... +def edges_equal(edges1, edges2) -> bool: ... +def graphs_equal(graph1, graph2) -> bool: ... def _clear_cache(G) -> None: ... diff --git a/stubs/networkx/networkx/utils/random_sequence.pyi b/stubs/networkx/networkx/utils/random_sequence.pyi index 3d89df4281c0..c31cd32d9436 100644 --- a/stubs/networkx/networkx/utils/random_sequence.pyi +++ b/stubs/networkx/networkx/utils/random_sequence.pyi @@ -10,7 +10,7 @@ __all__ = [ ] def powerlaw_sequence(n, exponent: float = 2.0, seed: Incomplete | None = None): ... -def zipf_rv(alpha, xmin: int = 1, seed: Incomplete | None = None): ... +def zipf_rv(alpha: float, xmin: int = 1, seed: Incomplete | None = None) -> int: ... def cumulative_distribution(distribution): ... def discrete_sequence( n, distribution: Incomplete | None = None, cdistribution: Incomplete | None = None, seed: Incomplete | None = None diff --git a/stubs/networkx/networkx/utils/rcm.pyi b/stubs/networkx/networkx/utils/rcm.pyi index cfe7c2debc0b..3f5547e34203 100644 --- a/stubs/networkx/networkx/utils/rcm.pyi +++ b/stubs/networkx/networkx/utils/rcm.pyi @@ -1,7 +1,11 @@ from _typeshed import Incomplete from collections.abc import Generator +from ..classes.graph import Graph + __all__ = ["cuthill_mckee_ordering", "reverse_cuthill_mckee_ordering"] -def cuthill_mckee_ordering(G, heuristic: Incomplete | None = None) -> Generator[Incomplete, Incomplete, None]: ... -def reverse_cuthill_mckee_ordering(G, heuristic: Incomplete | None = None): ... +def cuthill_mckee_ordering(G: Graph[Incomplete], heuristic=None) -> Generator[Incomplete, Incomplete, None]: ... +def reverse_cuthill_mckee_ordering(G: Graph[Incomplete], heuristic=None): ... +def connected_cuthill_mckee_ordering(G: Graph[Incomplete], heuristic=None): ... +def pseudo_peripheral_node(G: Graph[Incomplete]): ... From 67402d140ad883cee3b531080739edf5b4d7d029 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 13 May 2025 11:11:11 -0400 Subject: [PATCH 02/17] Replace `: Incomplete | None = None` with `=None` --- .../networkx/networkx/algorithms/boundary.pyi | 14 ++--- .../algorithms/centrality/flow_matrix.pyi | 4 +- .../algorithms/coloring/greedy_coloring.pyi | 2 +- .../algorithms/isomorphism/ismags.pyi | 7 +-- .../algorithms/isomorphism/isomorphvf2.pyi | 4 +- .../isomorphism/temporalisomorphvf2.pyi | 4 +- .../algorithms/lowest_common_ancestors.pyi | 2 +- .../networkx/algorithms/planarity.pyi | 2 +- .../networkx/networkx/algorithms/vitality.pyi | 2 +- stubs/networkx/networkx/classes/function.pyi | 4 +- stubs/networkx/networkx/classes/graph.pyi | 2 +- .../networkx/networkx/classes/multigraph.pyi | 10 ++-- .../networkx/networkx/classes/reportviews.pyi | 18 ++---- stubs/networkx/networkx/convert.pyi | 2 +- stubs/networkx/networkx/drawing/layout.pyi | 23 +++----- stubs/networkx/networkx/drawing/nx_agraph.pyi | 2 +- stubs/networkx/networkx/drawing/nx_latex.pyi | 6 +- stubs/networkx/networkx/drawing/nx_pydot.pyi | 4 +- stubs/networkx/networkx/drawing/nx_pylab.pyi | 56 +++++++++---------- .../networkx/networkx/generators/classic.pyi | 34 +++++------ .../networkx/networkx/generators/cographs.pyi | 4 +- .../networkx/generators/community.pyi | 14 ++--- .../networkx/generators/degree_seq.pyi | 20 +++---- .../networkx/networkx/generators/directed.pyi | 18 +++--- .../networkx/generators/duplication.pyi | 4 +- stubs/networkx/networkx/generators/ego.pyi | 4 +- .../networkx/generators/expanders.pyi | 8 +-- .../networkx/generators/geometric.pyi | 20 +++---- .../networkx/generators/harary_graph.pyi | 6 +- .../generators/internet_as_graphs.pyi | 2 +- .../networkx/generators/intersection.pyi | 8 +-- .../networkx/generators/joint_degree_seq.pyi | 4 +- .../networkx/networkx/generators/lattice.pyi | 11 +--- stubs/networkx/networkx/generators/line.pyi | 2 +- .../networkx/generators/random_graphs.pyi | 36 ++++++------ stubs/networkx/networkx/generators/small.pyi | 44 +++++++-------- .../generators/spectral_graph_forge.pyi | 2 +- .../networkx/linalg/algebraicconnectivity.pyi | 15 ++--- stubs/networkx/networkx/linalg/attrmatrix.pyi | 10 ++-- .../networkx/networkx/linalg/graphmatrix.pyi | 8 +-- .../networkx/linalg/laplacianmatrix.pyi | 4 +- .../networkx/linalg/modularitymatrix.pyi | 6 +- stubs/networkx/networkx/readwrite/adjlist.pyi | 15 +---- .../networkx/networkx/readwrite/edgelist.pyi | 20 ++----- stubs/networkx/networkx/readwrite/gexf.pyi | 10 ++-- stubs/networkx/networkx/readwrite/graphml.pyi | 22 ++++---- .../networkx/readwrite/multiline_adjlist.pyi | 13 ++--- stubs/networkx/networkx/readwrite/sparse6.pyi | 2 +- stubs/networkx/networkx/readwrite/text.pyi | 13 ++--- stubs/networkx/networkx/relabel.pyi | 3 +- stubs/networkx/networkx/utils/configs.pyi | 4 +- stubs/networkx/networkx/utils/heaps.pyi | 6 +- .../networkx/networkx/utils/mapped_queue.pyi | 6 +- stubs/networkx/networkx/utils/misc.pyi | 11 ++-- .../networkx/utils/random_sequence.pyi | 14 ++--- stubs/networkx/networkx/utils/union_find.pyi | 2 +- 56 files changed, 247 insertions(+), 346 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/boundary.pyi b/stubs/networkx/networkx/algorithms/boundary.pyi index a6c58a1b2cbf..17a8ee24e8a3 100644 --- a/stubs/networkx/networkx/algorithms/boundary.pyi +++ b/stubs/networkx/networkx/algorithms/boundary.pyi @@ -15,7 +15,7 @@ def edge_boundary( nbunch2: Iterable[Incomplete] | None = None, data: bool | Incomplete = False, keys: bool = False, - default: Incomplete | None = None, + default=None, ) -> Generator[tuple[_Node, _Node], None, None]: ... @overload def edge_boundary( @@ -24,7 +24,7 @@ def edge_boundary( nbunch2: Iterable[Incomplete] | None = None, data: bool | Incomplete = False, keys: bool = False, - default: Incomplete | None = None, + default=None, ) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( @@ -33,7 +33,7 @@ def edge_boundary( nbunch2: Iterable[Incomplete] | None = None, data: bool | Incomplete = False, keys: bool = False, - default: Incomplete | None = None, + default=None, ) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( @@ -60,7 +60,7 @@ def edge_boundary( nbunch2: Iterable[Incomplete] | None = None, data: bool | Incomplete = False, keys: bool = False, - default: Incomplete | None = None, + default=None, ) -> Generator[tuple[_Node, _Node, int], None, None]: ... @overload def edge_boundary( @@ -69,7 +69,7 @@ def edge_boundary( nbunch2: Iterable[Incomplete] | None = None, data: bool | Incomplete = False, keys: bool = False, - default: Incomplete | None = None, + default=None, ) -> Generator[tuple[_Node, _Node, int], None, None]: ... @overload def edge_boundary( @@ -78,7 +78,7 @@ def edge_boundary( nbunch2: Iterable[Incomplete] | None = None, data: bool | Incomplete = False, keys: bool = False, - default: Incomplete | None = None, + default=None, ) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( @@ -87,7 +87,7 @@ def edge_boundary( nbunch2: Iterable[Incomplete] | None = None, data: bool | Incomplete = False, keys: bool = False, - default: Incomplete | None = None, + default=None, ) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( diff --git a/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi b/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi index 7b7f43908ffb..b2cc13b1419e 100644 --- a/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi @@ -4,7 +4,7 @@ from collections.abc import Generator from networkx.utils.backends import _dispatchable @_dispatchable -def flow_matrix_row(G, weight: Incomplete | None = None, dtype=..., solver: str = "lu") -> Generator[Incomplete, None, None]: ... +def flow_matrix_row(G, weight=None, dtype=..., solver: str = "lu") -> Generator[Incomplete, None, None]: ... class InverseLaplacian: dtype: Incomplete @@ -13,7 +13,7 @@ class InverseLaplacian: C: Incomplete L1: Incomplete - def __init__(self, L, width: Incomplete | None = None, dtype: Incomplete | None = None) -> None: ... + def __init__(self, L, width=None, dtype=None) -> None: ... def init_solver(self, L) -> None: ... def solve(self, r) -> None: ... def solve_inverse(self, r) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi b/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi index 95d68ca34d7d..a42df3648687 100644 --- a/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi +++ b/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi @@ -19,7 +19,7 @@ __all__ = [ @_dispatchable def strategy_largest_first(G: Graph[Incomplete], colors): ... @_dispatchable -def strategy_random_sequential(G: Graph[Incomplete], colors, seed: Incomplete | None = None): ... +def strategy_random_sequential(G: Graph[Incomplete], colors, seed=None): ... @_dispatchable def strategy_smallest_last(G: Graph[Incomplete], colors): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi index a76499ed63e0..7a8dbab566fc 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi @@ -12,12 +12,7 @@ class ISMAGS: edge_equality: Incomplete def __init__( - self, - graph: Graph[Incomplete], - subgraph: Graph[Incomplete], - node_match: Incomplete | None = None, - edge_match: Incomplete | None = None, - cache: Incomplete | None = None, + self, graph: Graph[Incomplete], subgraph: Graph[Incomplete], node_match=None, edge_match=None, cache=None ) -> None: ... def find_isomorphisms(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, Incomplete]: ... def largest_common_subgraph(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, None]: ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi b/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi index 46762afbf8a7..17398cfb92aa 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi @@ -56,7 +56,7 @@ class GMState: G2_node: Incomplete depth: Incomplete - def __init__(self, GM, G1_node: Incomplete | None = None, G2_node: Incomplete | None = None) -> None: ... + def __init__(self, GM, G1_node=None, G2_node=None) -> None: ... def restore(self) -> None: ... class DiGMState: @@ -65,5 +65,5 @@ class DiGMState: G2_node: Incomplete depth: Incomplete - def __init__(self, GM, G1_node: Incomplete | None = None, G2_node: Incomplete | None = None) -> None: ... + def __init__(self, GM, G1_node=None, G2_node=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 3a7a377e283e..e2ed27e5eac0 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi @@ -24,8 +24,8 @@ class TimeRespectingDiGraphMatcher(DiGraphMatcher): def one_hop(self, Gx, Gx_node, core_x, pred, succ): ... def two_hop_pred(self, Gx, Gx_node, core_x, pred): ... def two_hop_succ(self, Gx, Gx_node, core_x, succ): ... - def preds(self, Gx, core_x, v, Gx_node: Incomplete | None = None): ... - def succs(self, Gx, core_x, v, Gx_node: Incomplete | None = None): ... + def preds(self, Gx, core_x, v, Gx_node=None): ... + def succs(self, Gx, core_x, v, Gx_node=None): ... def test_one(self, pred_dates, succ_dates): ... def test_two(self, pred_dates, succ_dates): ... def semantic_feasibility(self, G1_node, G2_node): ... diff --git a/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi b/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi index 480a56cfdf5e..ab7a8e5472cd 100644 --- a/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi +++ b/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi @@ -10,7 +10,7 @@ __all__ = ["all_pairs_lowest_common_ancestor", "tree_all_pairs_lowest_common_anc @_dispatchable def all_pairs_lowest_common_ancestor(G: DiGraph[_Node], pairs=None): ... @_dispatchable -def lowest_common_ancestor(G: DiGraph[_Node], node1, node2, default: Incomplete | None = None): ... +def lowest_common_ancestor(G: DiGraph[_Node], node1, node2, default=None): ... @_dispatchable def tree_all_pairs_lowest_common_ancestor( G: DiGraph[_Node], root: _Node | None = None, pairs=None diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index b170abc38651..acfea6304e55 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -20,7 +20,7 @@ class Interval: low: Incomplete high: Incomplete - def __init__(self, low: Incomplete | None = None, high: Incomplete | None = None) -> None: ... + def __init__(self, low=None, high=None) -> None: ... def empty(self): ... def copy(self): ... def conflicting(self, b, planarity_state): ... diff --git a/stubs/networkx/networkx/algorithms/vitality.pyi b/stubs/networkx/networkx/algorithms/vitality.pyi index 571aa0d4db44..3fd2cfe0e482 100644 --- a/stubs/networkx/networkx/algorithms/vitality.pyi +++ b/stubs/networkx/networkx/algorithms/vitality.pyi @@ -7,5 +7,5 @@ __all__ = ["closeness_vitality"] @_dispatchable def closeness_vitality( - G: Graph[_Node], node: Incomplete | None = None, weight: str | None = None, wiener_index: float | None = None + G: Graph[_Node], node=None, weight: str | None = None, wiener_index: float | None = None ) -> float | dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index 6bc5cc82c727..3e2cc17410ed 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -53,8 +53,8 @@ __all__ = [ _U = TypeVar("_U") def nodes(G: Graph[Incomplete]): ... -def edges(G: Graph[Incomplete], nbunch: Incomplete | None = None): ... -def degree(G: Graph[Incomplete], nbunch: Incomplete | None = None, weight: Incomplete | None = None): ... +def edges(G: Graph[Incomplete], nbunch=None): ... +def degree(G: Graph[Incomplete], nbunch=None, weight=None): ... def neighbors(G: Graph[Incomplete], n): ... def number_of_nodes(G: Graph[Incomplete]): ... def number_of_edges(G: Graph[Incomplete]): ... diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi index 2e7055ced3b9..4b8fbcce1aba 100644 --- a/stubs/networkx/networkx/classes/graph.pyi +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -79,7 +79,7 @@ class Graph(Collection[_Node]): def neighbors(self, n: _Node) -> Iterator[_Node]: ... @cached_property def edges(self) -> OutEdgeView[_Node]: ... - def get_edge_data(self, u: _Node, v: _Node, default: Incomplete | None = None) -> Mapping[str, Incomplete]: ... + def get_edge_data(self, u: _Node, v: _Node, default=None) -> Mapping[str, Incomplete]: ... def adjacency(self) -> Iterator[tuple[_Node, Mapping[_Node, Mapping[str, Incomplete]]]]: ... @cached_property def degree(self) -> DegreeView[_Node] | DiDegreeView[_Node]: ... # Include subtypes' possible return types diff --git a/stubs/networkx/networkx/classes/multigraph.pyi b/stubs/networkx/networkx/classes/multigraph.pyi index 48d5435f345f..be94eae5f18f 100644 --- a/stubs/networkx/networkx/classes/multigraph.pyi +++ b/stubs/networkx/networkx/classes/multigraph.pyi @@ -17,17 +17,17 @@ class MultiGraph(Graph[_Node]): edge_key_dict_factory: ClassVar[_MapFactory] def to_directed_class(self) -> type[MultiDiGraph[_Node]]: ... def to_undirected_class(self) -> type[MultiGraph[_Node]]: ... - def __init__(self, incoming_graph_data: Incomplete | None = None, multigraph_input: bool | None = None, **attr) -> None: ... + def __init__(self, incoming_graph_data=None, multigraph_input: bool | None = None, **attr) -> None: ... @cached_property def adj(self) -> MultiAdjacencyView[_Node, _Node, dict[str, Incomplete]]: ... def new_edge_key(self, u: _Node, v: _Node) -> int: ... - def add_edge(self, u_for_edge, v_for_edge, key: Incomplete | None = None, **attr): ... # type: ignore[override] # Has an additional `key` keyword argument - def remove_edge(self, u, v, key: Incomplete | None = None): ... - def has_edge(self, u, v, key: Incomplete | None = None) -> bool: ... + def add_edge(self, u_for_edge, v_for_edge, key=None, **attr): ... # type: ignore[override] # Has an additional `key` keyword argument + def remove_edge(self, u, v, key=None): ... + def has_edge(self, u, v, key=None) -> bool: ... @cached_property def edges(self) -> MultiEdgeView[_Node] | OutMultiEdgeView[_Node]: ... # Include subtypes' possible return types def get_edge_data( # type: ignore[override] # Has an additional `key` keyword argument - self, u, v, key: Incomplete | None = None, default: Incomplete | None = None + self, u, v, key=None, default=None ) -> Mapping[str, Incomplete]: ... @cached_property def degree(self) -> MultiDegreeView[_Node] | DiMultiDegreeView[_Node]: ... # Include subtypes' possible return types diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index 44ad01a7eda0..6a97d9a176ab 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -41,17 +41,13 @@ class NodeView(Mapping[_Node, dict[str, Any]], AbstractSet[_Node]): def __getitem__(self, n: _Node) -> dict[str, Any]: ... def __contains__(self, n: object) -> bool: ... @overload - def __call__(self, data: Literal[False] = False, default: Incomplete | None = None) -> Iterator[_Node]: ... + def __call__(self, data: Literal[False] = False, default=None) -> Iterator[_Node]: ... @overload - def __call__( - self, data: Literal[True] | str, default: Incomplete | None = None - ) -> Iterator[tuple[_Node, dict[str, Any]]]: ... - def data(self, data: bool | str = True, default: Incomplete | None = None) -> NodeDataView[_Node]: ... + def __call__(self, data: Literal[True] | str, default=None) -> Iterator[tuple[_Node, dict[str, Any]]]: ... + def data(self, data: bool | str = True, default=None) -> NodeDataView[_Node]: ... class NodeDataView(AbstractSet[_Node]): - def __init__( - self, nodedict: Mapping[str, Incomplete], data: bool | str = False, default: Incomplete | None = None - ) -> None: ... + def __init__(self, nodedict: Mapping[str, Incomplete], data: bool | str = False, default=None) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[tuple[_Node, Incomplete]]: ... # type: ignore[override] def __contains__(self, n: object) -> bool: ... @@ -74,9 +70,7 @@ class OutMultiDegreeView(DiDegreeView[_Node]): ... class EdgeViewABC(ABC): ... class OutEdgeDataView(EdgeViewABC, Generic[_Node, _D]): - def __init__( - self, viewer, nbunch: _NBunch[_Node] = None, data: bool = False, *, default: Incomplete | None = None - ) -> None: ... + def __init__(self, viewer, nbunch: _NBunch[_Node] = None, data: bool = False, *, default=None) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_D]: ... def __contains__(self, e: _Edge[_Node]) -> bool: ... @@ -87,7 +81,7 @@ class InEdgeDataView(OutEdgeDataView[_Node, _D]): ... class OutMultiEdgeDataView(OutEdgeDataView[_Node, _D]): keys: bool def __init__( - self, viewer, nbunch: _NBunch[_Node] = None, data: bool = False, *, default: Incomplete | None = None, keys: bool = False + self, viewer, nbunch: _NBunch[_Node] = None, data: bool = False, *, default=None, keys: bool = False ) -> None: ... class MultiEdgeDataView(OutEdgeDataView[_Node, _D]): ... diff --git a/stubs/networkx/networkx/convert.pyi b/stubs/networkx/networkx/convert.pyi index 170c3765420d..1c17923afb50 100644 --- a/stubs/networkx/networkx/convert.pyi +++ b/stubs/networkx/networkx/convert.pyi @@ -20,7 +20,7 @@ def to_networkx_graph( @_dispatchable def to_dict_of_lists(G: Graph[_Node], nodelist: Collection[_Node] | None = None) -> dict[_Node, list[_Node]]: ... @_dispatchable -def from_dict_of_lists(d: dict[_Node, Iterable[_Node]], create_using: Incomplete | None = None) -> Graph[_Node]: ... +def from_dict_of_lists(d: dict[_Node, Iterable[_Node]], create_using=None) -> Graph[_Node]: ... def to_dict_of_dicts( G: Graph[_Node], nodelist: Collection[_Node] | None = None, edge_data=None ) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/drawing/layout.pyi b/stubs/networkx/networkx/drawing/layout.pyi index 68cb019b0634..c8ccf266e25a 100644 --- a/stubs/networkx/networkx/drawing/layout.pyi +++ b/stubs/networkx/networkx/drawing/layout.pyi @@ -25,18 +25,13 @@ __all__ = [ ] def random_layout( - G: Graph[Incomplete], center: ArrayLike | None = None, dim: int = 2, seed: Incomplete | None = None + G: Graph[Incomplete], center: ArrayLike | None = None, dim: int = 2, seed=None ) -> dict[Incomplete, Incomplete]: ... def circular_layout( G: Graph[Incomplete], scale: float = 1, center: ArrayLike | None = None, dim: int = 2 ) -> dict[Incomplete, Incomplete]: ... def shell_layout( - G: Graph[Incomplete], - nlist: Incomplete | None = None, - rotate: Incomplete | None = None, - scale: float = 1, - center: ArrayLike | None = None, - dim: int = 2, + G: Graph[Incomplete], nlist=None, rotate=None, scale: float = 1, center: ArrayLike | None = None, dim: int = 2 ) -> dict[Incomplete, Incomplete]: ... def bipartite_layout( G: Graph[Incomplete], @@ -48,24 +43,24 @@ def bipartite_layout( ) -> dict[Incomplete, Incomplete]: ... def spring_layout( G: Graph[Incomplete], - k: Incomplete | None = None, - pos: Incomplete | None = None, - fixed: Incomplete | None = None, + k=None, + pos=None, + fixed=None, iterations: int = 50, threshold: float = 0.0001, weight: str = "weight", scale: float = 1, center: ArrayLike | None = None, dim: int = 2, - seed: Incomplete | None = None, + seed=None, ) -> dict[Incomplete, Incomplete]: ... fruchterman_reingold_layout = spring_layout def kamada_kawai_layout( G: Graph[Incomplete], - dist: Incomplete | None = None, - pos: Incomplete | None = None, + dist=None, + pos=None, weight: str = "weight", scale: float = 1, center: ArrayLike | None = None, @@ -90,7 +85,7 @@ def multipartite_layout( ) -> dict[Incomplete, Incomplete]: ... def arf_layout( G: Graph[Incomplete], - pos: Incomplete | None = None, + pos=None, scaling: float = 1, a: float = 1.1, etol: float = 1e-06, diff --git a/stubs/networkx/networkx/drawing/nx_agraph.pyi b/stubs/networkx/networkx/drawing/nx_agraph.pyi index d025372bf85d..5916f4501f13 100644 --- a/stubs/networkx/networkx/drawing/nx_agraph.pyi +++ b/stubs/networkx/networkx/drawing/nx_agraph.pyi @@ -13,7 +13,7 @@ _AGraph: TypeAlias = Incomplete __all__ = ["from_agraph", "to_agraph", "write_dot", "read_dot", "graphviz_layout", "pygraphviz_layout", "view_pygraphviz"] @_dispatchable -def from_agraph(A, create_using: Incomplete | None = None) -> Graph[Incomplete]: ... +def from_agraph(A, create_using=None) -> Graph[Incomplete]: ... def to_agraph(N: Graph[Hashable]) -> _AGraph: ... def write_dot(G: Graph[Hashable], path: str | TextIOBase) -> None: ... @_dispatchable diff --git a/stubs/networkx/networkx/drawing/nx_latex.pyi b/stubs/networkx/networkx/drawing/nx_latex.pyi index a7ca26c18821..1dcf1df0f7a8 100644 --- a/stubs/networkx/networkx/drawing/nx_latex.pyi +++ b/stubs/networkx/networkx/drawing/nx_latex.pyi @@ -1,5 +1,3 @@ -from _typeshed import Incomplete - __all__ = ["to_latex_raw", "to_latex", "write_latex"] def to_latex_raw( @@ -27,8 +25,8 @@ def to_latex( edge_label_options: str = "edge_label_options", caption: str = "", latex_label: str = "", - sub_captions: Incomplete | None = None, - sub_labels: Incomplete | None = None, + sub_captions=None, + sub_labels=None, n_rows: int = 1, as_document: bool = True, document_wrapper: str = ..., diff --git a/stubs/networkx/networkx/drawing/nx_pydot.pyi b/stubs/networkx/networkx/drawing/nx_pydot.pyi index d36a968f6409..652dd17c9b1c 100644 --- a/stubs/networkx/networkx/drawing/nx_pydot.pyi +++ b/stubs/networkx/networkx/drawing/nx_pydot.pyi @@ -12,5 +12,5 @@ def read_dot(path) -> Graph[Incomplete]: ... @_dispatchable def from_pydot(P): ... def to_pydot(N): ... -def graphviz_layout(G: Graph[Incomplete], prog: str = "neato", root: Incomplete | None = None): ... -def pydot_layout(G: Graph[Incomplete], prog: str = "neato", root: Incomplete | None = None): ... +def graphviz_layout(G: Graph[Incomplete], prog: str = "neato", root=None): ... +def pydot_layout(G: Graph[Incomplete], prog: str = "neato", root=None): ... diff --git a/stubs/networkx/networkx/drawing/nx_pylab.pyi b/stubs/networkx/networkx/drawing/nx_pylab.pyi index 0ce9242baa8c..f063560ef5c8 100644 --- a/stubs/networkx/networkx/drawing/nx_pylab.pyi +++ b/stubs/networkx/networkx/drawing/nx_pylab.pyi @@ -20,10 +20,8 @@ __all__ = [ "draw_forceatlas2", ] -def draw(G: Graph[Incomplete], pos: Incomplete | None = None, ax: Incomplete | None = None, **kwds) -> None: ... -def draw_networkx( - G: Graph[Incomplete], pos: Incomplete | None = None, arrows: Incomplete | None = None, with_labels: bool = True, **kwds -) -> None: ... +def draw(G: Graph[Incomplete], pos=None, ax=None, **kwds) -> None: ... +def draw_networkx(G: Graph[Incomplete], pos=None, arrows=None, with_labels: bool = True, **kwds) -> None: ... def draw_networkx_nodes( G: Graph[Incomplete], pos: Mapping[Incomplete, Incomplete], @@ -31,33 +29,33 @@ def draw_networkx_nodes( node_size: Incomplete | int = 300, node_color: str = "#1f78b4", node_shape: str = "o", - alpha: Incomplete | None = None, - cmap: Incomplete | None = None, - vmin: Incomplete | None = None, - vmax: Incomplete | None = None, - ax: Incomplete | None = None, - linewidths: Incomplete | None = None, - edgecolors: Incomplete | None = None, - label: Incomplete | None = None, - margins: Incomplete | None = None, + alpha=None, + cmap=None, + vmin=None, + vmax=None, + ax=None, + linewidths=None, + edgecolors=None, + label=None, + margins=None, hide_ticks: bool = True, ): ... def draw_networkx_edges( G: Graph[Incomplete], pos: Mapping[Incomplete, Incomplete], - edgelist: Incomplete | None = None, + edgelist=None, width: float = 1.0, edge_color: str = "k", style: str = "solid", - alpha: Incomplete | None = None, - arrowstyle: Incomplete | None = None, + alpha=None, + arrowstyle=None, arrowsize: int = 10, - edge_cmap: Incomplete | None = None, + edge_cmap=None, edge_vmin: float | None = None, edge_vmax: float | None = None, - ax: Incomplete | None = None, - arrows: Incomplete | None = None, - label: Incomplete | None = None, + ax=None, + arrows=None, + label=None, node_size: Incomplete | int = 300, nodelist: list[Incomplete] | None = None, node_shape: str = "o", @@ -69,33 +67,33 @@ def draw_networkx_edges( def draw_networkx_labels( G: Graph[Incomplete], pos: Mapping[Incomplete, Incomplete], - labels: Incomplete | None = None, + labels=None, font_size: int = 12, font_color: str = "k", font_family: str = "sans-serif", font_weight: str = "normal", - alpha: Incomplete | None = None, - bbox: Incomplete | None = None, + alpha=None, + bbox=None, horizontalalignment: str = "center", verticalalignment: str = "center", - ax: Incomplete | None = None, + ax=None, clip_on: bool = True, hide_ticks: bool = True, ): ... def draw_networkx_edge_labels( G: Graph[Incomplete], pos: Mapping[Incomplete, Incomplete], - edge_labels: Incomplete | None = None, + edge_labels=None, label_pos: float = 0.5, font_size: int = 10, font_color: str = "k", font_family: str = "sans-serif", font_weight: str = "normal", - alpha: Incomplete | None = None, - bbox: Incomplete | None = None, + alpha=None, + bbox=None, horizontalalignment: str = "center", verticalalignment: str = "center", - ax: Incomplete | None = None, + ax=None, rotate: bool = True, clip_on: bool = True, node_size: int = 300, @@ -108,7 +106,7 @@ def draw_kamada_kawai(G: Graph[Incomplete], **kwargs) -> None: ... def draw_random(G: Graph[Incomplete], **kwargs) -> None: ... def draw_spectral(G: Graph[Incomplete], **kwargs) -> None: ... def draw_spring(G: Graph[Incomplete], **kwargs) -> None: ... -def draw_shell(G: Graph[Incomplete], nlist: Incomplete | None = None, **kwargs) -> None: ... +def draw_shell(G: Graph[Incomplete], nlist=None, **kwargs) -> None: ... def draw_planar(G: Graph[Incomplete], **kwargs) -> None: ... def draw_forceatlas2(G, **kwargs) -> None: ... def apply_alpha( diff --git a/stubs/networkx/networkx/generators/classic.pyi b/stubs/networkx/networkx/generators/classic.pyi index fd4e470a9bf1..80d8d286f656 100644 --- a/stubs/networkx/networkx/generators/classic.pyi +++ b/stubs/networkx/networkx/generators/classic.pyi @@ -29,44 +29,44 @@ __all__ = [ ] @_dispatchable -def full_rary_tree(r: int, n: int, create_using: Incomplete | None = None): ... +def full_rary_tree(r: int, n: int, create_using=None): ... @_dispatchable def kneser_graph(n, k) -> Graph[Incomplete]: ... @_dispatchable -def balanced_tree(r: int, h: int, create_using: Incomplete | None = None): ... +def balanced_tree(r: int, h: int, create_using=None): ... @_dispatchable -def barbell_graph(m1, m2, create_using: Incomplete | None = None): ... +def barbell_graph(m1, m2, create_using=None): ... @_dispatchable -def binomial_tree(n: int, create_using: Incomplete | None = None): ... +def binomial_tree(n: int, create_using=None): ... @_dispatchable -def complete_graph(n, create_using: Incomplete | None = None): ... +def complete_graph(n, create_using=None): ... @_dispatchable -def circular_ladder_graph(n, create_using: Incomplete | None = None): ... +def circular_ladder_graph(n, create_using=None): ... @_dispatchable -def circulant_graph(n, offsets, create_using: Incomplete | None = None): ... +def circulant_graph(n, offsets, create_using=None): ... @_dispatchable -def cycle_graph(n, create_using: Incomplete | None = None): ... +def cycle_graph(n, create_using=None): ... @_dispatchable -def dorogovtsev_goltsev_mendes_graph(n, create_using: Incomplete | None = None): ... +def dorogovtsev_goltsev_mendes_graph(n, create_using=None): ... @_dispatchable -def empty_graph(n: int | Iterable[Incomplete] = 0, create_using: Incomplete | None = None, default=...): ... +def empty_graph(n: int | Iterable[Incomplete] = 0, create_using=None, default=...): ... @_dispatchable -def ladder_graph(n, create_using: Incomplete | None = None): ... +def ladder_graph(n, create_using=None): ... @_dispatchable -def lollipop_graph(m, n, create_using: Incomplete | None = None): ... +def lollipop_graph(m, n, create_using=None): ... @_dispatchable -def null_graph(create_using: Incomplete | None = None): ... +def null_graph(create_using=None): ... @_dispatchable -def path_graph(n: int | Iterable[Incomplete], create_using: Incomplete | None = None): ... +def path_graph(n: int | Iterable[Incomplete], create_using=None): ... @_dispatchable -def star_graph(n: int | Iterable[Incomplete], create_using: Incomplete | None = None): ... +def star_graph(n: int | Iterable[Incomplete], create_using=None): ... @_dispatchable def tadpole_graph(m, n, create_using=None) -> Graph[Incomplete] | Incomplete: ... @_dispatchable -def trivial_graph(create_using: Incomplete | None = None): ... +def trivial_graph(create_using=None): ... @_dispatchable def turan_graph(n: int, r: int): ... @_dispatchable -def wheel_graph(n: int | Iterable[Incomplete], create_using: Incomplete | None = None): ... +def wheel_graph(n: int | Iterable[Incomplete], create_using=None): ... @_dispatchable def complete_multipartite_graph(*subset_sizes): ... diff --git a/stubs/networkx/networkx/generators/cographs.pyi b/stubs/networkx/networkx/generators/cographs.pyi index 2b37b256787b..d7af20579015 100644 --- a/stubs/networkx/networkx/generators/cographs.pyi +++ b/stubs/networkx/networkx/generators/cographs.pyi @@ -1,8 +1,6 @@ -from _typeshed import Incomplete - from networkx.utils.backends import _dispatchable __all__ = ["random_cograph"] @_dispatchable -def random_cograph(n: int, seed: Incomplete | None = None): ... +def random_cograph(n: int, seed=None): ... diff --git a/stubs/networkx/networkx/generators/community.pyi b/stubs/networkx/networkx/generators/community.pyi index b43955a9528c..1c747f0b724d 100644 --- a/stubs/networkx/networkx/generators/community.pyi +++ b/stubs/networkx/networkx/generators/community.pyi @@ -21,15 +21,13 @@ def caveman_graph(l: int, k: int): ... @_dispatchable def connected_caveman_graph(l: int, k: int): ... @_dispatchable -def relaxed_caveman_graph(l: int, k: int, p: float, seed: Incomplete | None = None): ... +def relaxed_caveman_graph(l: int, k: int, p: float, seed=None): ... @_dispatchable -def random_partition_graph(sizes: Collection[int], p_in: float, p_out: float, seed: Incomplete | None = None, directed=False): ... +def random_partition_graph(sizes: Collection[int], p_in: float, p_out: float, seed=None, directed=False): ... @_dispatchable -def planted_partition_graph(l: int, k: int, p_in: float, p_out: float, seed: Incomplete | None = None, directed=False): ... +def planted_partition_graph(l: int, k: int, p_in: float, p_out: float, seed=None, directed=False): ... @_dispatchable -def gaussian_random_partition_graph( - n: int, s: float, v: float, p_in: float, p_out: float, directed=False, seed: Incomplete | None = None -): ... +def gaussian_random_partition_graph(n: int, s: float, v: float, p_in: float, p_out: float, directed=False, seed=None): ... @_dispatchable def ring_of_cliques(num_cliques: int, clique_size: int): ... @_dispatchable @@ -39,7 +37,7 @@ def stochastic_block_model( sizes: Collection[int], p, nodelist: Collection[Incomplete] | None = None, - seed: Incomplete | None = None, + seed=None, directed: bool = False, selfloops: bool = False, sparse: bool = True, @@ -57,5 +55,5 @@ def LFR_benchmark_graph( max_community: int | None = None, tol: float = 1.0e-7, max_iters: int = 500, - seed: Incomplete | None = None, + seed=None, ): ... diff --git a/stubs/networkx/networkx/generators/degree_seq.pyi b/stubs/networkx/networkx/generators/degree_seq.pyi index 3395239f0166..5e01f87e805d 100644 --- a/stubs/networkx/networkx/generators/degree_seq.pyi +++ b/stubs/networkx/networkx/generators/degree_seq.pyi @@ -21,25 +21,21 @@ __all__ = [ chaini = chain.from_iterable @_dispatchable -def configuration_model( - deg_sequence, create_using: Incomplete | None = None, seed: Incomplete | None = None -) -> MultiGraph[Incomplete]: ... +def configuration_model(deg_sequence, create_using=None, seed=None) -> MultiGraph[Incomplete]: ... @_dispatchable def directed_configuration_model( - in_degree_sequence, out_degree_sequence, create_using: Incomplete | None = None, seed: Incomplete | None = None + in_degree_sequence, out_degree_sequence, create_using=None, seed=None ) -> MultiDiGraph[Incomplete]: ... @_dispatchable -def expected_degree_graph(w: Collection[float], seed: Incomplete | None = None, selfloops: bool = True) -> Graph[Incomplete]: ... +def expected_degree_graph(w: Collection[float], seed=None, selfloops: bool = True) -> Graph[Incomplete]: ... @_dispatchable -def havel_hakimi_graph(deg_sequence, create_using: Incomplete | None = None): ... +def havel_hakimi_graph(deg_sequence, create_using=None): ... @_dispatchable -def directed_havel_hakimi_graph( - in_deg_sequence, out_deg_sequence, create_using: Incomplete | None = None -) -> DiGraph[Incomplete]: ... +def directed_havel_hakimi_graph(in_deg_sequence, out_deg_sequence, create_using=None) -> DiGraph[Incomplete]: ... @_dispatchable -def degree_sequence_tree(deg_sequence, create_using: Incomplete | None = None): ... +def degree_sequence_tree(deg_sequence, create_using=None): ... @_dispatchable -def random_degree_sequence_graph(sequence, seed: Incomplete | None = None, tries: int = 10) -> Graph[Incomplete]: ... +def random_degree_sequence_graph(sequence, seed=None, tries: int = 10) -> Graph[Incomplete]: ... class DegreeSequenceRandomGraph: rng: Incomplete @@ -50,7 +46,7 @@ class DegreeSequenceRandomGraph: remaining_degree: Incomplete graph: Incomplete def generate(self): ... - def update_remaining(self, u, v, aux_graph: Incomplete | None = None) -> None: ... + def update_remaining(self, u, v, aux_graph=None) -> None: ... def p(self, u, v): ... def q(self, u, v): ... def suitable_edge(self): ... diff --git a/stubs/networkx/networkx/generators/directed.pyi b/stubs/networkx/networkx/generators/directed.pyi index dcbe9016e918..8aab39a754ff 100644 --- a/stubs/networkx/networkx/generators/directed.pyi +++ b/stubs/networkx/networkx/generators/directed.pyi @@ -1,5 +1,3 @@ -from _typeshed import Incomplete - from networkx.utils.backends import _dispatchable from ..classes import MultiDiGraph @@ -7,13 +5,11 @@ from ..classes import MultiDiGraph __all__ = ["gn_graph", "gnc_graph", "gnr_graph", "random_k_out_graph", "scale_free_graph"] @_dispatchable -def gn_graph( - n: int, kernel: Incomplete | None = None, create_using: Incomplete | None = None, seed: Incomplete | None = None -): ... +def gn_graph(n: int, kernel=None, create_using=None, seed=None): ... @_dispatchable -def gnr_graph(n: int, p: float, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... +def gnr_graph(n: int, p: float, create_using=None, seed=None): ... @_dispatchable -def gnc_graph(n: int, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... +def gnc_graph(n: int, create_using=None, seed=None): ... @_dispatchable def scale_free_graph( n, @@ -22,11 +18,11 @@ def scale_free_graph( gamma: float = 0.05, delta_in: float = 0.2, delta_out: float = 0, - create_using: Incomplete | None = None, - seed: Incomplete | None = None, - initial_graph: Incomplete | None = None, + create_using=None, + seed=None, + initial_graph=None, ): ... @_dispatchable def random_uniform_k_out_graph(n: int, k: int, self_loops: bool = True, with_replacement: bool = True, seed=None): ... @_dispatchable -def random_k_out_graph(n: int, k: int, alpha: float, self_loops: bool = True, seed: Incomplete | None = None) -> MultiDiGraph: ... +def random_k_out_graph(n: int, k: int, alpha: float, self_loops: bool = True, seed=None) -> MultiDiGraph: ... diff --git a/stubs/networkx/networkx/generators/duplication.pyi b/stubs/networkx/networkx/generators/duplication.pyi index 1f72a298ff89..0212e9c3b060 100644 --- a/stubs/networkx/networkx/generators/duplication.pyi +++ b/stubs/networkx/networkx/generators/duplication.pyi @@ -7,6 +7,6 @@ from ..classes.graph import Graph __all__ = ["partial_duplication_graph", "duplication_divergence_graph"] @_dispatchable -def partial_duplication_graph(N: int, n: int, p: float, q: float, seed: Incomplete | None = None): ... +def partial_duplication_graph(N: int, n: int, p: float, q: float, seed=None): ... @_dispatchable -def duplication_divergence_graph(n: int, p: float, seed: Incomplete | None = None) -> Graph[Incomplete]: ... +def duplication_divergence_graph(n: int, p: float, seed=None) -> Graph[Incomplete]: ... diff --git a/stubs/networkx/networkx/generators/ego.pyi b/stubs/networkx/networkx/generators/ego.pyi index 04a8ad211625..be0b44bfebe2 100644 --- a/stubs/networkx/networkx/generators/ego.pyi +++ b/stubs/networkx/networkx/generators/ego.pyi @@ -7,6 +7,4 @@ from ..classes.graph import Graph __all__ = ["ego_graph"] @_dispatchable -def ego_graph( - G: Graph[Incomplete], n, radius: float = 1, center: bool = True, undirected: bool = False, distance: Incomplete | None = None -): ... +def ego_graph(G: Graph[Incomplete], n, radius: float = 1, center: bool = True, undirected: bool = False, distance=None): ... diff --git a/stubs/networkx/networkx/generators/expanders.pyi b/stubs/networkx/networkx/generators/expanders.pyi index 4f3c87ee6e16..f9a606b5f04b 100644 --- a/stubs/networkx/networkx/generators/expanders.pyi +++ b/stubs/networkx/networkx/generators/expanders.pyi @@ -1,5 +1,3 @@ -from _typeshed import Incomplete - from networkx.utils.backends import _dispatchable __all__ = [ @@ -12,11 +10,11 @@ __all__ = [ ] @_dispatchable -def margulis_gabber_galil_graph(n: int, create_using: Incomplete | None = None): ... +def margulis_gabber_galil_graph(n: int, create_using=None): ... @_dispatchable -def chordal_cycle_graph(p, create_using: Incomplete | None = None): ... +def chordal_cycle_graph(p, create_using=None): ... @_dispatchable -def paley_graph(p, create_using: Incomplete | None = None): ... +def paley_graph(p, create_using=None): ... @_dispatchable def maybe_regular_expander(n, d, *, create_using=None, max_tries=100, seed=None): ... @_dispatchable diff --git a/stubs/networkx/networkx/generators/geometric.pyi b/stubs/networkx/networkx/generators/geometric.pyi index 023b80e76bf5..7d8c836a9e2f 100644 --- a/stubs/networkx/networkx/generators/geometric.pyi +++ b/stubs/networkx/networkx/generators/geometric.pyi @@ -24,7 +24,7 @@ def random_geometric_graph( dim: int = 2, pos: Mapping[Incomplete, Incomplete] | None = None, p: float = 2, - seed: Incomplete | None = None, + seed=None, ): ... @_dispatchable def soft_random_geometric_graph( @@ -33,8 +33,8 @@ def soft_random_geometric_graph( dim: int = 2, pos: Mapping[Incomplete, Incomplete] | None = None, p: float = 2, - p_dist: Incomplete | None = None, - seed: Incomplete | None = None, + p_dist=None, + seed=None, ): ... @_dispatchable def geographical_threshold_graph( @@ -43,9 +43,9 @@ def geographical_threshold_graph( dim: int = 2, pos: Mapping[Incomplete, Incomplete] | None = None, weight: Mapping[Incomplete, Incomplete] | None = None, - metric: Incomplete | None = None, - p_dist: Incomplete | None = None, - seed: Incomplete | None = None, + metric=None, + p_dist=None, + seed=None, ): ... @_dispatchable def waxman_graph( @@ -54,13 +54,13 @@ def waxman_graph( alpha: float = 0.1, L: float | None = None, domain=(0, 0, 1, 1), - metric: Incomplete | None = None, - seed: Incomplete | None = None, + metric=None, + seed=None, ) -> Graph[Incomplete]: ... # docstring marks p as int, but it still works with floats. So I think it's better for consistency @_dispatchable -def navigable_small_world_graph(n: int, p: float = 1, q: int = 1, r: float = 2, dim: int = 2, seed: Incomplete | None = None): ... +def navigable_small_world_graph(n: int, p: float = 1, q: int = 1, r: float = 2, dim: int = 2, seed=None): ... @_dispatchable def thresholded_random_geometric_graph( n: int | Iterable[Incomplete], @@ -70,7 +70,7 @@ def thresholded_random_geometric_graph( pos: Mapping[Incomplete, Incomplete] | None = None, weight: Mapping[Incomplete, Incomplete] | None = None, p: float = 2, - seed: Incomplete | None = None, + seed=None, ): ... @_dispatchable def geometric_soft_configuration_graph( diff --git a/stubs/networkx/networkx/generators/harary_graph.pyi b/stubs/networkx/networkx/generators/harary_graph.pyi index 341308b8992d..2f709f2c94bd 100644 --- a/stubs/networkx/networkx/generators/harary_graph.pyi +++ b/stubs/networkx/networkx/generators/harary_graph.pyi @@ -1,10 +1,8 @@ -from _typeshed import Incomplete - from networkx.utils.backends import _dispatchable __all__ = ["hnm_harary_graph", "hkn_harary_graph"] @_dispatchable -def hnm_harary_graph(n, m, create_using: Incomplete | None = None): ... +def hnm_harary_graph(n, m, create_using=None): ... @_dispatchable -def hkn_harary_graph(k, n, create_using: Incomplete | None = None): ... +def hkn_harary_graph(k, n, create_using=None): ... diff --git a/stubs/networkx/networkx/generators/internet_as_graphs.pyi b/stubs/networkx/networkx/generators/internet_as_graphs.pyi index 4f525f03405d..74b8753d6c1c 100644 --- a/stubs/networkx/networkx/generators/internet_as_graphs.pyi +++ b/stubs/networkx/networkx/generators/internet_as_graphs.pyi @@ -42,4 +42,4 @@ class AS_graph_generator: def generate(self): ... @_dispatchable -def random_internet_as_graph(n, seed: Incomplete | None = None): ... +def random_internet_as_graph(n, seed=None): ... diff --git a/stubs/networkx/networkx/generators/intersection.pyi b/stubs/networkx/networkx/generators/intersection.pyi index f969f7707a4b..5897e64e1608 100644 --- a/stubs/networkx/networkx/generators/intersection.pyi +++ b/stubs/networkx/networkx/generators/intersection.pyi @@ -1,12 +1,10 @@ -from _typeshed import Incomplete - from networkx.utils.backends import _dispatchable __all__ = ["uniform_random_intersection_graph", "k_random_intersection_graph", "general_random_intersection_graph"] @_dispatchable -def uniform_random_intersection_graph(n: int, m: int, p: float, seed: Incomplete | None = None): ... +def uniform_random_intersection_graph(n: int, m: int, p: float, seed=None): ... @_dispatchable -def k_random_intersection_graph(n: int, m: int, k: float, seed: Incomplete | None = None): ... +def k_random_intersection_graph(n: int, m: int, k: float, seed=None): ... @_dispatchable -def general_random_intersection_graph(n: int, m: int, p, seed: Incomplete | None = None): ... +def general_random_intersection_graph(n: int, m: int, p, seed=None): ... diff --git a/stubs/networkx/networkx/generators/joint_degree_seq.pyi b/stubs/networkx/networkx/generators/joint_degree_seq.pyi index 3a291152db67..622c3b59e9ec 100644 --- a/stubs/networkx/networkx/generators/joint_degree_seq.pyi +++ b/stubs/networkx/networkx/generators/joint_degree_seq.pyi @@ -9,8 +9,8 @@ __all__ = ["is_valid_joint_degree", "is_valid_directed_joint_degree", "joint_deg @_dispatchable def is_valid_joint_degree(joint_degrees) -> bool: ... @_dispatchable -def joint_degree_graph(joint_degrees, seed: Incomplete | None = None) -> Graph[Incomplete]: ... +def joint_degree_graph(joint_degrees, seed=None) -> Graph[Incomplete]: ... @_dispatchable def is_valid_directed_joint_degree(in_degrees, out_degrees, nkk) -> bool: ... @_dispatchable -def directed_joint_degree_graph(in_degrees, out_degrees, nkk, seed: Incomplete | None = None) -> Graph[Incomplete]: ... +def directed_joint_degree_graph(in_degrees, out_degrees, nkk, seed=None) -> Graph[Incomplete]: ... diff --git a/stubs/networkx/networkx/generators/lattice.pyi b/stubs/networkx/networkx/generators/lattice.pyi index 5825351e2b6b..0e326fed87db 100644 --- a/stubs/networkx/networkx/generators/lattice.pyi +++ b/stubs/networkx/networkx/generators/lattice.pyi @@ -1,4 +1,3 @@ -from _typeshed import Incomplete from collections.abc import Iterable from networkx.utils.backends import _dispatchable @@ -6,16 +5,12 @@ from networkx.utils.backends import _dispatchable __all__ = ["grid_2d_graph", "grid_graph", "hypercube_graph", "triangular_lattice_graph", "hexagonal_lattice_graph"] @_dispatchable -def grid_2d_graph(m, n, periodic: bool | tuple[bool, bool] = False, create_using: Incomplete | None = None): ... +def grid_2d_graph(m, n, periodic: bool | tuple[bool, bool] = False, create_using=None): ... @_dispatchable def grid_graph(dim, periodic: bool | Iterable[bool] = False): ... @_dispatchable def hypercube_graph(n): ... @_dispatchable -def triangular_lattice_graph( - m: int, n: int, periodic: bool = False, with_positions: bool = True, create_using: Incomplete | None = None -): ... +def triangular_lattice_graph(m: int, n: int, periodic: bool = False, with_positions: bool = True, create_using=None): ... @_dispatchable -def hexagonal_lattice_graph( - m: int, n: int, periodic: bool = False, with_positions: bool = True, create_using: Incomplete | None = None -): ... +def hexagonal_lattice_graph(m: int, n: int, periodic: bool = False, with_positions: bool = True, create_using=None): ... diff --git a/stubs/networkx/networkx/generators/line.pyi b/stubs/networkx/networkx/generators/line.pyi index e6f4b397eb5d..9c22195b6bb9 100644 --- a/stubs/networkx/networkx/generators/line.pyi +++ b/stubs/networkx/networkx/generators/line.pyi @@ -7,6 +7,6 @@ from ..classes.graph import Graph __all__ = ["line_graph", "inverse_line_graph"] @_dispatchable -def line_graph(G: Graph[Incomplete], create_using: Incomplete | None = None): ... +def line_graph(G: Graph[Incomplete], create_using=None): ... @_dispatchable def inverse_line_graph(G: Graph[Incomplete]): ... diff --git a/stubs/networkx/networkx/generators/random_graphs.pyi b/stubs/networkx/networkx/generators/random_graphs.pyi index 7463608b5854..48a0dd569420 100644 --- a/stubs/networkx/networkx/generators/random_graphs.pyi +++ b/stubs/networkx/networkx/generators/random_graphs.pyi @@ -27,44 +27,42 @@ __all__ = [ ] @_dispatchable -def fast_gnp_random_graph(n: int, p: float, seed: Incomplete | None = None, directed: bool = False): ... +def fast_gnp_random_graph(n: int, p: float, seed=None, directed: bool = False): ... @_dispatchable -def gnp_random_graph(n: int, p: float, seed: Incomplete | None = None, directed: bool = False): ... +def gnp_random_graph(n: int, p: float, seed=None, directed: bool = False): ... binomial_graph = gnp_random_graph erdos_renyi_graph = gnp_random_graph @_dispatchable -def dense_gnm_random_graph(n: int, m: int, seed: Incomplete | None = None): ... +def dense_gnm_random_graph(n: int, m: int, seed=None): ... @_dispatchable -def gnm_random_graph(n: int, m: int, seed: Incomplete | None = None, directed: bool = False): ... +def gnm_random_graph(n: int, m: int, seed=None, directed: bool = False): ... @_dispatchable -def newman_watts_strogatz_graph(n: int, k: int, p: float, seed: Incomplete | None = None): ... +def newman_watts_strogatz_graph(n: int, k: int, p: float, seed=None): ... @_dispatchable -def watts_strogatz_graph(n: int, k: int, p: float, seed: Incomplete | None = None): ... +def watts_strogatz_graph(n: int, k: int, p: float, seed=None): ... @_dispatchable -def connected_watts_strogatz_graph(n: int, k: int, p: float, tries: int = 100, seed: Incomplete | None = None): ... +def connected_watts_strogatz_graph(n: int, k: int, p: float, tries: int = 100, seed=None): ... @_dispatchable -def random_regular_graph(d, n: int, seed: Incomplete | None = None): ... +def random_regular_graph(d, n: int, seed=None): ... @_dispatchable -def barabasi_albert_graph( - n: int, m: int, seed: Incomplete | None = None, initial_graph: Graph[Incomplete] | None = None -) -> Graph[Incomplete]: ... +def barabasi_albert_graph(n: int, m: int, seed=None, initial_graph: Graph[Incomplete] | None = None) -> Graph[Incomplete]: ... @_dispatchable def dual_barabasi_albert_graph( - n: int, m1, m2, p: float, seed: Incomplete | None = None, initial_graph: Graph[Incomplete] | None = None + n: int, m1, m2, p: float, seed=None, initial_graph: Graph[Incomplete] | None = None ) -> Graph[Incomplete]: ... @_dispatchable -def extended_barabasi_albert_graph(n: int, m: int, p: float, q, seed: Incomplete | None = None) -> Graph[Incomplete]: ... +def extended_barabasi_albert_graph(n: int, m: int, p: float, q, seed=None) -> Graph[Incomplete]: ... @_dispatchable -def powerlaw_cluster_graph(n: int, m: int, p: float, seed: Incomplete | None = None): ... +def powerlaw_cluster_graph(n: int, m: int, p: float, seed=None): ... @_dispatchable -def random_lobster(n: int, p1: float, p2: float, seed: Incomplete | None = None): ... +def random_lobster(n: int, p1: float, p2: float, seed=None): ... @_dispatchable -def random_shell_graph(constructor, seed: Incomplete | None = None): ... +def random_shell_graph(constructor, seed=None): ... @_dispatchable -def random_powerlaw_tree(n: int, gamma: float = 3, seed: Incomplete | None = None, tries: int = 100): ... +def random_powerlaw_tree(n: int, gamma: float = 3, seed=None, tries: int = 100): ... @_dispatchable -def random_powerlaw_tree_sequence(n: int, gamma: float = 3, seed: Incomplete | None = None, tries: int = 100): ... +def random_powerlaw_tree_sequence(n: int, gamma: float = 3, seed=None, tries: int = 100): ... @_dispatchable -def random_kernel_graph(n: int, kernel_integral, kernel_root: Incomplete | None = None, seed: Incomplete | None = None): ... +def random_kernel_graph(n: int, kernel_integral, kernel_root=None, seed=None): ... diff --git a/stubs/networkx/networkx/generators/small.pyi b/stubs/networkx/networkx/generators/small.pyi index 97c1057d8a02..4d5f7dc952a9 100644 --- a/stubs/networkx/networkx/generators/small.pyi +++ b/stubs/networkx/networkx/generators/small.pyi @@ -1,5 +1,3 @@ -from _typeshed import Incomplete - from networkx.utils.backends import _dispatchable __all__ = [ @@ -29,48 +27,48 @@ __all__ = [ ] @_dispatchable -def LCF_graph(n, shift_list, repeats, create_using: Incomplete | None = None): ... +def LCF_graph(n, shift_list, repeats, create_using=None): ... @_dispatchable -def bull_graph(create_using: Incomplete | None = None): ... +def bull_graph(create_using=None): ... @_dispatchable -def chvatal_graph(create_using: Incomplete | None = None): ... +def chvatal_graph(create_using=None): ... @_dispatchable -def cubical_graph(create_using: Incomplete | None = None): ... +def cubical_graph(create_using=None): ... @_dispatchable -def desargues_graph(create_using: Incomplete | None = None): ... +def desargues_graph(create_using=None): ... @_dispatchable -def diamond_graph(create_using: Incomplete | None = None): ... +def diamond_graph(create_using=None): ... @_dispatchable -def dodecahedral_graph(create_using: Incomplete | None = None): ... +def dodecahedral_graph(create_using=None): ... @_dispatchable -def frucht_graph(create_using: Incomplete | None = None): ... +def frucht_graph(create_using=None): ... @_dispatchable -def heawood_graph(create_using: Incomplete | None = None): ... +def heawood_graph(create_using=None): ... @_dispatchable def hoffman_singleton_graph(): ... @_dispatchable -def house_graph(create_using: Incomplete | None = None): ... +def house_graph(create_using=None): ... @_dispatchable -def house_x_graph(create_using: Incomplete | None = None): ... +def house_x_graph(create_using=None): ... @_dispatchable -def icosahedral_graph(create_using: Incomplete | None = None): ... +def icosahedral_graph(create_using=None): ... @_dispatchable -def krackhardt_kite_graph(create_using: Incomplete | None = None): ... +def krackhardt_kite_graph(create_using=None): ... @_dispatchable -def moebius_kantor_graph(create_using: Incomplete | None = None): ... +def moebius_kantor_graph(create_using=None): ... @_dispatchable -def octahedral_graph(create_using: Incomplete | None = None): ... +def octahedral_graph(create_using=None): ... @_dispatchable def pappus_graph(): ... @_dispatchable -def petersen_graph(create_using: Incomplete | None = None): ... +def petersen_graph(create_using=None): ... @_dispatchable -def sedgewick_maze_graph(create_using: Incomplete | None = None): ... +def sedgewick_maze_graph(create_using=None): ... @_dispatchable -def tetrahedral_graph(create_using: Incomplete | None = None): ... +def tetrahedral_graph(create_using=None): ... @_dispatchable -def truncated_cube_graph(create_using: Incomplete | None = None): ... +def truncated_cube_graph(create_using=None): ... @_dispatchable -def truncated_tetrahedron_graph(create_using: Incomplete | None = None): ... +def truncated_tetrahedron_graph(create_using=None): ... @_dispatchable -def tutte_graph(create_using: Incomplete | None = None): ... +def tutte_graph(create_using=None): ... diff --git a/stubs/networkx/networkx/generators/spectral_graph_forge.pyi b/stubs/networkx/networkx/generators/spectral_graph_forge.pyi index beb70434ad01..9af6bab45043 100644 --- a/stubs/networkx/networkx/generators/spectral_graph_forge.pyi +++ b/stubs/networkx/networkx/generators/spectral_graph_forge.pyi @@ -8,5 +8,5 @@ __all__ = ["spectral_graph_forge"] @_dispatchable def spectral_graph_forge( - G: Graph[Incomplete], alpha: float, transformation: str = "identity", seed: Incomplete | None = None + G: Graph[Incomplete], alpha: float, transformation: str = "identity", seed=None ) -> Graph[Incomplete]: ... diff --git a/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi b/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi index 1a0cc78cc522..81bd0dc125e6 100644 --- a/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi +++ b/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi @@ -12,7 +12,7 @@ class _PCGSolver: class _LUSolver: def __init__(self, A) -> None: ... - def solve(self, B, tol: Incomplete | None = None): ... + def solve(self, B, tol=None): ... @_dispatchable def algebraic_connectivity( @@ -21,7 +21,7 @@ def algebraic_connectivity( normalized: bool = False, tol: float = 1e-08, method: str = "tracemin_pcg", - seed: Incomplete | None = None, + seed=None, ): ... @_dispatchable def fiedler_vector( @@ -30,7 +30,7 @@ def fiedler_vector( normalized: bool = False, tol: float = 1e-08, method: str = "tracemin_pcg", - seed: Incomplete | None = None, + seed=None, ): ... @_dispatchable def spectral_ordering( @@ -39,14 +39,9 @@ def spectral_ordering( normalized: bool = False, tol: float = 1e-08, method: str = "tracemin_pcg", - seed: Incomplete | None = None, + seed=None, ): ... @_dispatchable def spectral_bisection( - G, - weight: str = "weight", - normalized: bool = False, - tol: float = 1e-08, - method: str = "tracemin_pcg", - seed: Incomplete | None = None, + G, weight: str = "weight", normalized: bool = False, tol: float = 1e-08, method: str = "tracemin_pcg", seed=None ): ... diff --git a/stubs/networkx/networkx/linalg/attrmatrix.pyi b/stubs/networkx/networkx/linalg/attrmatrix.pyi index 0e2dce1aa0c5..f237afd7079e 100644 --- a/stubs/networkx/networkx/linalg/attrmatrix.pyi +++ b/stubs/networkx/networkx/linalg/attrmatrix.pyi @@ -13,9 +13,9 @@ def attr_matrix( edge_attr: str | Callable[[Incomplete, Incomplete], Incomplete] | None = None, node_attr: str | Callable[[Incomplete], Incomplete] | None = None, normalized: bool = False, - rc_order: Incomplete | None = None, - dtype: Incomplete | None = None, - order: Incomplete | None = None, + rc_order=None, + dtype=None, + order=None, ): ... @_dispatchable def attr_sparse_matrix( @@ -23,6 +23,6 @@ def attr_sparse_matrix( edge_attr: str | Callable[[Incomplete, Incomplete], Incomplete] | None = None, node_attr: str | Callable[[Incomplete], Incomplete] | None = None, normalized: bool = False, - rc_order: Incomplete | None = None, - dtype: Incomplete | None = None, + rc_order=None, + dtype=None, ): ... diff --git a/stubs/networkx/networkx/linalg/graphmatrix.pyi b/stubs/networkx/networkx/linalg/graphmatrix.pyi index 0b2b8abd5094..aed2772178e3 100644 --- a/stubs/networkx/networkx/linalg/graphmatrix.pyi +++ b/stubs/networkx/networkx/linalg/graphmatrix.pyi @@ -9,13 +9,9 @@ __all__ = ["incidence_matrix", "adjacency_matrix"] @_dispatchable def incidence_matrix( - G: Graph[Incomplete], - nodelist: Collection[Incomplete] | None = None, - edgelist: Incomplete | None = None, - oriented: bool = False, - weight: Incomplete | None = None, + G: Graph[Incomplete], nodelist: Collection[Incomplete] | None = None, edgelist=None, oriented: bool = False, weight=None ): ... @_dispatchable def adjacency_matrix( - G: Graph[Incomplete], nodelist: Collection[Incomplete] | None = None, dtype: Incomplete | None = None, weight: str = "weight" + G: Graph[Incomplete], nodelist: Collection[Incomplete] | None = None, dtype=None, weight: str = "weight" ): ... diff --git a/stubs/networkx/networkx/linalg/laplacianmatrix.pyi b/stubs/networkx/networkx/linalg/laplacianmatrix.pyi index 9a4ce95367b6..5acd9c4a8d1c 100644 --- a/stubs/networkx/networkx/linalg/laplacianmatrix.pyi +++ b/stubs/networkx/networkx/linalg/laplacianmatrix.pyi @@ -25,7 +25,7 @@ def directed_laplacian_matrix( G: DiGraph[Incomplete], nodelist: Collection[Incomplete] | None = None, weight: str = "weight", - walk_type: Incomplete | None = None, + walk_type=None, alpha: float = 0.95, ): ... @_dispatchable @@ -33,6 +33,6 @@ def directed_combinatorial_laplacian_matrix( G: DiGraph[Incomplete], nodelist: Collection[Incomplete] | None = None, weight: str = "weight", - walk_type: Incomplete | None = None, + walk_type=None, alpha: float = 0.95, ): ... diff --git a/stubs/networkx/networkx/linalg/modularitymatrix.pyi b/stubs/networkx/networkx/linalg/modularitymatrix.pyi index 0cfb25d1b6f8..bbcae128e80b 100644 --- a/stubs/networkx/networkx/linalg/modularitymatrix.pyi +++ b/stubs/networkx/networkx/linalg/modularitymatrix.pyi @@ -9,8 +9,6 @@ from ..classes.graph import Graph __all__ = ["modularity_matrix", "directed_modularity_matrix"] @_dispatchable -def modularity_matrix(G: Graph[Incomplete], nodelist: Collection[Incomplete] | None = None, weight: Incomplete | None = None): ... +def modularity_matrix(G: Graph[Incomplete], nodelist: Collection[Incomplete] | None = None, weight=None): ... @_dispatchable -def directed_modularity_matrix( - G: DiGraph[Incomplete], nodelist: Collection[Incomplete] | None = None, weight: Incomplete | None = None -): ... +def directed_modularity_matrix(G: DiGraph[Incomplete], nodelist: Collection[Incomplete] | None = None, weight=None): ... diff --git a/stubs/networkx/networkx/readwrite/adjlist.pyi b/stubs/networkx/networkx/readwrite/adjlist.pyi index 083d7221835b..a1d705f7f17c 100644 --- a/stubs/networkx/networkx/readwrite/adjlist.pyi +++ b/stubs/networkx/networkx/readwrite/adjlist.pyi @@ -10,19 +10,8 @@ __all__ = ["generate_adjlist", "write_adjlist", "parse_adjlist", "read_adjlist"] def generate_adjlist(G: Graph[Incomplete], delimiter: str = " ") -> Generator[str, None, None]: ... def write_adjlist(G: Graph[Incomplete], path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8") -> None: ... @_dispatchable -def parse_adjlist( - lines, - comments: str = "#", - delimiter: str | None = None, - create_using: Incomplete | None = None, - nodetype: Incomplete | None = None, -): ... +def parse_adjlist(lines, comments: str = "#", delimiter: str | None = None, create_using=None, nodetype=None): ... @_dispatchable def read_adjlist( - path, - comments: str = "#", - delimiter: str | None = None, - create_using: Incomplete | None = None, - nodetype: Incomplete | None = None, - encoding: str = "utf-8", + path, comments: str = "#", delimiter: str | None = None, create_using=None, nodetype=None, encoding: str = "utf-8" ): ... diff --git a/stubs/networkx/networkx/readwrite/edgelist.pyi b/stubs/networkx/networkx/readwrite/edgelist.pyi index 96fbcdfcee1c..3866efcb11b9 100644 --- a/stubs/networkx/networkx/readwrite/edgelist.pyi +++ b/stubs/networkx/networkx/readwrite/edgelist.pyi @@ -22,22 +22,17 @@ def write_edgelist( ) -> None: ... @_dispatchable def parse_edgelist( - lines, - comments: str = "#", - delimiter: str | None = None, - create_using: Incomplete | None = None, - nodetype: Incomplete | None = None, - data: bool | Incomplete = True, + lines, comments: str = "#", delimiter: str | None = None, create_using=None, nodetype=None, data: bool | Incomplete = True ): ... @_dispatchable def read_edgelist( path, comments: str = "#", delimiter: str | None = None, - create_using: Incomplete | None = None, - nodetype: Incomplete | None = None, + create_using=None, + nodetype=None, data: bool | Incomplete = True, - edgetype: Incomplete | None = None, + edgetype=None, encoding: str = "utf-8", ): ... def write_weighted_edgelist( @@ -45,10 +40,5 @@ def write_weighted_edgelist( ) -> None: ... @_dispatchable def read_weighted_edgelist( - path, - comments: str = "#", - delimiter: str | None = None, - create_using: Incomplete | None = None, - nodetype: Incomplete | None = None, - encoding: str = "utf-8", + path, comments: str = "#", delimiter: str | None = None, create_using=None, nodetype=None, encoding: str = "utf-8" ): ... diff --git a/stubs/networkx/networkx/readwrite/gexf.pyi b/stubs/networkx/networkx/readwrite/gexf.pyi index 8da51bddf4fd..0528da55ae7b 100644 --- a/stubs/networkx/networkx/readwrite/gexf.pyi +++ b/stubs/networkx/networkx/readwrite/gexf.pyi @@ -15,7 +15,7 @@ def generate_gexf( G: Graph[Incomplete], encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft" ) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable -def read_gexf(path, node_type: Incomplete | None = None, relabel: bool = False, version: str = "1.2draft"): ... +def read_gexf(path, node_type=None, relabel: bool = False, version: str = "1.2draft"): ... class GEXF: versions: dict[str, dict[str, str]] @@ -39,9 +39,7 @@ class GEXFWriter(GEXF): attr_id: Incomplete all_edge_ids: Incomplete attr: Incomplete - def __init__( - self, graph: Incomplete | None = None, encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft" - ) -> None: ... + def __init__(self, graph=None, encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft") -> None: ... graph_element: Incomplete def add_graph(self, G) -> None: ... def add_nodes(self, G: Graph[Incomplete], graph_element) -> None: ... @@ -59,12 +57,12 @@ class GEXFWriter(GEXF): class GEXFReader(GEXF): node_type: Incomplete simple_graph: bool - def __init__(self, node_type: Incomplete | None = None, version: str = "1.2draft") -> None: ... + def __init__(self, node_type=None, version: str = "1.2draft") -> None: ... xml: Incomplete def __call__(self, stream): ... timeformat: Incomplete def make_graph(self, graph_xml): ... - def add_node(self, G: Graph[Incomplete], node_xml, node_attr, node_pid: Incomplete | None = None) -> None: ... + def add_node(self, G: Graph[Incomplete], node_xml, node_attr, node_pid=None) -> None: ... def add_start_end(self, data, xml): ... def add_viz(self, data, node_xml): ... def add_parents(self, data, node_xml): ... diff --git a/stubs/networkx/networkx/readwrite/graphml.pyi b/stubs/networkx/networkx/readwrite/graphml.pyi index abd4da9a3bf1..fd5639474f51 100644 --- a/stubs/networkx/networkx/readwrite/graphml.pyi +++ b/stubs/networkx/networkx/readwrite/graphml.pyi @@ -24,7 +24,7 @@ def write_graphml_xml( prettyprint: bool = True, infer_numeric_types: bool = False, named_key_ids: bool = False, - edge_id_from_attribute: Incomplete | None = None, + edge_id_from_attribute=None, ) -> None: ... def write_graphml_lxml( G: Graph[Incomplete], @@ -33,14 +33,14 @@ def write_graphml_lxml( prettyprint: bool = True, infer_numeric_types: bool = False, named_key_ids: bool = False, - edge_id_from_attribute: Incomplete | None = None, + edge_id_from_attribute=None, ): ... def generate_graphml( G: Graph[Incomplete], encoding: str = "utf-8", prettyprint: bool = True, named_key_ids: bool = False, - edge_id_from_attribute: Incomplete | None = None, + edge_id_from_attribute=None, ) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable def read_graphml(path, node_type=..., edge_key_type=..., force_multigraph: bool = False): ... @@ -71,16 +71,16 @@ class GraphMLWriter(GraphML): attribute_types: Incomplete def __init__( self, - graph: Incomplete | None = None, + graph=None, encoding: str = "utf-8", prettyprint: bool = True, infer_numeric_types: bool = False, named_key_ids: bool = False, - edge_id_from_attribute: Incomplete | None = None, + edge_id_from_attribute=None, ) -> None: ... def attr_type(self, name, scope, value): ... def get_key(self, name, attr_type, scope, default): ... - def add_data(self, name, element_type, value, scope: str = "all", default: Incomplete | None = None): ... + def add_data(self, name, element_type, value, scope: str = "all", default=None): ... def add_attributes(self, scope, xml_obj, data, default) -> None: ... def add_nodes(self, G: Graph[Incomplete], graph_element) -> None: ... def add_edges(self, G: Graph[Incomplete], graph_element) -> None: ... @@ -106,16 +106,16 @@ class GraphMLWriterLxml(GraphMLWriter): def __init__( self, path, - graph: Incomplete | None = None, + graph=None, encoding: str = "utf-8", prettyprint: bool = True, infer_numeric_types: bool = False, named_key_ids: bool = False, - edge_id_from_attribute: Incomplete | None = None, + edge_id_from_attribute=None, ) -> None: ... def add_graph_element(self, G) -> None: ... def add_attributes(self, scope, xml_obj, data, default) -> None: ... - def dump(self, stream: Incomplete | None = None) -> None: ... + def dump(self, stream=None) -> None: ... write_graphml = write_graphml_lxml @@ -126,8 +126,8 @@ class GraphMLReader(GraphML): edge_ids: Incomplete def __init__(self, node_type=..., edge_key_type=..., force_multigraph: bool = False) -> None: ... xml: Incomplete - def __call__(self, path: Incomplete | None = None, string: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... - def make_graph(self, graph_xml, graphml_keys, defaults, G: Incomplete | None = None): ... + def __call__(self, path=None, string=None) -> Generator[Incomplete, None, None]: ... + def make_graph(self, graph_xml, graphml_keys, defaults, G=None): ... def add_node(self, G: Graph[Incomplete], node_xml, graphml_keys, defaults) -> None: ... def add_edge(self, G: Graph[Incomplete], edge_element, graphml_keys) -> None: ... def decode_data_elements(self, graphml_keys, obj_xml): ... diff --git a/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi b/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi index 3ca9815c2e41..3caec2c4a52d 100644 --- a/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi +++ b/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi @@ -13,20 +13,15 @@ def write_multiline_adjlist( ) -> None: ... @_dispatchable def parse_multiline_adjlist( - lines, - comments: str = "#", - delimiter: str | None = None, - create_using: Incomplete | None = None, - nodetype: Incomplete | None = None, - edgetype: Incomplete | None = None, + lines, comments: str = "#", delimiter: str | None = None, create_using=None, nodetype=None, edgetype=None ): ... @_dispatchable def read_multiline_adjlist( path, comments: str = "#", delimiter: str | None = None, - create_using: Incomplete | None = None, - nodetype: Incomplete | None = None, - edgetype: Incomplete | None = None, + create_using=None, + nodetype=None, + edgetype=None, encoding: str = "utf-8", ): ... diff --git a/stubs/networkx/networkx/readwrite/sparse6.pyi b/stubs/networkx/networkx/readwrite/sparse6.pyi index 0ad32cacff42..b2a862631705 100644 --- a/stubs/networkx/networkx/readwrite/sparse6.pyi +++ b/stubs/networkx/networkx/readwrite/sparse6.pyi @@ -12,4 +12,4 @@ def from_sparse6_bytes(string: str) -> Graph[Incomplete]: ... def to_sparse6_bytes(G: Graph[Incomplete], nodes: Iterable[Incomplete] | None = None, header: bool = True): ... @_dispatchable def read_sparse6(path): ... -def write_sparse6(G: Graph[Incomplete], path, nodes: Incomplete | None = None, header: bool = True) -> None: ... +def write_sparse6(G: Graph[Incomplete], path, nodes=None, header: bool = True) -> None: ... diff --git a/stubs/networkx/networkx/readwrite/text.pyi b/stubs/networkx/networkx/readwrite/text.pyi index 8a2bf32fb8f0..3a1fe2e87e48 100644 --- a/stubs/networkx/networkx/readwrite/text.pyi +++ b/stubs/networkx/networkx/readwrite/text.pyi @@ -49,19 +49,14 @@ class UtfUndirectedGlyphs(UtfBaseGlyphs): vertical_edge: ClassVar[str] def generate_network_text( - graph, - with_labels: bool = True, - sources: Incomplete | None = None, - max_depth: Incomplete | None = None, - ascii_only: bool = False, - vertical_chains: bool = False, + graph, with_labels: bool = True, sources=None, max_depth=None, ascii_only: bool = False, vertical_chains: bool = False ) -> Generator[Incomplete, None, Incomplete]: ... def write_network_text( graph, - path: Incomplete | None = None, + path=None, with_labels: bool = True, - sources: Incomplete | None = None, - max_depth: Incomplete | None = None, + sources=None, + max_depth=None, ascii_only: bool = False, end: str = "\n", vertical_chains=False, diff --git a/stubs/networkx/networkx/relabel.pyi b/stubs/networkx/networkx/relabel.pyi index 4951676ca0e1..71e03625f022 100644 --- a/stubs/networkx/networkx/relabel.pyi +++ b/stubs/networkx/networkx/relabel.pyi @@ -1,4 +1,3 @@ -from _typeshed import Incomplete from collections.abc import Hashable, Mapping from typing import Literal, TypeVar, overload @@ -26,5 +25,5 @@ def convert_node_labels_to_integers( G: Graph[Hashable], first_label: int = 0, ordering: Literal["default", "sorted", "increasing degree", "decreasing degree"] = "default", - label_attribute: Incomplete | None = None, + label_attribute=None, ) -> Graph[int]: ... diff --git a/stubs/networkx/networkx/utils/configs.pyi b/stubs/networkx/networkx/utils/configs.pyi index 1d165b9fb1b5..780ccf7233a2 100644 --- a/stubs/networkx/networkx/utils/configs.pyi +++ b/stubs/networkx/networkx/utils/configs.pyi @@ -24,7 +24,7 @@ if sys.version_info >= (3, 10): def __getitem__(self, key: str): ... def __setitem__(self, key: str, value) -> None: ... def __delitem__(self, key: str) -> None: ... - def get(self, key: str, default: Incomplete | None = None): ... + def get(self, key: str, default=None): ... def items(self) -> ItemsView[str, Incomplete]: ... def keys(self) -> KeysView[str]: ... def values(self) -> ValuesView[Incomplete]: ... @@ -50,7 +50,7 @@ else: def __getitem__(self, key: str): ... def __setitem__(self, key: str, value) -> None: ... def __delitem__(self, key: str) -> None: ... - def get(self, key: str, default: Incomplete | None = None): ... + def get(self, key: str, default=None): ... def items(self) -> ItemsView[str, Incomplete]: ... def keys(self) -> KeysView[str]: ... def values(self) -> ValuesView[Incomplete]: ... diff --git a/stubs/networkx/networkx/utils/heaps.pyi b/stubs/networkx/networkx/utils/heaps.pyi index b5cd6a75e82a..92b3832cfa4e 100644 --- a/stubs/networkx/networkx/utils/heaps.pyi +++ b/stubs/networkx/networkx/utils/heaps.pyi @@ -11,7 +11,7 @@ class MinHeap: def __init__(self) -> None: ... def min(self) -> tuple[Incomplete, Incomplete]: ... def pop(self) -> tuple[Incomplete, Incomplete]: ... - def get(self, key, default: Incomplete | None = None): ... + def get(self, key, default=None): ... def insert(self, key, value, allow_increase: bool = False) -> bool: ... def __nonzero__(self): ... def __bool__(self) -> bool: ... @@ -29,12 +29,12 @@ class PairingHeap(MinHeap): def __init__(self) -> None: ... def min(self) -> tuple[Incomplete, Incomplete]: ... def pop(self) -> tuple[Incomplete, Incomplete]: ... - def get(self, key, default: Incomplete | None = None): ... + def get(self, key, default=None): ... def insert(self, key, value, allow_increase: bool = False) -> bool: ... class BinaryHeap(MinHeap): def __init__(self) -> None: ... def min(self) -> tuple[Incomplete, Incomplete]: ... def pop(self) -> tuple[Incomplete, Incomplete]: ... - def get(self, key, default: Incomplete | None = None): ... + def get(self, key, default=None): ... def insert(self, key, value, allow_increase: bool = False) -> bool: ... diff --git a/stubs/networkx/networkx/utils/mapped_queue.pyi b/stubs/networkx/networkx/utils/mapped_queue.pyi index e5eb305abb25..86e8c0e0ecde 100644 --- a/stubs/networkx/networkx/utils/mapped_queue.pyi +++ b/stubs/networkx/networkx/utils/mapped_queue.pyi @@ -17,9 +17,9 @@ class _HeapElement: class MappedQueue: heap: Incomplete position: Incomplete - def __init__(self, data: Incomplete | None = None) -> None: ... + def __init__(self, data=None) -> None: ... def __len__(self) -> int: ... - def push(self, elt, priority: Incomplete | None = None): ... + def push(self, elt, priority=None): ... def pop(self): ... - def update(self, elt, new, priority: Incomplete | None = None) -> None: ... + def update(self, elt, new, priority=None) -> None: ... def remove(self, elt) -> None: ... diff --git a/stubs/networkx/networkx/utils/misc.pyi b/stubs/networkx/networkx/utils/misc.pyi index eecd676e5702..0df8f1814066 100644 --- a/stubs/networkx/networkx/utils/misc.pyi +++ b/stubs/networkx/networkx/utils/misc.pyi @@ -1,5 +1,4 @@ import random -from _typeshed import Incomplete from types import ModuleType from typing_extensions import TypeAlias @@ -27,23 +26,23 @@ _RandomNumberGenerator: TypeAlias = ( ) _RandomState: TypeAlias = int | _RandomNumberGenerator | None -def flatten(obj, result: Incomplete | None = None): ... +def flatten(obj, result=None): ... def make_list_of_ints(sequence): ... -def dict_to_numpy_array(d, mapping: Incomplete | None = None): ... +def dict_to_numpy_array(d, mapping=None): ... def arbitrary_element(iterable): ... def pairwise(iterable, cyclic: bool = False): ... def groups(many_to_one): ... -def create_random_state(random_state: Incomplete | None = None): ... +def create_random_state(random_state=None): ... class PythonRandomViaNumpyBits(random.Random): def __init__(self, rng: numpy.random.Generator | None = None) -> None: ... def getrandbits(self, k: int) -> int: ... class PythonRandomInterface: - def __init__(self, rng: Incomplete | None = None) -> None: ... + def __init__(self, rng=None) -> None: ... def random(self): ... def uniform(self, a, b): ... - def randrange(self, a, b: Incomplete | None = None): ... + def randrange(self, a, b=None): ... def choice(self, seq): ... def gauss(self, mu, sigma): ... def shuffle(self, seq): ... diff --git a/stubs/networkx/networkx/utils/random_sequence.pyi b/stubs/networkx/networkx/utils/random_sequence.pyi index c31cd32d9436..6055c02e6a3f 100644 --- a/stubs/networkx/networkx/utils/random_sequence.pyi +++ b/stubs/networkx/networkx/utils/random_sequence.pyi @@ -1,5 +1,3 @@ -from _typeshed import Incomplete - __all__ = [ "powerlaw_sequence", "zipf_rv", @@ -9,11 +7,9 @@ __all__ = [ "weighted_choice", ] -def powerlaw_sequence(n, exponent: float = 2.0, seed: Incomplete | None = None): ... -def zipf_rv(alpha: float, xmin: int = 1, seed: Incomplete | None = None) -> int: ... +def powerlaw_sequence(n, exponent: float = 2.0, seed=None): ... +def zipf_rv(alpha: float, xmin: int = 1, seed=None) -> int: ... def cumulative_distribution(distribution): ... -def discrete_sequence( - n, distribution: Incomplete | None = None, cdistribution: Incomplete | None = None, seed: Incomplete | None = None -): ... -def random_weighted_sample(mapping, k, seed: Incomplete | None = None): ... -def weighted_choice(mapping, seed: Incomplete | None = None): ... +def discrete_sequence(n, distribution=None, cdistribution=None, seed=None): ... +def random_weighted_sample(mapping, k, seed=None): ... +def weighted_choice(mapping, seed=None): ... diff --git a/stubs/networkx/networkx/utils/union_find.pyi b/stubs/networkx/networkx/utils/union_find.pyi index fe50ede3c4df..97df662a3984 100644 --- a/stubs/networkx/networkx/utils/union_find.pyi +++ b/stubs/networkx/networkx/utils/union_find.pyi @@ -4,7 +4,7 @@ from collections.abc import Generator, Iterator class UnionFind: parents: Incomplete weights: Incomplete - def __init__(self, elements: Incomplete | None = None) -> None: ... + def __init__(self, elements=None) -> None: ... def __getitem__(self, object): ... def __iter__(self) -> Iterator[Incomplete]: ... def to_sets(self) -> Generator[Incomplete, Incomplete, None]: ... From 2037be35b546b441733218862938e8a1c9634241 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 13 May 2025 12:19:23 -0400 Subject: [PATCH 03/17] Fix failing tests --- stubs/networkx/@tests/stubtest_allowlist.txt | 5 +---- .../algorithms/approximation/traveling_salesman.pyi | 4 ++-- .../networkx/algorithms/approximation/treewidth.pyi | 1 + .../networkx/algorithms/centrality/trophic.pyi | 7 ++++--- stubs/networkx/networkx/algorithms/clique.pyi | 8 ++++---- .../algorithms/coloring/equitable_coloring.pyi | 8 +++++--- .../algorithms/community/label_propagation.pyi | 3 ++- .../networkx/algorithms/community/modularity_max.pyi | 4 +++- .../networkx/algorithms/components/attracting.pyi | 6 +++--- .../networkx/algorithms/connectivity/cuts.pyi | 2 +- .../algorithms/connectivity/edge_augmentation.pyi | 10 ++++++++++ stubs/networkx/networkx/algorithms/hierarchy.pyi | 5 ++++- .../networkx/algorithms/isomorphism/matchhelpers.pyi | 12 ++++++------ .../algorithms/isomorphism/tree_isomorphism.pyi | 1 + stubs/networkx/networkx/algorithms/planarity.pyi | 4 ++-- .../networkx/algorithms/shortest_paths/weighted.pyi | 4 +++- stubs/networkx/networkx/algorithms/threshold.pyi | 6 ++++-- stubs/networkx/networkx/algorithms/tournament.pyi | 4 ++-- .../networkx/networkx/algorithms/tree/branchings.pyi | 2 +- .../networkx/algorithms/tree/decomposition.pyi | 4 +++- stubs/networkx/networkx/classes/reportviews.pyi | 6 +++++- stubs/networkx/networkx/convert_matrix.pyi | 4 +++- stubs/networkx/networkx/generators/directed.pyi | 4 +++- stubs/networkx/networkx/generators/trees.pyi | 4 ++-- stubs/networkx/networkx/generators/triads.pyi | 3 ++- stubs/networkx/networkx/readwrite/p2g.pyi | 4 ++-- 26 files changed, 79 insertions(+), 46 deletions(-) diff --git a/stubs/networkx/@tests/stubtest_allowlist.txt b/stubs/networkx/@tests/stubtest_allowlist.txt index c55b28c08921..42dc072b15bb 100644 --- a/stubs/networkx/@tests/stubtest_allowlist.txt +++ b/stubs/networkx/@tests/stubtest_allowlist.txt @@ -40,7 +40,4 @@ networkx(\.algorithms)?(\.tree)?(\.mst)?\.SpanningTreeIterator\.Partition\._DT networkx(\.algorithms)?(\.tree)?(\.branchings)?\.ArborescenceIterator\.Partition\._DT # variable differs from runtime type abc.ABCMeta -networkx.classes.reportviews.EdgeView.dataview -networkx.classes.reportviews.InEdgeView.dataview -networkx.classes.reportviews.OutEdgeView.dataview -networkx.classes.reportviews.OutMultiEdgeView.dataview +networkx\.classes\.reportviews\.\w*EdgeView\.dataview diff --git a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi index aa3d9048d83e..73f67334b975 100644 --- a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi @@ -35,9 +35,9 @@ def asadpour_atsp( G: DiGraph[_Node], weight: str | None = "weight", seed: int | RandomState | None = None, source: str | None = None ): ... @_dispatchable -def held_karp_ascent(G: Graph, weight="weight"): ... +def held_karp_ascent(G: Graph[Incomplete], weight="weight"): ... @_dispatchable -def spanning_tree_distribution(G: Graph, z: Mapping[Incomplete, Incomplete]) -> dict[Incomplete, Incomplete]: ... +def spanning_tree_distribution(G: Graph[Incomplete], z: Mapping[Incomplete, Incomplete]) -> dict[Incomplete, Incomplete]: ... @_dispatchable def greedy_tsp(G: Graph[_Node], weight: str | None = "weight", source=None): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi index ad1df7938631..cbdad05997d3 100644 --- a/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi @@ -17,4 +17,5 @@ class MinDegreeHeuristic: def best_node(self, graph): ... def min_fill_in_heuristic(graph) -> Incomplete | None: ... +@_dispatchable def treewidth_decomp(G: Graph[Incomplete], heuristic=...) -> tuple[int, Graph[Incomplete]]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/trophic.pyi b/stubs/networkx/networkx/algorithms/centrality/trophic.pyi index 50ed79871702..4215c89b46d1 100644 --- a/stubs/networkx/networkx/algorithms/centrality/trophic.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/trophic.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete + from networkx.classes.digraph import DiGraph from networkx.classes.graph import _Node from networkx.utils.backends import _dispatchable @@ -6,8 +7,8 @@ from networkx.utils.backends import _dispatchable __all__ = ["trophic_levels", "trophic_differences", "trophic_incoherence_parameter"] @_dispatchable -def trophic_levels(G: DiGraph[_Node], weight="weight")->dict[Incomplete, Incomplete]: ... +def trophic_levels(G: DiGraph[_Node], weight="weight") -> dict[Incomplete, Incomplete]: ... @_dispatchable -def trophic_differences(G: DiGraph[_Node], weight="weight")->dict[Incomplete, Incomplete]: ... +def trophic_differences(G: DiGraph[_Node], weight="weight") -> dict[Incomplete, Incomplete]: ... @_dispatchable -def trophic_incoherence_parameter(G: DiGraph[_Node], weight="weight", cannibalism: bool = False)-float: ... +def trophic_incoherence_parameter(G: DiGraph[_Node], weight="weight", cannibalism: bool = False) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi index 2cea326e119d..78679886d4db 100644 --- a/stubs/networkx/networkx/algorithms/clique.pyi +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -29,23 +29,23 @@ def make_clique_bipartite( G: Graph[_Node], fpos: bool | None = None, create_using: Graph[_Node] | None = None, name=None ) -> Graph[_Node]: ... @overload -def node_clique_number( +def node_clique_number( # type: ignore[overload-overlap] G: Graph[_Node], nodes: Iterable[_Node] | None = None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False ) -> dict[_Node, int]: ... @overload def node_clique_number( - G: Graph[_Node], nodes: _Node = None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False + G: Graph[_Node], nodes: _Node, cliques: Iterable[Incomplete] | None = None, separate_nodes=False ) -> int: ... def number_of_cliques(G: Graph[Incomplete], nodes=None, cliques=None) -> int | dict[Incomplete, Incomplete]: ... @_dispatchable def max_weight_clique(G: Graph[Incomplete], weight="weight") -> tuple[list[Incomplete], int]: ... class MaxWeightClique: - G: Graph[_Node] + G: Graph[Incomplete] incumbent_nodes: list[Incomplete] incumbent_weight: int node_weights: dict[Incomplete, int] - def __init__(self, G: Graph, weight): ... + def __init__(self, G: Graph[Incomplete], weight): ... def update_incumbent_if_improved(self, C, C_weight): ... def greedily_find_independent_set(self, P): ... def find_branching_nodes(self, P, target): ... diff --git a/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi b/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi index 7e584f1fe140..15ed7afd4d14 100644 --- a/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi +++ b/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi @@ -1,19 +1,21 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["equitable_color"] @_dispatchable -def is_coloring(G: Graph, coloring): ... +def is_coloring(G: Graph[Incomplete], coloring): ... @_dispatchable -def is_equitable(G: Graph, coloring, num_colors=None): ... +def is_equitable(G: Graph[Incomplete], coloring, num_colors=None): ... def make_C_from_F(F): ... def make_N_from_L_C(L, C): ... def make_H_from_C_N(C, N): ... def change_color(u, X, Y, N, H, F, C, L): ... def move_witnesses(src_color, dst_color, N, H, F, C, T_cal, L): ... @_dispatchable -def pad_graph(G: Graph, num_colors): ... +def pad_graph(G: Graph[Incomplete], num_colors): ... def procedure_P(V_minus, V_plus, N, H, F, C, L, excluded_colors=None): ... @_dispatchable def equitable_color(G: Graph[_Node], num_colors): ... diff --git a/stubs/networkx/networkx/algorithms/community/label_propagation.pyi b/stubs/networkx/networkx/algorithms/community/label_propagation.pyi index e7aa55f2ebb0..6d0148179871 100644 --- a/stubs/networkx/networkx/algorithms/community/label_propagation.pyi +++ b/stubs/networkx/networkx/algorithms/community/label_propagation.pyi @@ -1,3 +1,4 @@ +from _collections_abc import dict_values from _typeshed import Incomplete from collections.abc import Generator @@ -14,4 +15,4 @@ def asyn_lpa_communities( G: Graph[_Node], weight: str | None = None, seed: int | RandomState | None = None ) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable -def label_propagation_communities(G: Graph[_Node]) -> dict_values[Any, set[Any]]: ... +def label_propagation_communities(G: Graph[_Node]) -> dict_values[Incomplete, set[Incomplete]]: ... diff --git a/stubs/networkx/networkx/algorithms/community/modularity_max.pyi b/stubs/networkx/networkx/algorithms/community/modularity_max.pyi index f737490748a6..701054c23e97 100644 --- a/stubs/networkx/networkx/algorithms/community/modularity_max.pyi +++ b/stubs/networkx/networkx/algorithms/community/modularity_max.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -6,6 +8,6 @@ __all__ = ["greedy_modularity_communities", "naive_greedy_modularity_communities @_dispatchable def greedy_modularity_communities( G: Graph[_Node], weight: str | None = None, resolution: float | None = 1, cutoff: int | None = 1, best_n: int | None = None -) -> list[set[Any]] | list[frozenset[Any]]: ... +) -> list[set[Incomplete]] | list[frozenset[Incomplete]]: ... @_dispatchable def naive_greedy_modularity_communities(G: Graph[_Node], resolution: float = 1, weight: str | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/components/attracting.pyi b/stubs/networkx/networkx/algorithms/components/attracting.pyi index 09b4d5c1d808..605e46a9429a 100644 --- a/stubs/networkx/networkx/algorithms/components/attracting.pyi +++ b/stubs/networkx/networkx/algorithms/components/attracting.pyi @@ -8,8 +8,8 @@ from ...classes.digraph import DiGraph __all__ = ["number_attracting_components", "attracting_components", "is_attracting_component"] @_dispatchable -def attracting_components(G: DiGraph) -> Generator[Incomplete, None, None]: ... +def attracting_components(G: DiGraph[Incomplete]) -> Generator[Incomplete, None, None]: ... @_dispatchable -def number_attracting_components(G: DiGraph) -> int: ... +def number_attracting_components(G: DiGraph[Incomplete]) -> int: ... @_dispatchable -def is_attracting_component(G: DiGraph) -> bool: ... +def is_attracting_component(G: DiGraph[Incomplete]) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi index f9dca59cea2e..4170cc9d37cf 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from collections.abc import Callable -from typing import Never +from typing_extensions import Never from networkx.algorithms.flow import edmonds_karp from networkx.classes.digraph import DiGraph diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi index a03d5cf55c7e..551684484b81 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -19,8 +19,11 @@ def k_edge_augmentation( weight: str | None = None, partial: bool = False, ) -> Generator[tuple[_Node, _Node], None, None]: ... +@_dispatchable def partial_k_edge_augmentation(G: Graph[Incomplete], k, avail, weight: str | None = None): ... +@_dispatchable def one_edge_augmentation(G: Graph[Incomplete], avail=None, weight: str | None = None, partial: bool = False): ... +@_dispatchable def bridge_augmentation(G: Graph[Incomplete], avail=None, weight: str | None = None): ... class MetaEdge(NamedTuple): @@ -28,10 +31,17 @@ class MetaEdge(NamedTuple): uv: Incomplete w: Incomplete +@_dispatchable def unconstrained_one_edge_augmentation(G: Graph[Incomplete]): ... +@_dispatchable def weighted_one_edge_augmentation(G: Graph[Incomplete], avail, weight: str | None = None, partial: bool = False): ... +@_dispatchable def unconstrained_bridge_augmentation(G: Graph[Incomplete]): ... +@_dispatchable def weighted_bridge_augmentation(G: Graph[Incomplete], avail, weight: str | None = None): ... +@_dispatchable def collapse(G: Graph[Incomplete], grouped_nodes): ... +@_dispatchable def complement_edges(G: Graph[Incomplete]): ... +@_dispatchable def greedy_k_edge_augmentation(G: Graph[Incomplete], k, avail=None, weight: str | None = None, seed=None): ... diff --git a/stubs/networkx/networkx/algorithms/hierarchy.pyi b/stubs/networkx/networkx/algorithms/hierarchy.pyi index d53b3829ffdc..58e9f32ee292 100644 --- a/stubs/networkx/networkx/algorithms/hierarchy.pyi +++ b/stubs/networkx/networkx/algorithms/hierarchy.pyi @@ -1,8 +1,11 @@ +from _typeshed import Incomplete + from networkx.utils.backends import _dispatchable from ..classes.digraph import DiGraph +from ..classes.multidigraph import MultiDiGraph __all__ = ["flow_hierarchy"] @_dispatchable -def flow_hierarchy(G: DiGraph, weight: str | None = None) -> float: ... +def flow_hierarchy(G: DiGraph[Incomplete] | MultiDiGraph[Incomplete], weight: str | None = None) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi b/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi index 4d7f21550bb0..a3799f4e2a8a 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi @@ -21,21 +21,21 @@ def allclose(x, y, rtol: float = 1.0000000000000001e-05, atol=1e-08) -> bool: .. @_dispatchable def categorical_node_match(attr: str | Iterable[str], default): ... -categorical_edge_match: FunctionType - +# Same as categorical_node_match, but not dispatchable +def categorical_edge_match(attr: str | Iterable[str], default): ... @_dispatchable def categorical_multiedge_match(attr: str | Iterable[str], default): ... @_dispatchable def numerical_node_match(attr: str | Iterable[str], default, rtol: float = 1e-05, atol: float = 1e-08): ... -numerical_edge_match: FunctionType - +# Same as numerical_node_match, but not dispatchable +def numerical_edge_match(attr: str | Iterable[str], default, rtol: float = 1e-05, atol: float = 1e-08): ... @_dispatchable def numerical_multiedge_match(attr: str | Iterable[str], default, rtol: float = 1e-05, atol: float = 1e-08): ... @_dispatchable def generic_node_match(attr: str | Iterable[str], default, op: Callable[[Incomplete, Incomplete], Incomplete]): ... -generic_edge_match: FunctionType - +# Same as generic_node_match, but not dispatchable +def generic_edge_match(attr: str | Iterable[str], default, op: Callable[[Incomplete, Incomplete], Incomplete]): ... @_dispatchable def generic_multiedge_match(attr: str | Iterable[str], default, op: Callable[[Incomplete, Incomplete], Incomplete]): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi b/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi index 978db20c29fb..b86a22c3e55b 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi @@ -5,6 +5,7 @@ from networkx.utils.backends import _dispatchable __all__ = ["rooted_tree_isomorphism", "tree_isomorphism"] +@_dispatchable def root_trees(t1, root1, t2, root2): ... @_dispatchable def assign_levels(G: Graph[Incomplete], root): ... diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index acfea6304e55..33e1cdde3f86 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -51,10 +51,10 @@ class LRPlanarity: lowpt_edge: Incomplete left_ref: Incomplete right_ref: Incomplete - embedding: PlanarEmbedding + embedding: PlanarEmbedding[Incomplete] def __init__(self, G) -> None: ... - def lr_planarity(self) -> PlanarEmbedding | None: ... + def lr_planarity(self) -> PlanarEmbedding[Incomplete] | None: ... def lr_planarity_recursive(self): ... def dfs_orientation(self, v): ... def dfs_orientation_recursive(self, v) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi index bee162cf7da4..39284b9cce64 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi @@ -183,4 +183,6 @@ def bidirectional_dijkstra( weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ): ... @_dispatchable -def johnson(G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight")->dict[Any, dict[Any, list[Any]]]:: ... +def johnson( + G: Graph[_Node], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight" +) -> dict[Any, dict[Any, list[Any]]]: ... diff --git a/stubs/networkx/networkx/algorithms/threshold.pyi b/stubs/networkx/networkx/algorithms/threshold.pyi index 309a0fa2178d..119e6d33f272 100644 --- a/stubs/networkx/networkx/algorithms/threshold.pyi +++ b/stubs/networkx/networkx/algorithms/threshold.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -14,11 +16,11 @@ def weights_to_creation_sequence(weights, threshold=1, with_labels=False, compac @_dispatchable def threshold_graph(creation_sequence, create_using=None): ... @_dispatchable -def find_alternating_4_cycle(G: Graph): ... +def find_alternating_4_cycle(G: Graph[Incomplete]): ... @_dispatchable def find_threshold_graph(G: Graph[_Node], create_using: Graph[_Node] | None = None): ... @_dispatchable -def find_creation_sequence(G: Graph): ... +def find_creation_sequence(G: Graph[Incomplete]): ... def triangles(creation_sequence): ... def triangle_sequence(creation_sequence): ... def cluster_sequence(creation_sequence): ... diff --git a/stubs/networkx/networkx/algorithms/tournament.pyi b/stubs/networkx/networkx/algorithms/tournament.pyi index a220912f5038..02d7ab9f7844 100644 --- a/stubs/networkx/networkx/algorithms/tournament.pyi +++ b/stubs/networkx/networkx/algorithms/tournament.pyi @@ -14,11 +14,11 @@ def is_tournament(G: Graph[_Node]) -> bool: ... @_dispatchable def hamiltonian_path(G: Graph[_Node]) -> list[Incomplete]: ... @_dispatchable -def random_tournament(n: int, seed: int | RandomState | None = None) -> DiGraph: ... +def random_tournament(n: int, seed: int | RandomState | None = None) -> DiGraph[Incomplete]: ... @_dispatchable def score_sequence(G: Graph[_Node]) -> list[Incomplete]: ... @_dispatchable -def tournament_matrix(G: Graph): ... +def tournament_matrix(G: Graph[Incomplete]): ... @_dispatchable def is_reachable(G: Graph[_Node], s: _Node, t: _Node) -> bool: ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi index 07c09af4b076..691aed6839f6 100644 --- a/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -21,7 +21,7 @@ __all__ = [ KINDS: set[str] STYLES: dict[str, str] -INF: Final = ... +INF: Final[float] def random_string(L=15, seed=None): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/tree/decomposition.pyi b/stubs/networkx/networkx/algorithms/tree/decomposition.pyi index 21c2e0fa53f5..d86d43c4c688 100644 --- a/stubs/networkx/networkx/algorithms/tree/decomposition.pyi +++ b/stubs/networkx/networkx/algorithms/tree/decomposition.pyi @@ -1,7 +1,9 @@ +from _typeshed import Incomplete + from networkx import Graph from networkx.utils.backends import _dispatchable __all__ = ["junction_tree"] @_dispatchable -def junction_tree(G: Graph) -> Graph: ... +def junction_tree(G: Graph[Incomplete]) -> Graph[Incomplete]: ... diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index 6a97d9a176ab..ca58dd891d1f 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -200,7 +200,11 @@ class InEdgeView(OutEdgeView[_Node]): ) -> InEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... class OutMultiEdgeView(OutEdgeView[_Node]): - dataview: type[OutMultiEdgeDataView | MultiEdgeDataView | InMultiEdgeDataView] # Include subtypes' possible types + dataview: type[ # Include subtypes' possible types + OutMultiEdgeDataView[Incomplete, Incomplete] + | MultiEdgeDataView[Incomplete, Incomplete] + | InMultiEdgeDataView[Incomplete, Incomplete] + ] def __iter__(self) -> Iterator[tuple[_Node, _Node, Incomplete]]: ... # type: ignore[override] def __getitem__(self, e: tuple[_Node, _Node, Incomplete]) -> dict[str, Any]: ... # type: ignore[override] dataview = OutMultiEdgeDataView diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index 6a9ab69c2460..36566e233a65 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -80,7 +80,9 @@ def from_pandas_edgelist( edge_key: str | None = None, ) -> Graph[Incomplete]: ... @_dispatchable -def to_scipy_sparse_array(G: Graph, nodelist: Collection[_Node] | None = None, dtype=None, weight="weight", format="csr"): ... +def to_scipy_sparse_array( + G: Graph[Incomplete], nodelist: Collection[_Node] | None = None, dtype=None, weight="weight", format="csr" +): ... @_dispatchable def from_scipy_sparse_array(A, parallel_edges: bool = False, create_using=None, edge_attribute: str = "weight"): ... @_dispatchable diff --git a/stubs/networkx/networkx/generators/directed.pyi b/stubs/networkx/networkx/generators/directed.pyi index 8aab39a754ff..2705f3889841 100644 --- a/stubs/networkx/networkx/generators/directed.pyi +++ b/stubs/networkx/networkx/generators/directed.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete + from networkx.utils.backends import _dispatchable from ..classes import MultiDiGraph @@ -25,4 +27,4 @@ def scale_free_graph( @_dispatchable def random_uniform_k_out_graph(n: int, k: int, self_loops: bool = True, with_replacement: bool = True, seed=None): ... @_dispatchable -def random_k_out_graph(n: int, k: int, alpha: float, self_loops: bool = True, seed=None) -> MultiDiGraph: ... +def random_k_out_graph(n: int, k: int, alpha: float, self_loops: bool = True, seed=None) -> MultiDiGraph[Incomplete]: ... diff --git a/stubs/networkx/networkx/generators/trees.pyi b/stubs/networkx/networkx/generators/trees.pyi index 5f359a320d92..9ebd32f0d81f 100644 --- a/stubs/networkx/networkx/generators/trees.pyi +++ b/stubs/networkx/networkx/generators/trees.pyi @@ -16,9 +16,9 @@ __all__ = [ ] @_dispatchable -def prefix_tree(paths) -> DiGraph: ... +def prefix_tree(paths) -> DiGraph[Incomplete]: ... @_dispatchable -def prefix_tree_recursive(paths) -> DiGraph: ... +def prefix_tree_recursive(paths) -> DiGraph[Incomplete]: ... @_dispatchable def random_labeled_tree(n, *, seed=None): ... @_dispatchable diff --git a/stubs/networkx/networkx/generators/triads.pyi b/stubs/networkx/networkx/generators/triads.pyi index 24f64e61a9e8..66fb47f93757 100644 --- a/stubs/networkx/networkx/generators/triads.pyi +++ b/stubs/networkx/networkx/generators/triads.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from typing import Final from networkx import DiGraph @@ -8,4 +9,4 @@ __all__ = ["triad_graph"] TRIAD_EDGES: Final[dict[str, list[str]]] @_dispatchable -def triad_graph(triad_name: str) -> DiGraph: ... +def triad_graph(triad_name: str) -> DiGraph[Incomplete]: ... diff --git a/stubs/networkx/networkx/readwrite/p2g.pyi b/stubs/networkx/networkx/readwrite/p2g.pyi index 1bdf5ac58355..4a6dd96252bb 100644 --- a/stubs/networkx/networkx/readwrite/p2g.pyi +++ b/stubs/networkx/networkx/readwrite/p2g.pyi @@ -7,6 +7,6 @@ from ..classes.multidigraph import MultiDiGraph def write_p2g(G: Graph[Incomplete], path, encoding: str = "utf-8") -> None: ... @_dispatchable -def read_p2g(path, encoding: str = "utf-8") -> MultiDiGraph: ... +def read_p2g(path, encoding: str = "utf-8") -> MultiDiGraph[Incomplete]: ... @_dispatchable -def parse_p2g(lines) -> MultiDiGraph: ... +def parse_p2g(lines) -> MultiDiGraph[Incomplete]: ... From 16f2a664674ce27da0970803e633da9ff7b53d7e Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 13 May 2025 12:20:16 -0400 Subject: [PATCH 04/17] Support `requires_python` in `runtests.py` --- lib/ts_utils/metadata.py | 4 ++-- tests/runtests.py | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/ts_utils/metadata.py b/lib/ts_utils/metadata.py index 2cf093ffc4a4..da1a15af0f30 100644 --- a/lib/ts_utils/metadata.py +++ b/lib/ts_utils/metadata.py @@ -47,7 +47,7 @@ def _is_nested_dict(obj: object) -> TypeGuard[dict[str, dict[str, Any]]]: @functools.cache -def _get_oldest_supported_python() -> str: +def get_oldest_supported_python() -> str: with PYPROJECT_PATH.open("rb") as config: val = tomli.load(config)["tool"]["typeshed"]["oldest_supported_python"] assert type(val) is str @@ -276,7 +276,7 @@ def read_metadata(distribution: str) -> StubMetadata: partial_stub: object = data.get("partial_stub", True) assert type(partial_stub) is bool requires_python_str: object = data.get("requires_python") - oldest_supported_python = _get_oldest_supported_python() + oldest_supported_python = get_oldest_supported_python() oldest_supported_python_specifier = Specifier(f">={oldest_supported_python}") if requires_python_str is None: requires_python = oldest_supported_python_specifier diff --git a/tests/runtests.py b/tests/runtests.py index 64346f4e58fd..efffc84df747 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -9,6 +9,7 @@ from importlib.util import find_spec from pathlib import Path +from ts_utils.metadata import get_oldest_supported_python, read_metadata from ts_utils.paths import TEST_CASES_DIR, test_cases_path from ts_utils.utils import colored @@ -19,9 +20,6 @@ _SUCCESS = colored("Success", "green") _SKIPPED = colored("Skipped", "yellow") _FAILED = colored("Failed", "red") -# We're using the oldest fully supported version because it's the most likely to produce errors -# due to unsupported syntax, feature, or bug in a tool. -_PYTHON_VERSION = "3.9" def _parse_jsonc(json_text: str) -> str: @@ -52,15 +50,16 @@ def main() -> None: ) parser.add_argument( "--python-version", - default=_PYTHON_VERSION, + default=None, choices=("3.9", "3.10", "3.11", "3.12", "3.13", "3.14"), - help="Target Python version for the test (default: %(default)s).", + # We're using the oldest fully supported version because it's the most likely to produce errors + # due to unsupported syntax, feature, or bug in a tool. + help="Target Python version for the test (defaults to oldest supported Python version).", ) parser.add_argument("path", help="Path of the stub to test in format /, from the root of the project.") args = parser.parse_args() path = Path(args.path) run_stubtest: bool = args.run_stubtest - python_version: str = args.python_version if len(path.parts) != 2: parser.error("'path' argument should be in format /.") @@ -69,6 +68,14 @@ def main() -> None: parser.error("Only the 'stdlib' and 'stubs' folders are supported.") if not path.exists(): parser.error(f"{path=} does not exist.") + + if args.python_version: + python_version: str = args.python_version + elif folder in "stubs": + python_version = read_metadata(stub).requires_python.version + else: + python_version = get_oldest_supported_python() + stubtest_result: subprocess.CompletedProcess[bytes] | None = None pytype_result: subprocess.CompletedProcess[bytes] | None = None From 72cf2c91df7acf9910d688778f71ee4d6b9ee141 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 14 May 2025 10:41:24 -0400 Subject: [PATCH 05/17] Discard changes to stubs/networkx/networkx/drawing/nx_agraph.pyi --- stubs/networkx/networkx/drawing/nx_agraph.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/networkx/networkx/drawing/nx_agraph.pyi b/stubs/networkx/networkx/drawing/nx_agraph.pyi index 5916f4501f13..4082bd6153ec 100644 --- a/stubs/networkx/networkx/drawing/nx_agraph.pyi +++ b/stubs/networkx/networkx/drawing/nx_agraph.pyi @@ -6,7 +6,6 @@ from typing_extensions import TypeAlias from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable -__all__ = ["from_agraph", "to_agraph", "write_dot", "read_dot", "graphviz_layout", "pygraphviz_layout", "view_pygraphviz"] # from pygraphviz.agraph import AGraph as _AGraph _AGraph: TypeAlias = Incomplete From e17709fd64a9e68aace7ae6d848864b03b923ea4 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 14 May 2025 10:42:42 -0400 Subject: [PATCH 06/17] Update stubs/networkx/networkx/classes/multidigraph.pyi --- stubs/networkx/networkx/classes/multidigraph.pyi | 2 -- 1 file changed, 2 deletions(-) diff --git a/stubs/networkx/networkx/classes/multidigraph.pyi b/stubs/networkx/networkx/classes/multidigraph.pyi index 66a275274bba..bae251859439 100644 --- a/stubs/networkx/networkx/classes/multidigraph.pyi +++ b/stubs/networkx/networkx/classes/multidigraph.pyi @@ -9,8 +9,6 @@ from networkx.classes.reportviews import DiMultiDegreeView, InMultiDegreeView, O __all__ = ["MultiDiGraph"] -__all__ = ["MultiDiGraph"] - class MultiDiGraph(MultiGraph[_Node], DiGraph[_Node]): @cached_property def succ(self) -> MultiAdjacencyView[_Node, _Node, dict[str, Incomplete]]: ... From 47f5f7cbe14b69c237f926200095a268098f86d3 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 14 May 2025 10:43:29 -0400 Subject: [PATCH 07/17] Update stubs/networkx/networkx/classes/digraph.pyi --- stubs/networkx/networkx/classes/digraph.pyi | 2 -- 1 file changed, 2 deletions(-) diff --git a/stubs/networkx/networkx/classes/digraph.pyi b/stubs/networkx/networkx/classes/digraph.pyi index f74cf10d5c19..dba6edff4837 100644 --- a/stubs/networkx/networkx/classes/digraph.pyi +++ b/stubs/networkx/networkx/classes/digraph.pyi @@ -16,8 +16,6 @@ from networkx.classes.reportviews import ( __all__ = ["DiGraph"] -__all__ = ["DiGraph"] - class DiGraph(Graph[_Node]): @cached_property def succ(self) -> AdjacencyView[_Node, _Node, dict[str, Incomplete]]: ... From 73dbdbf9f3bb46b2578c42b4588e4d989c46ed86 Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 16 May 2025 13:39:52 -0400 Subject: [PATCH 08/17] Remove accidental extra symbols --- stubs/networkx/networkx/algorithms/dag.pyi | 3 --- stubs/networkx/networkx/algorithms/minors/contraction.pyi | 3 --- stubs/networkx/networkx/classes/reportviews.pyi | 5 ++--- stubs/networkx/networkx/generators/degree_seq.pyi | 2 -- 4 files changed, 2 insertions(+), 11 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/dag.pyi b/stubs/networkx/networkx/algorithms/dag.pyi index fc21705c16eb..2c2ee1cbdf9a 100644 --- a/stubs/networkx/networkx/algorithms/dag.pyi +++ b/stubs/networkx/networkx/algorithms/dag.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete from collections.abc import Callable, Generator, Iterable -from itertools import chain from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node @@ -25,8 +24,6 @@ __all__ = [ "compute_v_structures", ] -chaini = chain.from_iterable - @_dispatchable def descendants(G: Graph[_Node], source) -> set[_Node]: ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/minors/contraction.pyi b/stubs/networkx/networkx/algorithms/minors/contraction.pyi index 4552be95180a..98bba1154f83 100644 --- a/stubs/networkx/networkx/algorithms/minors/contraction.pyi +++ b/stubs/networkx/networkx/algorithms/minors/contraction.pyi @@ -1,14 +1,11 @@ from _typeshed import Incomplete from collections.abc import Callable, Iterable -from itertools import chain from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["contracted_edge", "contracted_nodes", "equivalence_classes", "identified_nodes", "quotient_graph"] -chaini = chain.from_iterable - @_dispatchable def equivalence_classes(iterable: Iterable[Incomplete], relation): ... @_dispatchable diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index ca58dd891d1f..9c614737f217 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -200,14 +200,13 @@ class InEdgeView(OutEdgeView[_Node]): ) -> InEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... class OutMultiEdgeView(OutEdgeView[_Node]): + def __iter__(self) -> Iterator[tuple[_Node, _Node, Incomplete]]: ... # type: ignore[override] + def __getitem__(self, e: tuple[_Node, _Node, Incomplete]) -> dict[str, Any]: ... # type: ignore[override] dataview: type[ # Include subtypes' possible types OutMultiEdgeDataView[Incomplete, Incomplete] | MultiEdgeDataView[Incomplete, Incomplete] | InMultiEdgeDataView[Incomplete, Incomplete] ] - def __iter__(self) -> Iterator[tuple[_Node, _Node, Incomplete]]: ... # type: ignore[override] - def __getitem__(self, e: tuple[_Node, _Node, Incomplete]) -> dict[str, Any]: ... # type: ignore[override] - dataview = OutMultiEdgeDataView @overload # type: ignore[override] # Has an additional `keys` keyword argument def __call__( # type: ignore[overload-overlap] self, nbunch: None = None, data: Literal[False] = False, *, default: Unused = None, keys: Literal[True] diff --git a/stubs/networkx/networkx/generators/degree_seq.pyi b/stubs/networkx/networkx/generators/degree_seq.pyi index 5e01f87e805d..8f6a87e86af2 100644 --- a/stubs/networkx/networkx/generators/degree_seq.pyi +++ b/stubs/networkx/networkx/generators/degree_seq.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete from collections.abc import Collection -from itertools import chain from networkx.utils.backends import _dispatchable @@ -18,7 +17,6 @@ __all__ = [ "degree_sequence_tree", "random_degree_sequence_graph", ] -chaini = chain.from_iterable @_dispatchable def configuration_model(deg_sequence, create_using=None, seed=None) -> MultiGraph[Incomplete]: ... From a092752ea0dbb3a234818aaf7290d41f01a0e60e Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 22 May 2025 11:21:26 -0400 Subject: [PATCH 09/17] Replace `Graph[Incomplete]` with `Graph[_Node]` --- .../approximation/traveling_salesman.pyi | 4 +- .../algorithms/approximation/treewidth.pyi | 2 +- .../networkx/algorithms/asteroidal.pyi | 2 +- .../algorithms/bipartite/edgelist.pyi | 4 +- .../networkx/networkx/algorithms/chordal.pyi | 2 +- stubs/networkx/networkx/algorithms/clique.pyi | 6 +-- .../coloring/equitable_coloring.pyi | 2 +- .../algorithms/coloring/greedy_coloring.pyi | 16 ++++---- .../networkx/algorithms/community/quality.pyi | 10 ++--- .../algorithms/components/attracting.pyi | 4 +- .../connectivity/edge_augmentation.pyi | 20 +++++----- .../connectivity/edge_kcomponents.pyi | 4 +- .../algorithms/connectivity/utils.pyi | 8 ++-- .../networkx/algorithms/d_separation.pyi | 2 +- stubs/networkx/networkx/algorithms/dag.pyi | 2 +- .../algorithms/flow/networksimplex.pyi | 2 +- .../networkx/algorithms/flow/utils.pyi | 6 +-- .../networkx/algorithms/hierarchy.pyi | 5 +-- .../algorithms/isomorphism/ismags.pyi | 8 ++-- .../algorithms/isomorphism/isomorphvf2.pyi | 6 +-- .../isomorphism/temporalisomorphvf2.pyi | 6 +-- .../isomorphism/tree_isomorphism.pyi | 2 +- .../algorithms/isomorphism/vf2userfunc.pyi | 10 ++--- .../networkx/algorithms/operators/binary.pyi | 2 +- .../networkx/algorithms/planarity.pyi | 4 +- .../networkx/algorithms/structuralholes.pyi | 4 +- .../networkx/algorithms/threshold.pyi | 5 +-- .../networkx/algorithms/tournament.pyi | 2 +- .../traversal/breadth_first_search.pyi | 6 +-- .../networkx/algorithms/tree/branchings.pyi | 2 +- .../algorithms/tree/decomposition.pyi | 6 +-- .../networkx/networkx/algorithms/tree/mst.pyi | 6 +-- stubs/networkx/networkx/classes/function.pyi | 30 +++++++-------- stubs/networkx/networkx/convert_matrix.pyi | 2 +- stubs/networkx/networkx/drawing/layout.pyi | 37 ++++++------------- stubs/networkx/networkx/drawing/nx_pydot.pyi | 8 ++-- stubs/networkx/networkx/drawing/nx_pylab.pyi | 28 +++++++------- .../networkx/networkx/generators/classic.pyi | 2 +- stubs/networkx/networkx/generators/ego.pyi | 6 +-- stubs/networkx/networkx/generators/line.pyi | 8 ++-- .../networkx/generators/mycielski.pyi | 6 +-- .../networkx/generators/random_graphs.pyi | 8 ++-- .../generators/spectral_graph_forge.pyi | 8 +--- .../networkx/generators/stochastic.pyi | 6 +-- .../networkx/linalg/algebraicconnectivity.pyi | 25 ++----------- stubs/networkx/networkx/linalg/attrmatrix.pyi | 6 +-- .../networkx/linalg/bethehessianmatrix.pyi | 4 +- .../networkx/networkx/linalg/graphmatrix.pyi | 8 ++-- .../networkx/linalg/laplacianmatrix.pyi | 20 +++------- .../networkx/linalg/modularitymatrix.pyi | 6 +-- stubs/networkx/networkx/linalg/spectrum.pyi | 14 +++---- stubs/networkx/networkx/readwrite/adjlist.pyi | 7 ++-- .../networkx/networkx/readwrite/edgelist.pyi | 8 ++-- stubs/networkx/networkx/readwrite/gexf.pyi | 18 ++++----- stubs/networkx/networkx/readwrite/gml.pyi | 6 +-- stubs/networkx/networkx/readwrite/graph6.pyi | 8 ++-- stubs/networkx/networkx/readwrite/graphml.pyi | 20 ++++------ .../readwrite/json_graph/adjacency.pyi | 4 +- .../readwrite/json_graph/cytoscape.pyi | 4 +- .../readwrite/json_graph/node_link.pyi | 4 +- .../networkx/readwrite/json_graph/tree.pyi | 4 +- .../networkx/readwrite/multiline_adjlist.pyi | 7 ++-- stubs/networkx/networkx/readwrite/p2g.pyi | 4 +- stubs/networkx/networkx/readwrite/pajek.pyi | 6 +-- stubs/networkx/networkx/readwrite/sparse6.pyi | 6 +-- stubs/networkx/networkx/utils/rcm.pyi | 10 ++--- 66 files changed, 222 insertions(+), 296 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi index 73f67334b975..8fc66fe293b5 100644 --- a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi @@ -35,9 +35,9 @@ def asadpour_atsp( G: DiGraph[_Node], weight: str | None = "weight", seed: int | RandomState | None = None, source: str | None = None ): ... @_dispatchable -def held_karp_ascent(G: Graph[Incomplete], weight="weight"): ... +def held_karp_ascent(G: Graph[_Node], weight="weight"): ... @_dispatchable -def spanning_tree_distribution(G: Graph[Incomplete], z: Mapping[Incomplete, Incomplete]) -> dict[Incomplete, Incomplete]: ... +def spanning_tree_distribution(G: Graph[_Node], z: Mapping[Incomplete, Incomplete]) -> dict[Incomplete, Incomplete]: ... @_dispatchable def greedy_tsp(G: Graph[_Node], weight: str | None = "weight", source=None): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi index cbdad05997d3..02b275350005 100644 --- a/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi @@ -18,4 +18,4 @@ class MinDegreeHeuristic: def min_fill_in_heuristic(graph) -> Incomplete | None: ... @_dispatchable -def treewidth_decomp(G: Graph[Incomplete], heuristic=...) -> tuple[int, Graph[Incomplete]]: ... +def treewidth_decomp(G: Graph[_Node], heuristic=...) -> tuple[int, Graph[_Node]]: ... diff --git a/stubs/networkx/networkx/algorithms/asteroidal.pyi b/stubs/networkx/networkx/algorithms/asteroidal.pyi index 2caee5d7b3e0..9e4dbd34028f 100644 --- a/stubs/networkx/networkx/algorithms/asteroidal.pyi +++ b/stubs/networkx/networkx/algorithms/asteroidal.pyi @@ -10,4 +10,4 @@ def find_asteroidal_triple(G: Graph[_Node]) -> list[Incomplete] | None: ... @_dispatchable def is_at_free(G: Graph[_Node]) -> bool: ... @_dispatchable -def create_component_structure(G: Graph[Incomplete]) -> dict[Incomplete, Incomplete]: ... +def create_component_structure(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi b/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi index cb64aaa3f1ce..92d17a6f2eb4 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi @@ -8,7 +8,7 @@ __all__ = ["generate_edgelist", "write_edgelist", "parse_edgelist", "read_edgeli @_dispatchable def write_edgelist( - G: Graph[Incomplete], + G: Graph[_Node], path, comments: str = "#", delimiter: str = " ", @@ -17,7 +17,7 @@ def write_edgelist( ) -> None: ... @_dispatchable def generate_edgelist( - G: Graph[Incomplete], delimiter: str = " ", data: bool | Iterable[Incomplete] = True + G: Graph[_Node], delimiter: str = " ", data: bool | Iterable[Incomplete] = True ) -> Generator[str, None, None]: ... @_dispatchable def parse_edgelist( diff --git a/stubs/networkx/networkx/algorithms/chordal.pyi b/stubs/networkx/networkx/algorithms/chordal.pyi index 44aa7b935657..6dc458dfa3d2 100644 --- a/stubs/networkx/networkx/algorithms/chordal.pyi +++ b/stubs/networkx/networkx/algorithms/chordal.pyi @@ -26,4 +26,4 @@ def chordal_graph_cliques(G: Graph[_Node]) -> Generator[frozenset[_Node], None, @_dispatchable def chordal_graph_treewidth(G: Graph[_Node]) -> int: ... @_dispatchable -def complete_to_chordal_graph(G: Graph[Incomplete]) -> tuple[Incomplete, dict[Incomplete, int]]: ... +def complete_to_chordal_graph(G: Graph[_Node]) -> tuple[Incomplete, dict[Incomplete, int]]: ... diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi index 78679886d4db..2f873a64e301 100644 --- a/stubs/networkx/networkx/algorithms/clique.pyi +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -36,16 +36,16 @@ def node_clique_number( # type: ignore[overload-overlap] def node_clique_number( G: Graph[_Node], nodes: _Node, cliques: Iterable[Incomplete] | None = None, separate_nodes=False ) -> int: ... -def number_of_cliques(G: Graph[Incomplete], nodes=None, cliques=None) -> int | dict[Incomplete, Incomplete]: ... +def number_of_cliques(G: Graph[_Node], nodes=None, cliques=None) -> int | dict[Incomplete, Incomplete]: ... @_dispatchable -def max_weight_clique(G: Graph[Incomplete], weight="weight") -> tuple[list[Incomplete], int]: ... +def max_weight_clique(G: Graph[_Node], weight="weight") -> tuple[list[Incomplete], int]: ... class MaxWeightClique: G: Graph[Incomplete] incumbent_nodes: list[Incomplete] incumbent_weight: int node_weights: dict[Incomplete, int] - def __init__(self, G: Graph[Incomplete], weight): ... + def __init__(self, G: Graph[_Node], weight): ... def update_incumbent_if_improved(self, C, C_weight): ... def greedily_find_independent_set(self, P): ... def find_branching_nodes(self, P, target): ... diff --git a/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi b/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi index bf705f00feed..dffd5c269c0e 100644 --- a/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi +++ b/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi @@ -17,7 +17,7 @@ def make_H_from_C_N(C, N): ... def change_color(u, X, Y, N, H, F, C, L): ... def move_witnesses(src_color, dst_color, N, H, F, C, T_cal, L): ... @_dispatchable -def pad_graph(G: Graph[Incomplete], num_colors): ... +def pad_graph(G: Graph[_Node], num_colors): ... def procedure_P(V_minus, V_plus, N, H, F, C, L, excluded_colors=None): ... @_dispatchable 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 a42df3648687..8f1f66faba0f 100644 --- a/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi +++ b/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi @@ -17,21 +17,21 @@ __all__ = [ ] @_dispatchable -def strategy_largest_first(G: Graph[Incomplete], colors): ... +def strategy_largest_first(G: Graph[_Node], colors): ... @_dispatchable -def strategy_random_sequential(G: Graph[Incomplete], colors, seed=None): ... +def strategy_random_sequential(G: Graph[_Node], colors, seed=None): ... @_dispatchable -def strategy_smallest_last(G: Graph[Incomplete], colors): ... +def strategy_smallest_last(G: Graph[_Node], colors): ... @_dispatchable -def strategy_independent_set(G: Graph[Incomplete], colors) -> Generator[Incomplete, Incomplete, None]: ... +def strategy_independent_set(G: Graph[_Node], colors) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable -def strategy_connected_sequential_bfs(G: Graph[Incomplete], colors): ... +def strategy_connected_sequential_bfs(G: Graph[_Node], colors): ... @_dispatchable -def strategy_connected_sequential_dfs(G: Graph[Incomplete], colors): ... +def strategy_connected_sequential_dfs(G: Graph[_Node], colors): ... @_dispatchable -def strategy_connected_sequential(G: Graph[Incomplete], colors, traversal: str = "bfs") -> Generator[Incomplete, None, None]: ... +def strategy_connected_sequential(G: Graph[_Node], colors, traversal: str = "bfs") -> Generator[Incomplete, None, None]: ... @_dispatchable -def strategy_saturation_largest_first(G: Graph[Incomplete], colors) -> Generator[Incomplete, None, Incomplete]: ... +def strategy_saturation_largest_first(G: Graph[_Node], colors) -> Generator[Incomplete, None, Incomplete]: ... STRATEGIES: dict[str, Callable[..., Incomplete]] diff --git a/stubs/networkx/networkx/algorithms/community/quality.pyi b/stubs/networkx/networkx/algorithms/community/quality.pyi index 0e4a3e13f24b..8ded6a641250 100644 --- a/stubs/networkx/networkx/algorithms/community/quality.pyi +++ b/stubs/networkx/networkx/algorithms/community/quality.pyi @@ -1,5 +1,3 @@ -from _typeshed import Incomplete - from networkx.classes.graph import Graph, _Node from networkx.exception import NetworkXError from networkx.utils.backends import _dispatchable @@ -8,16 +6,16 @@ from networkx.utils.decorators import argmap __all__ = ["modularity", "partition_quality"] class NotAPartition(NetworkXError): - def __init__(self, G: Graph[Incomplete], collection) -> None: ... + def __init__(self, G: Graph[_Node], collection) -> None: ... require_partition: argmap @_dispatchable -def intra_community_edges(G: Graph[Incomplete], partition): ... +def intra_community_edges(G: Graph[_Node], partition): ... @_dispatchable -def inter_community_edges(G: Graph[Incomplete], partition): ... +def inter_community_edges(G: Graph[_Node], partition): ... @_dispatchable -def inter_community_non_edges(G: Graph[Incomplete], partition): ... +def inter_community_non_edges(G: Graph[_Node], partition): ... @_dispatchable def modularity(G: Graph[_Node], communities, weight: str | None = "weight", resolution: float = 1): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/components/attracting.pyi b/stubs/networkx/networkx/algorithms/components/attracting.pyi index 6d553a2cd1dc..88b2c5e7816a 100644 --- a/stubs/networkx/networkx/algorithms/components/attracting.pyi +++ b/stubs/networkx/networkx/algorithms/components/attracting.pyi @@ -9,8 +9,8 @@ from networkx.utils.backends import _dispatchable __all__ = ["number_attracting_components", "attracting_components", "is_attracting_component"] @_dispatchable -def attracting_components(G: DiGraph[Incomplete]) -> Generator[Incomplete, None, None]: ... +def attracting_components(G: DiGraph[_Node]) -> Generator[Incomplete, None, None]: ... @_dispatchable -def number_attracting_components(G: DiGraph[Incomplete]) -> int: ... +def number_attracting_components(G: DiGraph[_Node]) -> int: ... @_dispatchable def is_attracting_component(G: DiGraph[_Node] | MultiDiGraph[_Node]) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi index 551684484b81..a988852eac92 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -20,11 +20,11 @@ def k_edge_augmentation( partial: bool = False, ) -> Generator[tuple[_Node, _Node], None, None]: ... @_dispatchable -def partial_k_edge_augmentation(G: Graph[Incomplete], k, avail, weight: str | None = None): ... +def partial_k_edge_augmentation(G: Graph[_Node], k, avail, weight: str | None = None): ... @_dispatchable -def one_edge_augmentation(G: Graph[Incomplete], avail=None, weight: str | None = None, partial: bool = False): ... +def one_edge_augmentation(G: Graph[_Node], avail=None, weight: str | None = None, partial: bool = False): ... @_dispatchable -def bridge_augmentation(G: Graph[Incomplete], avail=None, weight: str | None = None): ... +def bridge_augmentation(G: Graph[_Node], avail=None, weight: str | None = None): ... class MetaEdge(NamedTuple): meta_uv: Incomplete @@ -32,16 +32,16 @@ class MetaEdge(NamedTuple): w: Incomplete @_dispatchable -def unconstrained_one_edge_augmentation(G: Graph[Incomplete]): ... +def unconstrained_one_edge_augmentation(G: Graph[_Node]): ... @_dispatchable -def weighted_one_edge_augmentation(G: Graph[Incomplete], avail, weight: str | None = None, partial: bool = False): ... +def weighted_one_edge_augmentation(G: Graph[_Node], avail, weight: str | None = None, partial: bool = False): ... @_dispatchable -def unconstrained_bridge_augmentation(G: Graph[Incomplete]): ... +def unconstrained_bridge_augmentation(G: Graph[_Node]): ... @_dispatchable -def weighted_bridge_augmentation(G: Graph[Incomplete], avail, weight: str | None = None): ... +def weighted_bridge_augmentation(G: Graph[_Node], avail, weight: str | None = None): ... @_dispatchable -def collapse(G: Graph[Incomplete], grouped_nodes): ... +def collapse(G: Graph[_Node], grouped_nodes): ... @_dispatchable -def complement_edges(G: Graph[Incomplete]): ... +def complement_edges(G: Graph[_Node]): ... @_dispatchable -def greedy_k_edge_augmentation(G: Graph[Incomplete], k, avail=None, weight: str | None = None, seed=None): ... +def greedy_k_edge_augmentation(G: Graph[_Node], k, avail=None, weight: str | None = None, seed=None): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi index 21f10db002b6..dd4e67663ab5 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi @@ -18,9 +18,9 @@ class EdgeComponentAuxGraph: H: Incomplete @classmethod - def construct(cls, G: Graph[Incomplete]): ... + def construct(cls, G: Graph[_Node]): ... def k_edge_components(self, k: int) -> Generator[Incomplete, Incomplete, None]: ... def k_edge_subgraphs(self, k: int) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable -def general_k_edge_subgraphs(G: Graph[Incomplete], k): ... +def general_k_edge_subgraphs(G: Graph[_Node], k): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/utils.pyi b/stubs/networkx/networkx/algorithms/connectivity/utils.pyi index e18582e4796d..8b7bb6bc0626 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/utils.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/utils.pyi @@ -1,12 +1,10 @@ -from _typeshed import Incomplete - from networkx.utils.backends import _dispatchable -from ...classes.graph import Graph +from ...classes.graph import Graph, _Node __all__ = ["build_auxiliary_node_connectivity", "build_auxiliary_edge_connectivity"] @_dispatchable -def build_auxiliary_node_connectivity(G: Graph[Incomplete]): ... +def build_auxiliary_node_connectivity(G: Graph[_Node]): ... @_dispatchable -def build_auxiliary_edge_connectivity(G: Graph[Incomplete]): ... +def build_auxiliary_edge_connectivity(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/algorithms/d_separation.pyi b/stubs/networkx/networkx/algorithms/d_separation.pyi index 3ef2e95c5903..f15f982fefd3 100644 --- a/stubs/networkx/networkx/algorithms/d_separation.pyi +++ b/stubs/networkx/networkx/algorithms/d_separation.pyi @@ -13,7 +13,7 @@ def is_d_separator(G: DiGraph[_Node], x: _Node | set[_Node], y: _Node | set[_Nod def find_minimal_d_separator(G, x, y, *, included=None, restricted=None) -> set[Incomplete] | None: ... @deprecated("d_separated is deprecated and will be removed in NetworkX v3.5. Please use `is_d_separator(G, x, y, z)`.") def d_separated( - G: Graph[Incomplete], x: Incomplete | set[Incomplete], y: Incomplete | set[Incomplete], z: Incomplete | set[Incomplete] + G: Graph[_Node], x: Incomplete | set[Incomplete], y: Incomplete | set[Incomplete], z: Incomplete | set[Incomplete] ) -> bool: ... @_dispatchable def minimal_d_separator(G, u, v): ... diff --git a/stubs/networkx/networkx/algorithms/dag.pyi b/stubs/networkx/networkx/algorithms/dag.pyi index 2c2ee1cbdf9a..bbb3977b0c47 100644 --- a/stubs/networkx/networkx/algorithms/dag.pyi +++ b/stubs/networkx/networkx/algorithms/dag.pyi @@ -62,4 +62,4 @@ def dag_longest_path_length(G: DiGraph[_Node], weight: str | None = "weight", de @_dispatchable def dag_to_branching(G: Graph[_Node]) -> DiGraph[_Node]: ... @_dispatchable -def compute_v_structures(G: Graph[Incomplete]) -> Generator[tuple[Incomplete, Incomplete, Incomplete]]: ... +def compute_v_structures(G: Graph[_Node]) -> Generator[tuple[Incomplete, Incomplete, Incomplete]]: ... diff --git a/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi b/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi index 7f03d98e3479..a2f58d7cae6b 100644 --- a/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi +++ b/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi @@ -27,7 +27,7 @@ class _DataEssentialsAndFunctions: last_descendent_dft: Incomplete def __init__( - self, G: Graph[Incomplete], multigraph, demand: str = "demand", capacity: str = "capacity", weight: str = "weight" + self, G: Graph[_Node], multigraph, demand: str = "demand", capacity: str = "capacity", weight: str = "weight" ) -> None: ... def initialize_spanning_tree(self, n, faux_inf) -> None: ... def find_apex(self, p, q): ... diff --git a/stubs/networkx/networkx/algorithms/flow/utils.pyi b/stubs/networkx/networkx/algorithms/flow/utils.pyi index 39d33a1e88b5..01bb19236e8d 100644 --- a/stubs/networkx/networkx/algorithms/flow/utils.pyi +++ b/stubs/networkx/networkx/algorithms/flow/utils.pyi @@ -2,7 +2,7 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable -from ...classes.graph import Graph +from ...classes.graph import Graph, _Node __all__ = ["CurrentEdge", "Level", "GlobalRelabelThreshold", "build_residual_network", "detect_unboundedness", "build_flow_dict"] @@ -24,8 +24,8 @@ class GlobalRelabelThreshold: def clear_work(self) -> None: ... @_dispatchable -def build_residual_network(G: Graph[Incomplete], capacity): ... +def build_residual_network(G: Graph[_Node], capacity): ... @_dispatchable def detect_unboundedness(R, s, t) -> None: ... @_dispatchable -def build_flow_dict(G: Graph[Incomplete], R): ... +def build_flow_dict(G: Graph[_Node], R): ... diff --git a/stubs/networkx/networkx/algorithms/hierarchy.pyi b/stubs/networkx/networkx/algorithms/hierarchy.pyi index 58e9f32ee292..7d2aea52b9ba 100644 --- a/stubs/networkx/networkx/algorithms/hierarchy.pyi +++ b/stubs/networkx/networkx/algorithms/hierarchy.pyi @@ -1,11 +1,10 @@ -from _typeshed import Incomplete - from networkx.utils.backends import _dispatchable from ..classes.digraph import DiGraph +from ..classes.graph import _Node from ..classes.multidigraph import MultiDiGraph __all__ = ["flow_hierarchy"] @_dispatchable -def flow_hierarchy(G: DiGraph[Incomplete] | MultiDiGraph[Incomplete], weight: str | None = None) -> float: ... +def flow_hierarchy(G: DiGraph[_Node] | MultiDiGraph[_Node], weight: str | None = None) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi index 7a8dbab566fc..6856f2f12da5 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete from collections.abc import Generator -from ...classes.graph import Graph +from ...classes.graph import Graph, _Node __all__ = ["ISMAGS"] @@ -11,12 +11,10 @@ class ISMAGS: node_equality: Incomplete edge_equality: Incomplete - def __init__( - self, graph: Graph[Incomplete], subgraph: Graph[Incomplete], node_match=None, edge_match=None, cache=None - ) -> None: ... + def __init__(self, graph: Graph[_Node], subgraph: Graph[_Node], node_match=None, edge_match=None, cache=None) -> None: ... def find_isomorphisms(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, Incomplete]: ... def largest_common_subgraph(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, None]: ... - def analyze_symmetry(self, graph: Graph[Incomplete], node_partitions, edge_colors): ... + def analyze_symmetry(self, graph: Graph[_Node], node_partitions, edge_colors): ... def is_isomorphic(self, symmetry: bool = False) -> bool: ... def subgraph_is_isomorphic(self, symmetry: bool = False) -> bool: ... def isomorphisms_iter(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, None]: ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi b/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi index 0e8bc76387e9..ad2493c89af4 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete from collections.abc import Generator -from ...classes.graph import Graph +from ...classes.graph import Graph, _Node __all__ = ["GraphMatcher", "DiGraphMatcher"] @@ -14,7 +14,7 @@ class GraphMatcher: old_recursion_limit: Incomplete test: str - def __init__(self, G1: Graph[Incomplete], G2: Graph[Incomplete]) -> None: ... + def __init__(self, G1: Graph[_Node], G2: Graph[_Node]) -> None: ... def reset_recursion_limit(self) -> None: ... def candidate_pairs_iter(self) -> Generator[Incomplete, None, None]: ... core_1: Incomplete @@ -36,7 +36,7 @@ class GraphMatcher: def syntactic_feasibility(self, G1_node, G2_node): ... class DiGraphMatcher(GraphMatcher): - def __init__(self, G1: Graph[Incomplete], G2: Graph[Incomplete]) -> None: ... + def __init__(self, G1: Graph[_Node], G2: Graph[_Node]) -> None: ... def candidate_pairs_iter(self) -> Generator[Incomplete, None, None]: ... core_1: Incomplete core_2: Incomplete diff --git a/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi b/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi index e2ed27e5eac0..b0fea1026625 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from ...classes.graph import Graph +from ...classes.graph import Graph, _Node from .isomorphvf2 import DiGraphMatcher, GraphMatcher __all__ = ["TimeRespectingGraphMatcher", "TimeRespectingDiGraphMatcher"] @@ -9,7 +9,7 @@ class TimeRespectingGraphMatcher(GraphMatcher): temporal_attribute_name: Incomplete delta: Incomplete - def __init__(self, G1: Graph[Incomplete], G2: Graph[Incomplete], temporal_attribute_name, delta) -> None: ... + def __init__(self, G1: Graph[_Node], G2: Graph[_Node], temporal_attribute_name, delta) -> None: ... def one_hop(self, Gx, Gx_node, neighbors): ... def two_hop(self, Gx, core_x, Gx_node, neighbors): ... def semantic_feasibility(self, G1_node, G2_node): ... @@ -18,7 +18,7 @@ class TimeRespectingDiGraphMatcher(DiGraphMatcher): temporal_attribute_name: Incomplete delta: Incomplete - def __init__(self, G1: Graph[Incomplete], G2: Graph[Incomplete], temporal_attribute_name, delta) -> None: ... + def __init__(self, G1: Graph[_Node], G2: Graph[_Node], 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): ... def one_hop(self, Gx, Gx_node, core_x, pred, succ): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi b/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi index b86a22c3e55b..316f8fb1b65a 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi @@ -8,7 +8,7 @@ __all__ = ["rooted_tree_isomorphism", "tree_isomorphism"] @_dispatchable def root_trees(t1, root1, t2, root2): ... @_dispatchable -def assign_levels(G: Graph[Incomplete], root): ... +def assign_levels(G: Graph[_Node], root): ... def group_by_levels(levels): ... def generate_isomorphism(v, w, M, ordered_children): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi b/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi index 67ca3646dea2..b522d21c09ed 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete from collections.abc import Callable -from ...classes.graph import Graph +from ...classes.graph import Graph, _Node from . import isomorphvf2 as vf2 __all__ = ["GraphMatcher", "DiGraphMatcher", "MultiGraphMatcher", "MultiDiGraphMatcher"] @@ -14,8 +14,8 @@ class GraphMatcher(vf2.GraphMatcher): def __init__( self, - G1: Graph[Incomplete], - G2: Graph[Incomplete], + G1: Graph[_Node], + G2: Graph[_Node], node_match: Callable[..., Incomplete] | None = None, edge_match: Callable[..., Incomplete] | None = None, ) -> None: ... @@ -29,8 +29,8 @@ class DiGraphMatcher(vf2.DiGraphMatcher): def __init__( self, - G1: Graph[Incomplete], - G2: Graph[Incomplete], + G1: Graph[_Node], + G2: Graph[_Node], node_match: Callable[..., Incomplete] | None = None, edge_match: Callable[..., Incomplete] | None = None, ) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/operators/binary.pyi b/stubs/networkx/networkx/algorithms/operators/binary.pyi index a33b50529d94..069595330023 100644 --- a/stubs/networkx/networkx/algorithms/operators/binary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/binary.pyi @@ -23,6 +23,6 @@ _Y_co = TypeVar("_Y_co", bound=Hashable, covariant=True) @_dispatchable def compose(G: Graph[_X_co], H: Graph[_Y_co]) -> DiGraph[_X_co | _Y_co]: ... @_dispatchable -def full_join(G: Graph[Incomplete], H, rename=(None, None)): ... +def full_join(G: Graph[_Node], H, rename=(None, None)): ... @_dispatchable def union(G: Graph[_X_co], H: Graph[_Y_co], rename: Iterable[Incomplete] | None = ()) -> DiGraph[_X_co | _Y_co]: ... diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index 33e1cdde3f86..56ce4ec9ecad 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -12,9 +12,9 @@ def is_planar(G: Graph[_Node]) -> bool: ... @_dispatchable def check_planarity(G: Graph[_Node], counterexample: bool = False): ... @_dispatchable -def get_counterexample(G: Graph[Incomplete]) -> Graph[Incomplete]: ... +def get_counterexample(G: Graph[_Node]) -> Graph[_Node]: ... @_dispatchable -def get_counterexample_recursive(G: Graph[Incomplete]) -> Graph[Incomplete]: ... +def get_counterexample_recursive(G: Graph[_Node]) -> Graph[_Node]: ... class Interval: low: Incomplete diff --git a/stubs/networkx/networkx/algorithms/structuralholes.pyi b/stubs/networkx/networkx/algorithms/structuralholes.pyi index b976f042e5b7..e869afe75614 100644 --- a/stubs/networkx/networkx/algorithms/structuralholes.pyi +++ b/stubs/networkx/networkx/algorithms/structuralholes.pyi @@ -7,9 +7,9 @@ from networkx.utils.backends import _dispatchable __all__ = ["constraint", "local_constraint", "effective_size"] @_dispatchable -def mutual_weight(G: Graph[Incomplete], u, v, weight=None) -> Incomplete | int: ... +def mutual_weight(G: Graph[_Node], u, v, weight=None) -> Incomplete | int: ... @_dispatchable -def normalized_mutual_weight(G: Graph[Incomplete], u, v, norm=..., weight=None) -> float: ... +def normalized_mutual_weight(G: Graph[_Node], u, v, norm=..., weight=None) -> float: ... @_dispatchable def effective_size( G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, weight: str | None = None diff --git a/stubs/networkx/networkx/algorithms/threshold.pyi b/stubs/networkx/networkx/algorithms/threshold.pyi index 901c5c1884ef..d5a0361e2c1e 100644 --- a/stubs/networkx/networkx/algorithms/threshold.pyi +++ b/stubs/networkx/networkx/algorithms/threshold.pyi @@ -1,4 +1,3 @@ -from _typeshed import Incomplete from collections.abc import Sequence from networkx.classes.graph import Graph, _Node @@ -17,11 +16,11 @@ def weights_to_creation_sequence(weights, threshold=1, with_labels=False, compac @_dispatchable def threshold_graph(creation_sequence, create_using=None): ... @_dispatchable -def find_alternating_4_cycle(G: Graph[Incomplete]): ... +def find_alternating_4_cycle(G: Graph[_Node]): ... @_dispatchable def find_threshold_graph(G: Graph[_Node], create_using: Graph[_Node] | None = None): ... @_dispatchable -def find_creation_sequence(G: Graph[Incomplete]): ... +def find_creation_sequence(G: Graph[_Node]): ... def triangles(creation_sequence): ... def triangle_sequence(creation_sequence): ... def cluster_sequence(creation_sequence): ... diff --git a/stubs/networkx/networkx/algorithms/tournament.pyi b/stubs/networkx/networkx/algorithms/tournament.pyi index 02d7ab9f7844..613596406d21 100644 --- a/stubs/networkx/networkx/algorithms/tournament.pyi +++ b/stubs/networkx/networkx/algorithms/tournament.pyi @@ -18,7 +18,7 @@ def random_tournament(n: int, seed: int | RandomState | None = None) -> DiGraph[ @_dispatchable def score_sequence(G: Graph[_Node]) -> list[Incomplete]: ... @_dispatchable -def tournament_matrix(G: Graph[Incomplete]): ... +def tournament_matrix(G: Graph[_Node]): ... @_dispatchable def is_reachable(G: Graph[_Node], s: _Node, t: _Node) -> bool: ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi b/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi index 5dd99a54d7ee..bda7d5dc87fd 100644 --- a/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi @@ -17,9 +17,7 @@ __all__ = [ ] @_dispatchable -def generic_bfs_edges( - G: Graph[Incomplete], source, neighbors=None, depth_limit=None -) -> Generator[tuple[Incomplete, Incomplete]]: ... +def generic_bfs_edges(G: Graph[_Node], source, neighbors=None, depth_limit=None) -> Generator[tuple[Incomplete, Incomplete]]: ... @_dispatchable def bfs_edges( G: Graph[_Node], @@ -48,7 +46,7 @@ def bfs_successors( def bfs_layers(G: Graph[_Node], sources) -> Generator[Incomplete, None, None]: ... @_dispatchable def bfs_labeled_edges( - G: Graph[Incomplete], sources + G: Graph[_Node], sources ) -> Generator[tuple[Incomplete, Incomplete, Literal["tree", "level", "forward", "reverse"]]]: ... @_dispatchable def descendants_at_distance(G: Graph[_Node], source, distance): ... diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi index 691aed6839f6..2e65c6657bc2 100644 --- a/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -65,7 +65,7 @@ class ArborescenceIterator: def __init__( self, - G: Graph[Incomplete], + G: Graph[_Node], weight: str = "weight", minimum: bool = True, init_partition: tuple[Incomplete, Incomplete] | None = None, diff --git a/stubs/networkx/networkx/algorithms/tree/decomposition.pyi b/stubs/networkx/networkx/algorithms/tree/decomposition.pyi index d86d43c4c688..6499fcea35a4 100644 --- a/stubs/networkx/networkx/algorithms/tree/decomposition.pyi +++ b/stubs/networkx/networkx/algorithms/tree/decomposition.pyi @@ -1,9 +1,7 @@ -from _typeshed import Incomplete - -from networkx import Graph +from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["junction_tree"] @_dispatchable -def junction_tree(G: Graph[Incomplete]) -> Graph[Incomplete]: ... +def junction_tree(G: Graph[_Node]) -> Graph[_Node]: ... diff --git a/stubs/networkx/networkx/algorithms/tree/mst.pyi b/stubs/networkx/networkx/algorithms/tree/mst.pyi index 3b8307896840..021071870bea 100644 --- a/stubs/networkx/networkx/algorithms/tree/mst.pyi +++ b/stubs/networkx/networkx/algorithms/tree/mst.pyi @@ -27,11 +27,11 @@ class EdgePartition(Enum): EXCLUDED = 2 @_dispatchable -def boruvka_mst_edges(G: Graph[Incomplete], minimum=True, weight="weight", keys=False, data=True, ignore_nan=False): ... +def boruvka_mst_edges(G: Graph[_Node], minimum=True, weight="weight", keys=False, data=True, ignore_nan=False): ... @_dispatchable -def kruskal_mst_edges(G: Graph[Incomplete], minimum, weight="weight", keys=True, data=True, ignore_nan=False, partition=None): ... +def kruskal_mst_edges(G: Graph[_Node], minimum, weight="weight", keys=True, data=True, ignore_nan=False, partition=None): ... @_dispatchable -def prim_mst_edges(G: Graph[Incomplete], minimum, weight="weight", keys=True, data=True, ignore_nan=False): ... +def prim_mst_edges(G: Graph[_Node], minimum, weight="weight", keys=True, data=True, ignore_nan=False): ... ALGORITHMS: dict[str, Callable[..., Generator[Incomplete, Incomplete, Incomplete]]] = ... diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index bed8d21670c1..04023836b788 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -52,32 +52,32 @@ __all__ = [ _U = TypeVar("_U") -def nodes(G: Graph[Incomplete]): ... -def edges(G: Graph[Incomplete], nbunch=None): ... -def degree(G: Graph[Incomplete], nbunch=None, weight=None): ... -def neighbors(G: Graph[Incomplete], n): ... -def number_of_nodes(G: Graph[Incomplete]): ... -def number_of_edges(G: Graph[Incomplete]): ... -def density(G: Graph[Incomplete]): ... -def degree_histogram(G: Graph[Incomplete]) -> list[int]: ... +def nodes(G: Graph[_Node]): ... +def edges(G: Graph[_Node], nbunch=None): ... +def degree(G: Graph[_Node], nbunch=None, weight=None): ... +def neighbors(G: Graph[_Node], n): ... +def number_of_nodes(G: Graph[_Node]): ... +def number_of_edges(G: Graph[_Node]): ... +def density(G: Graph[_Node]): ... +def degree_histogram(G: Graph[_Node]) -> list[int]: ... @overload def is_directed(G: PlanarEmbedding[Hashable]) -> Literal[False]: ... # type: ignore[misc] # Incompatible return types @overload def is_directed(G: DiGraph[Hashable]) -> Literal[True]: ... # type: ignore[misc] # Incompatible return types @overload def is_directed(G: Graph[Hashable]) -> Literal[False]: ... -def freeze(G: Graph[Incomplete]): ... -def is_frozen(G: Graph[Incomplete]) -> bool: ... +def freeze(G: Graph[_Node]): ... +def is_frozen(G: Graph[_Node]) -> bool: ... def add_star(G_to_add_to, nodes_for_star, **attr) -> None: ... def add_path(G_to_add_to, nodes_for_path, **attr) -> None: ... def add_cycle(G_to_add_to, nodes_for_cycle, **attr) -> None: ... -def subgraph(G: Graph[Incomplete], nbunch: _NBunch[_Node]): ... +def subgraph(G: Graph[_Node], nbunch: _NBunch[_Node]): ... def induced_subgraph(G: Graph[_Node], nbunch: _NBunch[_Node]) -> Graph[_Node]: ... -def edge_subgraph(G: Graph[Incomplete], edges: Iterable[Incomplete]): ... -def restricted_view(G: Graph[Incomplete], nodes: Iterable[Incomplete], edges: Iterable[Incomplete]): ... +def edge_subgraph(G: Graph[_Node], edges: Iterable[Incomplete]): ... +def restricted_view(G: Graph[_Node], nodes: Iterable[Incomplete], edges: Iterable[Incomplete]): ... def to_directed(graph): ... def to_undirected(graph): ... -def create_empty_copy(G: Graph[Incomplete], with_data: bool = True): ... +def create_empty_copy(G: Graph[_Node], with_data: bool = True): ... # incomplete: Can "Any scalar value" be enforced? @overload @@ -137,4 +137,4 @@ def selfloop_edges( ) -> Generator[tuple[_Node, _Node, int, _U], None, None]: ... def number_of_selfloops(G: Graph[Hashable]) -> int: ... def is_path(G: Graph[_Node], path: Iterable[Incomplete]) -> bool: ... -def path_weight(G: Graph[Incomplete], path: Iterable[Incomplete], weight: str) -> int: ... +def path_weight(G: Graph[_Node], path: Iterable[Incomplete], weight: str) -> int: ... diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index 36566e233a65..b96869b1a6ba 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -81,7 +81,7 @@ def from_pandas_edgelist( ) -> Graph[Incomplete]: ... @_dispatchable def to_scipy_sparse_array( - G: Graph[Incomplete], nodelist: Collection[_Node] | None = None, dtype=None, weight="weight", format="csr" + G: Graph[_Node], nodelist: Collection[_Node] | None = None, dtype=None, weight="weight", format="csr" ): ... @_dispatchable def from_scipy_sparse_array(A, parallel_edges: bool = False, create_using=None, edge_attribute: str = "weight"): ... diff --git a/stubs/networkx/networkx/drawing/layout.pyi b/stubs/networkx/networkx/drawing/layout.pyi index c8ccf266e25a..bee2ac057d8e 100644 --- a/stubs/networkx/networkx/drawing/layout.pyi +++ b/stubs/networkx/networkx/drawing/layout.pyi @@ -3,7 +3,7 @@ from _typeshed import Incomplete import numpy from numpy.typing import ArrayLike -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = [ "bipartite_layout", @@ -24,25 +24,18 @@ __all__ = [ "arf_layout", ] -def random_layout( - G: Graph[Incomplete], center: ArrayLike | None = None, dim: int = 2, seed=None -) -> dict[Incomplete, Incomplete]: ... +def random_layout(G: Graph[_Node], center: ArrayLike | None = None, dim: int = 2, seed=None) -> dict[Incomplete, Incomplete]: ... def circular_layout( - G: Graph[Incomplete], scale: float = 1, center: ArrayLike | None = None, dim: int = 2 + G: Graph[_Node], scale: float = 1, center: ArrayLike | None = None, dim: int = 2 ) -> dict[Incomplete, Incomplete]: ... def shell_layout( - G: Graph[Incomplete], nlist=None, rotate=None, scale: float = 1, center: ArrayLike | None = None, dim: int = 2 + G: Graph[_Node], nlist=None, rotate=None, scale: float = 1, center: ArrayLike | None = None, dim: int = 2 ) -> dict[Incomplete, Incomplete]: ... def bipartite_layout( - G: Graph[Incomplete], - nodes, - align: str = "vertical", - scale: float = 1, - center: ArrayLike | None = None, - aspect_ratio: float = ..., + G: Graph[_Node], nodes, align: str = "vertical", scale: float = 1, center: ArrayLike | None = None, aspect_ratio: float = ... ) -> dict[Incomplete, Incomplete]: ... def spring_layout( - G: Graph[Incomplete], + G: Graph[_Node], k=None, pos=None, fixed=None, @@ -58,22 +51,16 @@ def spring_layout( fruchterman_reingold_layout = spring_layout def kamada_kawai_layout( - G: Graph[Incomplete], - dist=None, - pos=None, - weight: str = "weight", - scale: float = 1, - center: ArrayLike | None = None, - dim: int = 2, + G: Graph[_Node], dist=None, pos=None, weight: str = "weight", scale: float = 1, center: ArrayLike | None = None, dim: int = 2 ) -> dict[Incomplete, Incomplete]: ... def spectral_layout( - G: Graph[Incomplete], weight: str = "weight", scale: float = 1, center: ArrayLike | None = None, dim: int = 2 + G: Graph[_Node], weight: str = "weight", scale: float = 1, center: ArrayLike | None = None, dim: int = 2 ) -> dict[Incomplete, Incomplete]: ... def planar_layout( - G: Graph[Incomplete], scale: float = 1, center: ArrayLike | None = None, dim: int = 2 + G: Graph[_Node], scale: float = 1, center: ArrayLike | None = None, dim: int = 2 ) -> dict[Incomplete, Incomplete]: ... def spiral_layout( - G: Graph[Incomplete], + G: Graph[_Node], scale: float = 1, center: ArrayLike | None = None, dim: int = 2, @@ -81,10 +68,10 @@ def spiral_layout( equidistant: bool = False, ) -> dict[Incomplete, Incomplete]: ... def multipartite_layout( - G: Graph[Incomplete], subset_key: str = "subset", align: str = "vertical", scale: float = 1, center: ArrayLike | None = None + G: Graph[_Node], subset_key: str = "subset", align: str = "vertical", scale: float = 1, center: ArrayLike | None = None ) -> dict[Incomplete, Incomplete]: ... def arf_layout( - G: Graph[Incomplete], + G: Graph[_Node], pos=None, scaling: float = 1, a: float = 1.1, diff --git a/stubs/networkx/networkx/drawing/nx_pydot.pyi b/stubs/networkx/networkx/drawing/nx_pydot.pyi index 652dd17c9b1c..f626afe276ad 100644 --- a/stubs/networkx/networkx/drawing/nx_pydot.pyi +++ b/stubs/networkx/networkx/drawing/nx_pydot.pyi @@ -2,15 +2,15 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["write_dot", "read_dot", "graphviz_layout", "pydot_layout", "to_pydot", "from_pydot"] -def write_dot(G: Graph[Incomplete], path) -> None: ... +def write_dot(G: Graph[_Node], path) -> None: ... @_dispatchable def read_dot(path) -> Graph[Incomplete]: ... @_dispatchable def from_pydot(P): ... def to_pydot(N): ... -def graphviz_layout(G: Graph[Incomplete], prog: str = "neato", root=None): ... -def pydot_layout(G: Graph[Incomplete], prog: str = "neato", root=None): ... +def graphviz_layout(G: Graph[_Node], prog: str = "neato", root=None): ... +def pydot_layout(G: Graph[_Node], prog: str = "neato", root=None): ... diff --git a/stubs/networkx/networkx/drawing/nx_pylab.pyi b/stubs/networkx/networkx/drawing/nx_pylab.pyi index 286b57de3f43..65de9ced099f 100644 --- a/stubs/networkx/networkx/drawing/nx_pylab.pyi +++ b/stubs/networkx/networkx/drawing/nx_pylab.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete from collections.abc import Collection, Iterable, Mapping, Sequence -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = [ "draw", @@ -20,10 +20,10 @@ __all__ = [ "draw_forceatlas2", ] -def draw(G: Graph[Incomplete], pos=None, ax=None, **kwds) -> None: ... -def draw_networkx(G: Graph[Incomplete], pos=None, arrows=None, with_labels: bool = True, **kwds) -> None: ... +def draw(G: Graph[_Node], pos=None, ax=None, **kwds) -> None: ... +def draw_networkx(G: Graph[_Node], pos=None, arrows=None, with_labels: bool = True, **kwds) -> None: ... def draw_networkx_nodes( - G: Graph[Incomplete], + G: Graph[_Node], pos: Mapping[Incomplete, Incomplete], nodelist: Collection[Incomplete] | None = None, node_size: Incomplete | int = 300, @@ -41,7 +41,7 @@ def draw_networkx_nodes( hide_ticks: bool = True, ): ... def draw_networkx_edges( - G: Graph[Incomplete], + G: Graph[_Node], pos: Mapping[Incomplete, Incomplete], edgelist=None, width: float = 1.0, @@ -65,7 +65,7 @@ def draw_networkx_edges( hide_ticks: bool = True, ): ... def draw_networkx_labels( - G: Graph[Incomplete], + G: Graph[_Node], pos: Mapping[Incomplete, Incomplete], labels=None, font_size: int = 12, @@ -81,7 +81,7 @@ def draw_networkx_labels( hide_ticks: bool = True, ): ... def draw_networkx_edge_labels( - G: Graph[Incomplete], + G: Graph[_Node], pos: Mapping[Incomplete, Incomplete], edge_labels=None, label_pos: float = 0.5, @@ -101,13 +101,13 @@ def draw_networkx_edge_labels( connectionstyle: str = "arc3", hide_ticks: bool = True, ): ... -def draw_circular(G: Graph[Incomplete], **kwargs) -> None: ... -def draw_kamada_kawai(G: Graph[Incomplete], **kwargs) -> None: ... -def draw_random(G: Graph[Incomplete], **kwargs) -> None: ... -def draw_spectral(G: Graph[Incomplete], **kwargs) -> None: ... -def draw_spring(G: Graph[Incomplete], **kwargs) -> None: ... -def draw_shell(G: Graph[Incomplete], nlist=None, **kwargs) -> None: ... -def draw_planar(G: Graph[Incomplete], **kwargs) -> None: ... +def draw_circular(G: Graph[_Node], **kwargs) -> None: ... +def draw_kamada_kawai(G: Graph[_Node], **kwargs) -> None: ... +def draw_random(G: Graph[_Node], **kwargs) -> None: ... +def draw_spectral(G: Graph[_Node], **kwargs) -> None: ... +def draw_spring(G: Graph[_Node], **kwargs) -> None: ... +def draw_shell(G: Graph[_Node], nlist=None, **kwargs) -> None: ... +def draw_planar(G: Graph[_Node], **kwargs) -> None: ... def draw_forceatlas2(G, **kwargs) -> None: ... def apply_alpha( colors, alpha: float | Iterable[float], elem_list, cmap=None, vmin: float | None = None, vmax: float | None = None diff --git a/stubs/networkx/networkx/generators/classic.pyi b/stubs/networkx/networkx/generators/classic.pyi index 80d8d286f656..d279d826f28f 100644 --- a/stubs/networkx/networkx/generators/classic.pyi +++ b/stubs/networkx/networkx/generators/classic.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete from collections.abc import Iterable -from networkx.classes import Graph +from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable __all__ = [ diff --git a/stubs/networkx/networkx/generators/ego.pyi b/stubs/networkx/networkx/generators/ego.pyi index be0b44bfebe2..8bf615df700c 100644 --- a/stubs/networkx/networkx/generators/ego.pyi +++ b/stubs/networkx/networkx/generators/ego.pyi @@ -1,10 +1,8 @@ -from _typeshed import Incomplete - from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["ego_graph"] @_dispatchable -def ego_graph(G: Graph[Incomplete], n, radius: float = 1, center: bool = True, undirected: bool = False, distance=None): ... +def ego_graph(G: Graph[_Node], n, radius: float = 1, center: bool = True, undirected: bool = False, distance=None): ... diff --git a/stubs/networkx/networkx/generators/line.pyi b/stubs/networkx/networkx/generators/line.pyi index 9c22195b6bb9..7d8c00c1e765 100644 --- a/stubs/networkx/networkx/generators/line.pyi +++ b/stubs/networkx/networkx/generators/line.pyi @@ -1,12 +1,10 @@ -from _typeshed import Incomplete - from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["line_graph", "inverse_line_graph"] @_dispatchable -def line_graph(G: Graph[Incomplete], create_using=None): ... +def line_graph(G: Graph[_Node], create_using=None): ... @_dispatchable -def inverse_line_graph(G: Graph[Incomplete]): ... +def inverse_line_graph(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/generators/mycielski.pyi b/stubs/networkx/networkx/generators/mycielski.pyi index cd58d6f51116..2f883c5a2a58 100644 --- a/stubs/networkx/networkx/generators/mycielski.pyi +++ b/stubs/networkx/networkx/generators/mycielski.pyi @@ -1,12 +1,10 @@ -from _typeshed import Incomplete - from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["mycielskian", "mycielski_graph"] @_dispatchable -def mycielskian(G: Graph[Incomplete], iterations: int = 1): ... +def mycielskian(G: Graph[_Node], iterations: int = 1): ... @_dispatchable def mycielski_graph(n: int): ... diff --git a/stubs/networkx/networkx/generators/random_graphs.pyi b/stubs/networkx/networkx/generators/random_graphs.pyi index 48a0dd569420..ecdfb226941a 100644 --- a/stubs/networkx/networkx/generators/random_graphs.pyi +++ b/stubs/networkx/networkx/generators/random_graphs.pyi @@ -2,7 +2,7 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = [ "fast_gnp_random_graph", @@ -47,11 +47,11 @@ def connected_watts_strogatz_graph(n: int, k: int, p: float, tries: int = 100, s @_dispatchable def random_regular_graph(d, n: int, seed=None): ... @_dispatchable -def barabasi_albert_graph(n: int, m: int, seed=None, initial_graph: Graph[Incomplete] | None = None) -> Graph[Incomplete]: ... +def barabasi_albert_graph(n: int, m: int, seed=None, initial_graph: Graph[_Node] | None = None) -> Graph[_Node]: ... @_dispatchable def dual_barabasi_albert_graph( - n: int, m1, m2, p: float, seed=None, initial_graph: Graph[Incomplete] | None = None -) -> Graph[Incomplete]: ... + n: int, m1, m2, p: float, seed=None, initial_graph: Graph[_Node] | None = None +) -> Graph[_Node]: ... @_dispatchable def extended_barabasi_albert_graph(n: int, m: int, p: float, q, seed=None) -> Graph[Incomplete]: ... @_dispatchable diff --git a/stubs/networkx/networkx/generators/spectral_graph_forge.pyi b/stubs/networkx/networkx/generators/spectral_graph_forge.pyi index 9af6bab45043..5db1e7cd1905 100644 --- a/stubs/networkx/networkx/generators/spectral_graph_forge.pyi +++ b/stubs/networkx/networkx/generators/spectral_graph_forge.pyi @@ -1,12 +1,8 @@ -from _typeshed import Incomplete - from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["spectral_graph_forge"] @_dispatchable -def spectral_graph_forge( - G: Graph[Incomplete], alpha: float, transformation: str = "identity", seed=None -) -> Graph[Incomplete]: ... +def spectral_graph_forge(G: Graph[_Node], alpha: float, transformation: str = "identity", seed=None) -> Graph[_Node]: ... diff --git a/stubs/networkx/networkx/generators/stochastic.pyi b/stubs/networkx/networkx/generators/stochastic.pyi index 8c2ace919ad3..f035de187915 100644 --- a/stubs/networkx/networkx/generators/stochastic.pyi +++ b/stubs/networkx/networkx/generators/stochastic.pyi @@ -1,10 +1,8 @@ -from _typeshed import Incomplete - from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["stochastic_graph"] @_dispatchable -def stochastic_graph(G: Graph[Incomplete], copy: bool = True, weight: str = "weight"): ... +def stochastic_graph(G: Graph[_Node], copy: bool = True, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi b/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi index 81bd0dc125e6..d59910f6c58a 100644 --- a/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi +++ b/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi @@ -1,8 +1,6 @@ -from _typeshed import Incomplete - from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["algebraic_connectivity", "fiedler_vector", "spectral_ordering", "spectral_bisection"] @@ -16,30 +14,15 @@ class _LUSolver: @_dispatchable def algebraic_connectivity( - G: Graph[Incomplete], - weight: str = "weight", - normalized: bool = False, - tol: float = 1e-08, - method: str = "tracemin_pcg", - seed=None, + G: Graph[_Node], weight: str = "weight", normalized: bool = False, tol: float = 1e-08, method: str = "tracemin_pcg", seed=None ): ... @_dispatchable def fiedler_vector( - G: Graph[Incomplete], - weight: str = "weight", - normalized: bool = False, - tol: float = 1e-08, - method: str = "tracemin_pcg", - seed=None, + G: Graph[_Node], weight: str = "weight", normalized: bool = False, tol: float = 1e-08, method: str = "tracemin_pcg", seed=None ): ... @_dispatchable def spectral_ordering( - G: Graph[Incomplete], - weight: str = "weight", - normalized: bool = False, - tol: float = 1e-08, - method: str = "tracemin_pcg", - seed=None, + G: Graph[_Node], weight: str = "weight", normalized: bool = False, tol: float = 1e-08, method: str = "tracemin_pcg", seed=None ): ... @_dispatchable def spectral_bisection( diff --git a/stubs/networkx/networkx/linalg/attrmatrix.pyi b/stubs/networkx/networkx/linalg/attrmatrix.pyi index f237afd7079e..d9ab1b11b9fe 100644 --- a/stubs/networkx/networkx/linalg/attrmatrix.pyi +++ b/stubs/networkx/networkx/linalg/attrmatrix.pyi @@ -3,13 +3,13 @@ from collections.abc import Callable from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["attr_matrix", "attr_sparse_matrix"] @_dispatchable def attr_matrix( - G: Graph[Incomplete], + G: Graph[_Node], edge_attr: str | Callable[[Incomplete, Incomplete], Incomplete] | None = None, node_attr: str | Callable[[Incomplete], Incomplete] | None = None, normalized: bool = False, @@ -19,7 +19,7 @@ def attr_matrix( ): ... @_dispatchable def attr_sparse_matrix( - G: Graph[Incomplete], + G: Graph[_Node], edge_attr: str | Callable[[Incomplete, Incomplete], Incomplete] | None = None, node_attr: str | Callable[[Incomplete], Incomplete] | None = None, normalized: bool = False, diff --git a/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi b/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi index bd0ac5865de3..5cd4976079b8 100644 --- a/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi +++ b/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi @@ -3,9 +3,9 @@ from collections.abc import Collection from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["bethe_hessian_matrix"] @_dispatchable -def bethe_hessian_matrix(G: Graph[Incomplete], r: float | None = None, nodelist: Collection[Incomplete] | None = None): ... +def bethe_hessian_matrix(G: Graph[_Node], r: float | None = None, nodelist: Collection[Incomplete] | None = None): ... diff --git a/stubs/networkx/networkx/linalg/graphmatrix.pyi b/stubs/networkx/networkx/linalg/graphmatrix.pyi index aed2772178e3..bb1fdb98b914 100644 --- a/stubs/networkx/networkx/linalg/graphmatrix.pyi +++ b/stubs/networkx/networkx/linalg/graphmatrix.pyi @@ -3,15 +3,13 @@ from collections.abc import Collection from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["incidence_matrix", "adjacency_matrix"] @_dispatchable def incidence_matrix( - G: Graph[Incomplete], nodelist: Collection[Incomplete] | None = None, edgelist=None, oriented: bool = False, weight=None + G: Graph[_Node], nodelist: Collection[Incomplete] | None = None, edgelist=None, oriented: bool = False, weight=None ): ... @_dispatchable -def adjacency_matrix( - G: Graph[Incomplete], nodelist: Collection[Incomplete] | None = None, dtype=None, weight: str = "weight" -): ... +def adjacency_matrix(G: Graph[_Node], nodelist: Collection[Incomplete] | None = None, dtype=None, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/linalg/laplacianmatrix.pyi b/stubs/networkx/networkx/linalg/laplacianmatrix.pyi index 5acd9c4a8d1c..0c9625d2558b 100644 --- a/stubs/networkx/networkx/linalg/laplacianmatrix.pyi +++ b/stubs/networkx/networkx/linalg/laplacianmatrix.pyi @@ -4,7 +4,7 @@ from collections.abc import Collection from networkx.utils.backends import _dispatchable from ..classes.digraph import DiGraph -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = [ "laplacian_matrix", @@ -15,24 +15,16 @@ __all__ = [ ] @_dispatchable -def laplacian_matrix(G: Graph[Incomplete], nodelist: Collection[Incomplete] | None = None, weight: str = "weight"): ... +def laplacian_matrix(G: Graph[_Node], nodelist: Collection[Incomplete] | None = None, weight: str = "weight"): ... @_dispatchable -def normalized_laplacian_matrix(G: Graph[Incomplete], nodelist: Collection[Incomplete] | None = None, weight: str = "weight"): ... +def normalized_laplacian_matrix(G: Graph[_Node], nodelist: Collection[Incomplete] | None = None, weight: str = "weight"): ... @_dispatchable -def total_spanning_tree_weight(G: Graph[Incomplete], weight: str | None = None) -> float: ... +def total_spanning_tree_weight(G: Graph[_Node], weight: str | None = None) -> float: ... @_dispatchable def directed_laplacian_matrix( - G: DiGraph[Incomplete], - nodelist: Collection[Incomplete] | None = None, - weight: str = "weight", - walk_type=None, - alpha: float = 0.95, + G: DiGraph[_Node], nodelist: Collection[Incomplete] | None = None, weight: str = "weight", walk_type=None, alpha: float = 0.95 ): ... @_dispatchable def directed_combinatorial_laplacian_matrix( - G: DiGraph[Incomplete], - nodelist: Collection[Incomplete] | None = None, - weight: str = "weight", - walk_type=None, - alpha: float = 0.95, + G: DiGraph[_Node], nodelist: Collection[Incomplete] | None = None, weight: str = "weight", walk_type=None, alpha: float = 0.95 ): ... diff --git a/stubs/networkx/networkx/linalg/modularitymatrix.pyi b/stubs/networkx/networkx/linalg/modularitymatrix.pyi index bbcae128e80b..a9eac6a3b015 100644 --- a/stubs/networkx/networkx/linalg/modularitymatrix.pyi +++ b/stubs/networkx/networkx/linalg/modularitymatrix.pyi @@ -4,11 +4,11 @@ from collections.abc import Collection from networkx.utils.backends import _dispatchable from ..classes.digraph import DiGraph -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["modularity_matrix", "directed_modularity_matrix"] @_dispatchable -def modularity_matrix(G: Graph[Incomplete], nodelist: Collection[Incomplete] | None = None, weight=None): ... +def modularity_matrix(G: Graph[_Node], nodelist: Collection[Incomplete] | None = None, weight=None): ... @_dispatchable -def directed_modularity_matrix(G: DiGraph[Incomplete], nodelist: Collection[Incomplete] | None = None, weight=None): ... +def directed_modularity_matrix(G: DiGraph[_Node], nodelist: Collection[Incomplete] | None = None, weight=None): ... diff --git a/stubs/networkx/networkx/linalg/spectrum.pyi b/stubs/networkx/networkx/linalg/spectrum.pyi index 397dc5d7ff62..dfc73c966d9b 100644 --- a/stubs/networkx/networkx/linalg/spectrum.pyi +++ b/stubs/networkx/networkx/linalg/spectrum.pyi @@ -1,8 +1,6 @@ -from _typeshed import Incomplete - from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = [ "laplacian_spectrum", @@ -13,12 +11,12 @@ __all__ = [ ] @_dispatchable -def laplacian_spectrum(G: Graph[Incomplete], weight: str = "weight"): ... +def laplacian_spectrum(G: Graph[_Node], weight: str = "weight"): ... @_dispatchable -def normalized_laplacian_spectrum(G: Graph[Incomplete], weight: str = "weight"): ... +def normalized_laplacian_spectrum(G: Graph[_Node], weight: str = "weight"): ... @_dispatchable -def adjacency_spectrum(G: Graph[Incomplete], weight: str = "weight"): ... +def adjacency_spectrum(G: Graph[_Node], weight: str = "weight"): ... @_dispatchable -def modularity_spectrum(G: Graph[Incomplete]): ... +def modularity_spectrum(G: Graph[_Node]): ... @_dispatchable -def bethe_hessian_spectrum(G: Graph[Incomplete], r: float | None = None): ... +def bethe_hessian_spectrum(G: Graph[_Node], r: float | None = None): ... diff --git a/stubs/networkx/networkx/readwrite/adjlist.pyi b/stubs/networkx/networkx/readwrite/adjlist.pyi index a1d705f7f17c..afbe54215d5c 100644 --- a/stubs/networkx/networkx/readwrite/adjlist.pyi +++ b/stubs/networkx/networkx/readwrite/adjlist.pyi @@ -1,14 +1,13 @@ -from _typeshed import Incomplete from collections.abc import Generator from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["generate_adjlist", "write_adjlist", "parse_adjlist", "read_adjlist"] -def generate_adjlist(G: Graph[Incomplete], delimiter: str = " ") -> Generator[str, None, None]: ... -def write_adjlist(G: Graph[Incomplete], path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8") -> None: ... +def generate_adjlist(G: Graph[_Node], delimiter: str = " ") -> Generator[str, None, None]: ... +def write_adjlist(G: Graph[_Node], path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8") -> None: ... @_dispatchable def parse_adjlist(lines, comments: str = "#", delimiter: str | None = None, create_using=None, nodetype=None): ... @_dispatchable diff --git a/stubs/networkx/networkx/readwrite/edgelist.pyi b/stubs/networkx/networkx/readwrite/edgelist.pyi index 3866efcb11b9..562230ec8d67 100644 --- a/stubs/networkx/networkx/readwrite/edgelist.pyi +++ b/stubs/networkx/networkx/readwrite/edgelist.pyi @@ -3,7 +3,7 @@ from collections.abc import Generator from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = [ "generate_edgelist", @@ -15,10 +15,10 @@ __all__ = [ ] def generate_edgelist( - G: Graph[Incomplete], delimiter: str = " ", data: bool | Incomplete = True + G: Graph[_Node], delimiter: str = " ", data: bool | Incomplete = True ) -> Generator[Incomplete, None, None]: ... def write_edgelist( - G: Graph[Incomplete], path, comments: str = "#", delimiter: str = " ", data: bool | Incomplete = True, encoding: str = "utf-8" + G: Graph[_Node], path, comments: str = "#", delimiter: str = " ", data: bool | Incomplete = True, encoding: str = "utf-8" ) -> None: ... @_dispatchable def parse_edgelist( @@ -36,7 +36,7 @@ def read_edgelist( encoding: str = "utf-8", ): ... def write_weighted_edgelist( - G: Graph[Incomplete], path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8" + G: Graph[_Node], path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8" ) -> None: ... @_dispatchable def read_weighted_edgelist( diff --git a/stubs/networkx/networkx/readwrite/gexf.pyi b/stubs/networkx/networkx/readwrite/gexf.pyi index 0528da55ae7b..d2dafff8f97c 100644 --- a/stubs/networkx/networkx/readwrite/gexf.pyi +++ b/stubs/networkx/networkx/readwrite/gexf.pyi @@ -4,15 +4,13 @@ from typing import Literal from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["write_gexf", "read_gexf", "relabel_gexf_graph", "generate_gexf"] -def write_gexf( - G: Graph[Incomplete], path, encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft" -) -> None: ... +def write_gexf(G: Graph[_Node], path, encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft") -> None: ... def generate_gexf( - G: Graph[Incomplete], encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft" + G: Graph[_Node], encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft" ) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable def read_gexf(path, node_type=None, relabel: bool = False, version: str = "1.2draft"): ... @@ -42,8 +40,8 @@ class GEXFWriter(GEXF): def __init__(self, graph=None, encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft") -> None: ... graph_element: Incomplete def add_graph(self, G) -> None: ... - def add_nodes(self, G: Graph[Incomplete], graph_element) -> None: ... - def add_edges(self, G: Graph[Incomplete], graph_element) -> None: ... + def add_nodes(self, G: Graph[_Node], graph_element) -> None: ... + def add_edges(self, G: Graph[_Node], graph_element) -> None: ... def add_attributes(self, node_or_edge, xml_obj, data, default): ... def get_attr_id(self, title, attr_type, edge_or_node, default, mode): ... def add_viz(self, element, node_data): ... @@ -62,14 +60,14 @@ class GEXFReader(GEXF): def __call__(self, stream): ... timeformat: Incomplete def make_graph(self, graph_xml): ... - def add_node(self, G: Graph[Incomplete], node_xml, node_attr, node_pid=None) -> None: ... + def add_node(self, G: Graph[_Node], node_xml, node_attr, node_pid=None) -> None: ... def add_start_end(self, data, xml): ... def add_viz(self, data, node_xml): ... def add_parents(self, data, node_xml): ... def add_slices(self, data, node_or_edge_xml): ... def add_spells(self, data, node_or_edge_xml): ... - def add_edge(self, G: Graph[Incomplete], edge_element, edge_attr) -> None: ... + def add_edge(self, G: Graph[_Node], edge_element, edge_attr) -> None: ... def decode_attr_elements(self, gexf_keys, obj_xml): ... def find_gexf_attributes(self, attributes_element): ... -def relabel_gexf_graph(G: Graph[Incomplete]): ... +def relabel_gexf_graph(G: Graph[_Node]): ... diff --git a/stubs/networkx/networkx/readwrite/gml.pyi b/stubs/networkx/networkx/readwrite/gml.pyi index 59f6cc11a491..9d42540c931f 100644 --- a/stubs/networkx/networkx/readwrite/gml.pyi +++ b/stubs/networkx/networkx/readwrite/gml.pyi @@ -5,7 +5,7 @@ from typing import Final, Generic, NamedTuple, TypeVar from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node _T = TypeVar("_T") @@ -41,6 +41,6 @@ LIST_START_VALUE: Final = "_networkx_list_start" def parse_gml_lines(lines, label, destringizer): ... def literal_stringizer(value) -> str: ... def generate_gml( - G: Graph[Incomplete], stringizer: Callable[[Incomplete], str] | None = None + G: Graph[_Node], stringizer: Callable[[Incomplete], str] | None = None ) -> Generator[Incomplete, Incomplete, None]: ... -def write_gml(G: Graph[Incomplete], path, stringizer: Callable[[Incomplete], str] | None = None) -> None: ... +def write_gml(G: Graph[_Node], path, stringizer: Callable[[Incomplete], str] | None = None) -> None: ... diff --git a/stubs/networkx/networkx/readwrite/graph6.pyi b/stubs/networkx/networkx/readwrite/graph6.pyi index 826b55c4b58c..84a1348b9707 100644 --- a/stubs/networkx/networkx/readwrite/graph6.pyi +++ b/stubs/networkx/networkx/readwrite/graph6.pyi @@ -3,16 +3,16 @@ from collections.abc import Iterable from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["from_graph6_bytes", "read_graph6", "to_graph6_bytes", "write_graph6"] @_dispatchable def from_graph6_bytes(bytes_in) -> Graph[Incomplete]: ... -def to_graph6_bytes(G: Graph[Incomplete], nodes: Iterable[Incomplete] | None = None, header: bool = True): ... +def to_graph6_bytes(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, header: bool = True): ... @_dispatchable def read_graph6(path): ... -def write_graph6(G: Graph[Incomplete], path, nodes: Iterable[Incomplete] | None = None, header: bool = True): ... -def write_graph6_file(G: Graph[Incomplete], f, nodes: Iterable[Incomplete] | None = None, header: bool = True): ... +def write_graph6(G: Graph[_Node], path, nodes: Iterable[Incomplete] | None = None, header: bool = True): ... +def write_graph6_file(G: Graph[_Node], f, nodes: Iterable[Incomplete] | None = None, header: bool = True): ... def data_to_n(data): ... def n_to_data(n): ... diff --git a/stubs/networkx/networkx/readwrite/graphml.pyi b/stubs/networkx/networkx/readwrite/graphml.pyi index fd5639474f51..8b71d329eb6f 100644 --- a/stubs/networkx/networkx/readwrite/graphml.pyi +++ b/stubs/networkx/networkx/readwrite/graphml.pyi @@ -4,7 +4,7 @@ from typing import Final, Literal from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = [ "write_graphml", @@ -18,7 +18,7 @@ __all__ = [ ] def write_graphml_xml( - G: Graph[Incomplete], + G: Graph[_Node], path, encoding: str = "utf-8", prettyprint: bool = True, @@ -27,7 +27,7 @@ def write_graphml_xml( edge_id_from_attribute=None, ) -> None: ... def write_graphml_lxml( - G: Graph[Incomplete], + G: Graph[_Node], path, encoding: str = "utf-8", prettyprint: bool = True, @@ -36,11 +36,7 @@ def write_graphml_lxml( edge_id_from_attribute=None, ): ... def generate_graphml( - G: Graph[Incomplete], - encoding: str = "utf-8", - prettyprint: bool = True, - named_key_ids: bool = False, - edge_id_from_attribute=None, + G: Graph[_Node], encoding: str = "utf-8", prettyprint: bool = True, named_key_ids: bool = False, edge_id_from_attribute=None ) -> Generator[Incomplete, Incomplete, None]: ... @_dispatchable def read_graphml(path, node_type=..., edge_key_type=..., force_multigraph: bool = False): ... @@ -82,8 +78,8 @@ class GraphMLWriter(GraphML): def get_key(self, name, attr_type, scope, default): ... def add_data(self, name, element_type, value, scope: str = "all", default=None): ... def add_attributes(self, scope, xml_obj, data, default) -> None: ... - def add_nodes(self, G: Graph[Incomplete], graph_element) -> None: ... - def add_edges(self, G: Graph[Incomplete], graph_element) -> None: ... + def add_nodes(self, G: Graph[_Node], graph_element) -> None: ... + def add_edges(self, G: Graph[_Node], graph_element) -> None: ... def add_graph_element(self, G) -> None: ... def add_graphs(self, graph_list) -> None: ... def dump(self, stream) -> None: ... @@ -128,7 +124,7 @@ class GraphMLReader(GraphML): xml: Incomplete def __call__(self, path=None, string=None) -> Generator[Incomplete, None, None]: ... def make_graph(self, graph_xml, graphml_keys, defaults, G=None): ... - def add_node(self, G: Graph[Incomplete], node_xml, graphml_keys, defaults) -> None: ... - def add_edge(self, G: Graph[Incomplete], edge_element, graphml_keys) -> None: ... + def add_node(self, G: Graph[_Node], node_xml, graphml_keys, defaults) -> None: ... + def add_edge(self, G: Graph[_Node], edge_element, graphml_keys) -> None: ... def decode_data_elements(self, graphml_keys, obj_xml): ... def find_graphml_keys(self, graph_element): ... diff --git a/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi b/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi index a820f3575f1e..6e3d15dc5c8a 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi @@ -4,12 +4,12 @@ from typing import Any from networkx.utils.backends import _dispatchable -from ...classes.graph import Graph +from ...classes.graph import Graph, _Node __all__ = ["adjacency_data", "adjacency_graph"] # Any: Complex type union -def adjacency_data(G: Graph[Incomplete], attrs: Mapping[str, Incomplete] = {"id": "id", "key": "key"}) -> dict[str, Any]: ... +def adjacency_data(G: Graph[_Node], attrs: Mapping[str, Incomplete] = {"id": "id", "key": "key"}) -> dict[str, Any]: ... @_dispatchable def adjacency_graph( data, directed: bool = False, multigraph: bool = True, attrs: Mapping[str, Incomplete] = {"id": "id", "key": "key"} diff --git a/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi b/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi index 9598ccb32cdc..76370fe9ab23 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi @@ -4,11 +4,11 @@ from typing import Any from networkx.utils.backends import _dispatchable -from ...classes.graph import Graph +from ...classes.graph import Graph, _Node __all__ = ["cytoscape_data", "cytoscape_graph"] # Any: Complex type union -def cytoscape_data(G: Graph[Incomplete], name: str = "name", ident: str = "id") -> dict[str, Any]: ... +def cytoscape_data(G: Graph[_Node], name: str = "name", ident: str = "id") -> dict[str, Any]: ... @_dispatchable def cytoscape_graph(data: Mapping[str, Incomplete], name: str = "name", ident: str = "id"): ... diff --git a/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi b/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi index 7fa38ff946f3..49a6016c8329 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi @@ -3,12 +3,12 @@ from collections.abc import Mapping from networkx.utils.backends import _dispatchable -from ...classes.graph import Graph +from ...classes.graph import Graph, _Node __all__ = ["node_link_data", "node_link_graph"] def node_link_data( - G: Graph[Incomplete], + G: Graph[_Node], *, source: str = "source", target: str = "target", diff --git a/stubs/networkx/networkx/readwrite/json_graph/tree.pyi b/stubs/networkx/networkx/readwrite/json_graph/tree.pyi index d4b2b1d40b24..c4f28eebcc09 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/tree.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/tree.pyi @@ -3,10 +3,10 @@ from collections.abc import Mapping from networkx.utils.backends import _dispatchable -from ...classes.graph import Graph +from ...classes.graph import Graph, _Node __all__ = ["tree_data", "tree_graph"] -def tree_data(G: Graph[Incomplete], root, ident: str = "id", children: str = "children"): ... +def tree_data(G: Graph[_Node], root, ident: str = "id", children: str = "children"): ... @_dispatchable def tree_graph(data: Mapping[str, Incomplete], ident: str = "id", children: str = "children"): ... diff --git a/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi b/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi index 3caec2c4a52d..4e8dd4d8c3bc 100644 --- a/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi +++ b/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi @@ -1,15 +1,14 @@ -from _typeshed import Incomplete from collections.abc import Generator from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["generate_multiline_adjlist", "write_multiline_adjlist", "parse_multiline_adjlist", "read_multiline_adjlist"] -def generate_multiline_adjlist(G: Graph[Incomplete], delimiter: str = " ") -> Generator[str, None, None]: ... +def generate_multiline_adjlist(G: Graph[_Node], delimiter: str = " ") -> Generator[str, None, None]: ... def write_multiline_adjlist( - G: Graph[Incomplete], path, delimiter: str = " ", comments: str = "#", encoding: str = "utf-8" + G: Graph[_Node], path, delimiter: str = " ", comments: str = "#", encoding: str = "utf-8" ) -> None: ... @_dispatchable def parse_multiline_adjlist( diff --git a/stubs/networkx/networkx/readwrite/p2g.pyi b/stubs/networkx/networkx/readwrite/p2g.pyi index 4a6dd96252bb..ebdc333a52ac 100644 --- a/stubs/networkx/networkx/readwrite/p2g.pyi +++ b/stubs/networkx/networkx/readwrite/p2g.pyi @@ -2,10 +2,10 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node from ..classes.multidigraph import MultiDiGraph -def write_p2g(G: Graph[Incomplete], path, encoding: str = "utf-8") -> None: ... +def write_p2g(G: Graph[_Node], path, encoding: str = "utf-8") -> None: ... @_dispatchable def read_p2g(path, encoding: str = "utf-8") -> MultiDiGraph[Incomplete]: ... @_dispatchable diff --git a/stubs/networkx/networkx/readwrite/pajek.pyi b/stubs/networkx/networkx/readwrite/pajek.pyi index 081a1ad60865..9f4d5e776954 100644 --- a/stubs/networkx/networkx/readwrite/pajek.pyi +++ b/stubs/networkx/networkx/readwrite/pajek.pyi @@ -3,12 +3,12 @@ from collections.abc import Generator, Iterable from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["read_pajek", "parse_pajek", "generate_pajek", "write_pajek"] -def generate_pajek(G: Graph[Incomplete]) -> Generator[Incomplete, None, None]: ... -def write_pajek(G: Graph[Incomplete], path, encoding: str = "UTF-8") -> None: ... +def generate_pajek(G: Graph[_Node]) -> Generator[Incomplete, None, None]: ... +def write_pajek(G: Graph[_Node], path, encoding: str = "UTF-8") -> None: ... @_dispatchable def read_pajek(path, encoding: str = "UTF-8"): ... @_dispatchable diff --git a/stubs/networkx/networkx/readwrite/sparse6.pyi b/stubs/networkx/networkx/readwrite/sparse6.pyi index b2a862631705..2c8aed0e56fa 100644 --- a/stubs/networkx/networkx/readwrite/sparse6.pyi +++ b/stubs/networkx/networkx/readwrite/sparse6.pyi @@ -3,13 +3,13 @@ from collections.abc import Iterable from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["from_sparse6_bytes", "read_sparse6", "to_sparse6_bytes", "write_sparse6"] @_dispatchable def from_sparse6_bytes(string: str) -> Graph[Incomplete]: ... -def to_sparse6_bytes(G: Graph[Incomplete], nodes: Iterable[Incomplete] | None = None, header: bool = True): ... +def to_sparse6_bytes(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, header: bool = True): ... @_dispatchable def read_sparse6(path): ... -def write_sparse6(G: Graph[Incomplete], path, nodes=None, header: bool = True) -> None: ... +def write_sparse6(G: Graph[_Node], path, nodes=None, header: bool = True) -> None: ... diff --git a/stubs/networkx/networkx/utils/rcm.pyi b/stubs/networkx/networkx/utils/rcm.pyi index 3f5547e34203..6149c1512bad 100644 --- a/stubs/networkx/networkx/utils/rcm.pyi +++ b/stubs/networkx/networkx/utils/rcm.pyi @@ -1,11 +1,11 @@ from _typeshed import Incomplete from collections.abc import Generator -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = ["cuthill_mckee_ordering", "reverse_cuthill_mckee_ordering"] -def cuthill_mckee_ordering(G: Graph[Incomplete], heuristic=None) -> Generator[Incomplete, Incomplete, None]: ... -def reverse_cuthill_mckee_ordering(G: Graph[Incomplete], heuristic=None): ... -def connected_cuthill_mckee_ordering(G: Graph[Incomplete], heuristic=None): ... -def pseudo_peripheral_node(G: Graph[Incomplete]): ... +def cuthill_mckee_ordering(G: Graph[_Node], heuristic=None) -> Generator[Incomplete, Incomplete, None]: ... +def reverse_cuthill_mckee_ordering(G: Graph[_Node], heuristic=None): ... +def connected_cuthill_mckee_ordering(G: Graph[_Node], heuristic=None): ... +def pseudo_peripheral_node(G: Graph[_Node]): ... From 6409a80d225ef739a909c29aa8711d9c420e2e3a Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 25 Jul 2025 15:31:58 -0400 Subject: [PATCH 10/17] Pass tests --- stubs/networkx/networkx/algorithms/tournament.pyi | 2 -- stubs/networkx/networkx/drawing/layout.pyi | 2 +- stubs/networkx/networkx/drawing/nx_pylab.pyi | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/tournament.pyi b/stubs/networkx/networkx/algorithms/tournament.pyi index d46386b89c12..6ca969c6922a 100644 --- a/stubs/networkx/networkx/algorithms/tournament.pyi +++ b/stubs/networkx/networkx/algorithms/tournament.pyi @@ -5,8 +5,6 @@ from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable from numpy.random import RandomState -from ..classes.digraph import DiGraph - __all__ = [ "hamiltonian_path", "is_reachable", diff --git a/stubs/networkx/networkx/drawing/layout.pyi b/stubs/networkx/networkx/drawing/layout.pyi index b14e98200356..0a9dc3b696cb 100644 --- a/stubs/networkx/networkx/drawing/layout.pyi +++ b/stubs/networkx/networkx/drawing/layout.pyi @@ -46,7 +46,7 @@ def shell_layout( ) -> dict[Incomplete, Incomplete]: ... def bipartite_layout( G: Graph[_Node], - nodes, + nodes=None, align: str = "vertical", scale: float = 1, center: ArrayLike | None = None, diff --git a/stubs/networkx/networkx/drawing/nx_pylab.pyi b/stubs/networkx/networkx/drawing/nx_pylab.pyi index 104cca7a5851..adb15d63d250 100644 --- a/stubs/networkx/networkx/drawing/nx_pylab.pyi +++ b/stubs/networkx/networkx/drawing/nx_pylab.pyi @@ -1,8 +1,6 @@ from _typeshed import Incomplete from collections.abc import Collection, Iterable, Mapping, Sequence -from networkx.classes.graph import Graph, _Node - from ..classes.graph import Graph, _Node __all__ = [ From 33f62496c06521cb873c1292a3bf2e1b4d05c105 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 20 Aug 2025 14:36:45 -0400 Subject: [PATCH 11/17] Discard changes to stubs/networkx/networkx/classes/digraph.pyi --- stubs/networkx/networkx/classes/digraph.pyi | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/stubs/networkx/networkx/classes/digraph.pyi b/stubs/networkx/networkx/classes/digraph.pyi index dba6edff4837..dacf44f8d48c 100644 --- a/stubs/networkx/networkx/classes/digraph.pyi +++ b/stubs/networkx/networkx/classes/digraph.pyi @@ -5,14 +5,7 @@ from typing_extensions import Self from networkx.classes.coreviews import AdjacencyView from networkx.classes.graph import Graph, _Node -from networkx.classes.reportviews import ( - DiDegreeView, - InDegreeView, - InMultiDegreeView, - OutDegreeView, - OutEdgeView, - OutMultiDegreeView, -) +from networkx.classes.reportviews import InDegreeView, InMultiDegreeView, OutDegreeView, OutEdgeView, OutMultiDegreeView __all__ = ["DiGraph"] @@ -31,10 +24,9 @@ class DiGraph(Graph[_Node]): @cached_property def in_edges(self) -> OutEdgeView[_Node]: ... @cached_property - def degree(self) -> DiDegreeView[_Node]: ... - @cached_property def in_degree(self) -> InDegreeView[_Node] | InMultiDegreeView[_Node]: ... # Include subtypes' possible return types @cached_property def out_degree(self) -> OutDegreeView[_Node] | OutMultiDegreeView[_Node]: ... # Include subtypes' possible return types def to_undirected(self, reciprocal: bool = False, as_view: bool = False) -> Graph[_Node]: ... # type: ignore[override] # Has an additional `reciprocal` keyword argument def reverse(self, copy: bool = True) -> Self: ... + def copy(self, as_view: bool = False) -> DiGraph[_Node]: ... From cba33cc0ba05a785433fac453ec1342f35956f6e Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 20 Aug 2025 14:37:23 -0400 Subject: [PATCH 12/17] Discard changes to stubs/networkx/networkx/classes/graph.pyi --- stubs/networkx/networkx/classes/graph.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi index 4b8fbcce1aba..ec771d64ece9 100644 --- a/stubs/networkx/networkx/classes/graph.pyi +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -48,10 +48,10 @@ class Graph(Collection[_Node]): def name(self) -> str: ... @name.setter def name(self, s: str) -> None: ... + def __getitem__(self, n: _Node) -> AtlasView[_Node, str, Any]: ... def __iter__(self) -> Iterator[_Node]: ... def __contains__(self, n: object) -> bool: ... def __len__(self) -> int: ... - def __getitem__(self, n: _Node) -> AtlasView[_Node, str, Any]: ... def add_node(self, node_for_adding: _Node, **attr: Any) -> None: ... # attr: Set or change node attributes using key=value def add_nodes_from(self, nodes_for_adding: Iterable[_NodePlus[_Node]], **attr) -> None: ... def remove_node(self, n: _Node) -> None: ... @@ -90,7 +90,7 @@ class Graph(Collection[_Node]): def copy(self, as_view: bool = False) -> Self: ... def to_directed(self, as_view: bool = False) -> DiGraph[_Node]: ... def to_undirected(self, as_view: bool = False) -> Graph[_Node]: ... - def subgraph(self, nodes: _NBunch[_Node]) -> Graph[_Node]: ... + def subgraph(self, nodes: Iterable[_Node]) -> Graph[_Node]: ... def edge_subgraph(self, edges: Iterable[_Edge[_Node]]) -> Graph[_Node]: ... @overload def size(self, weight: None = None) -> int: ... From fc0104b6739cdd8b89513400c825d7437e774bb8 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 20 Aug 2025 14:37:40 -0400 Subject: [PATCH 13/17] Discard changes to stubs/networkx/networkx/classes/multidigraph.pyi --- stubs/networkx/networkx/classes/multidigraph.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stubs/networkx/networkx/classes/multidigraph.pyi b/stubs/networkx/networkx/classes/multidigraph.pyi index bae251859439..0bf2f2fe87cd 100644 --- a/stubs/networkx/networkx/classes/multidigraph.pyi +++ b/stubs/networkx/networkx/classes/multidigraph.pyi @@ -5,7 +5,7 @@ from networkx.classes.coreviews import MultiAdjacencyView from networkx.classes.digraph import DiGraph from networkx.classes.graph import _Node from networkx.classes.multigraph import MultiGraph -from networkx.classes.reportviews import DiMultiDegreeView, InMultiDegreeView, OutMultiDegreeView, OutMultiEdgeView +from networkx.classes.reportviews import InMultiDegreeView, OutMultiDegreeView, OutMultiEdgeView __all__ = ["MultiDiGraph"] @@ -19,11 +19,11 @@ class MultiDiGraph(MultiGraph[_Node], DiGraph[_Node]): @cached_property def out_edges(self) -> OutMultiEdgeView[_Node]: ... @cached_property - def degree(self) -> DiMultiDegreeView[_Node]: ... - @cached_property def in_edges(self) -> OutMultiEdgeView[_Node]: ... @cached_property def in_degree(self) -> InMultiDegreeView[_Node]: ... @cached_property def out_degree(self) -> OutMultiDegreeView[_Node]: ... def to_undirected(self, reciprocal: bool = False, as_view: bool = False) -> MultiGraph[_Node]: ... # type: ignore[override] + def reverse(self, copy: bool = True) -> MultiDiGraph[_Node]: ... + def copy(self, as_view: bool = False) -> MultiDiGraph[_Node]: ... From 764a6d2a856365d6ba210eefed91357dd3da50aa Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 20 Aug 2025 14:38:02 -0400 Subject: [PATCH 14/17] Discard changes to stubs/networkx/networkx/classes/multigraph.pyi --- stubs/networkx/networkx/classes/multigraph.pyi | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/stubs/networkx/networkx/classes/multigraph.pyi b/stubs/networkx/networkx/classes/multigraph.pyi index 9d34c0d7da48..a35727bdf7e0 100644 --- a/stubs/networkx/networkx/classes/multigraph.pyi +++ b/stubs/networkx/networkx/classes/multigraph.pyi @@ -7,7 +7,7 @@ from typing_extensions import TypeAlias from networkx.classes.coreviews import MultiAdjacencyView from networkx.classes.graph import Graph, _MapFactory, _Node from networkx.classes.multidigraph import MultiDiGraph -from networkx.classes.reportviews import DiMultiDegreeView, MultiDegreeView, MultiEdgeView, OutMultiEdgeView +from networkx.classes.reportviews import OutMultiEdgeView _MultiEdge: TypeAlias = tuple[_Node, _Node, int] # noqa: Y047 @@ -15,8 +15,6 @@ __all__ = ["MultiGraph"] class MultiGraph(Graph[_Node]): edge_key_dict_factory: ClassVar[_MapFactory] - def to_directed_class(self) -> type[MultiDiGraph[_Node]]: ... - def to_undirected_class(self) -> type[MultiGraph[_Node]]: ... def __init__(self, incoming_graph_data=None, multigraph_input: bool | None = None, **attr) -> None: ... @cached_property def adj(self) -> MultiAdjacencyView[_Node, _Node, dict[str, Incomplete]]: ... @@ -24,12 +22,12 @@ class MultiGraph(Graph[_Node]): def add_edge(self, u_for_edge, v_for_edge, key=None, **attr): ... # type: ignore[override] # Has an additional `key` keyword argument def remove_edge(self, u, v, key=None): ... def has_edge(self, u: _Node, v: _Node, key=None) -> bool: ... - @cached_property - def edges(self) -> MultiEdgeView[_Node] | OutMultiEdgeView[_Node]: ... # Include subtypes' possible return types def get_edge_data( # type: ignore[override] # Has an additional `key` keyword argument self, u, v, key=None, default=None ) -> Mapping[str, Incomplete]: ... - @cached_property - def degree(self) -> MultiDegreeView[_Node] | DiMultiDegreeView[_Node]: ... # Include subtypes' possible return types + def copy(self, as_view: bool = False) -> MultiGraph[_Node]: ... def to_directed(self, as_view: bool = False) -> MultiDiGraph[_Node]: ... def to_undirected(self, as_view: bool = False) -> MultiGraph[_Node]: ... + def number_of_edges(self, u: _Node | None = None, v: _Node | None = None) -> int: ... + @cached_property + def edges(self) -> OutMultiEdgeView[_Node]: ... From 2ba94b7f31a72e0901af20ad07b040c5494484f8 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 20 Aug 2025 14:39:49 -0400 Subject: [PATCH 15/17] Update stubs/networkx/networkx/classes/reportviews.pyi --- stubs/networkx/networkx/classes/reportviews.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index 9c614737f217..0b25fe8570e3 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -202,7 +202,7 @@ class InEdgeView(OutEdgeView[_Node]): class OutMultiEdgeView(OutEdgeView[_Node]): def __iter__(self) -> Iterator[tuple[_Node, _Node, Incomplete]]: ... # type: ignore[override] def __getitem__(self, e: tuple[_Node, _Node, Incomplete]) -> dict[str, Any]: ... # type: ignore[override] - dataview: type[ # Include subtypes' possible types + dataview: type[ # Including subtypes' possible return types for LSP OutMultiEdgeDataView[Incomplete, Incomplete] | MultiEdgeDataView[Incomplete, Incomplete] | InMultiEdgeDataView[Incomplete, Incomplete] From 5bcdc2c601406a08e75d6d00e348851dbd159b88 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 20 Aug 2025 17:17:40 -0400 Subject: [PATCH 16/17] Update stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi --- .../networkx/algorithms/approximation/traveling_salesman.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi index 50833b85472c..cd33c37a058a 100644 --- a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi @@ -15,6 +15,7 @@ __all__ = [ "simulated_annealing_tsp", "threshold_accepting_tsp", ] + _SupportsLenAndGetItemT = TypeVar("_SupportsLenAndGetItemT", bound=SupportsLenAndGetItem[Any]) def swap_two_nodes(soln: _SupportsLenAndGetItemT, seed) -> _SupportsLenAndGetItemT: ... From 213708e42d3b85e7753b412a610d0e42e1a34902 Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 19 Dec 2025 21:34:00 -0500 Subject: [PATCH 17/17] Post-merge fixes --- stubs/networkx/networkx/algorithms/bipartite/matrix.pyi | 2 +- stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi index a347814476bc..22b9ba19d5a8 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Collection +from collections.abc import Collection, Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable diff --git a/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi index 834ba40f6220..c2bb14effd7d 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi @@ -26,6 +26,7 @@ class ISMAGS: def __init__(self, graph: Graph[_Node], subgraph: Graph[_Node], node_match=None, edge_match=None, cache=None) -> None: ... def create_aligned_partitions(self, thing_matcher, sg_things, g_things): ... def find_isomorphisms(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, Incomplete]: ... + def largest_common_subgraph(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, None]: ... def analyze_subgraph_symmetry(self) -> dict[Hashable, set[Hashable]]: ... def is_isomorphic(self, symmetry: bool = False) -> bool: ... def subgraph_is_isomorphic(self, symmetry: bool = False) -> bool: ...