From afa3c9c16e215da62286e29e4cd9c1672a7e7c3e Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Tue, 8 Aug 2023 10:22:19 -0700 Subject: [PATCH 01/37] Add networkx --- pyrightconfig.stricter.json | 1 + stubs/networkx/METADATA.toml | 4 + stubs/networkx/networkx/__init__.pyi | 23 +++ .../networkx/networkx/algorithms/__init__.pyi | 135 ++++++++++++++++++ .../algorithms/approximation/__init__.pyi | 13 ++ .../algorithms/approximation/clique.pyi | 4 + .../approximation/clustering_coefficient.pyi | 3 + .../algorithms/approximation/connectivity.pyi | 7 + .../approximation/distance_measures.pyi | 3 + .../approximation/dominating_set.pyi | 4 + .../algorithms/approximation/kcomponents.pyi | 3 + .../algorithms/approximation/matching.pyi | 1 + .../algorithms/approximation/maxcut.pyi | 11 ++ .../algorithms/approximation/ramsey.pyi | 1 + .../algorithms/approximation/steinertree.pyi | 6 + .../approximation/traveling_salesman.pyi | 41 ++++++ .../algorithms/approximation/treewidth.pyi | 9 ++ .../algorithms/approximation/vertex_cover.pyi | 3 + .../algorithms/assortativity/__init__.pyi | 5 + .../algorithms/assortativity/connectivity.pyi | 9 ++ .../algorithms/assortativity/correlation.pyi | 22 +++ .../algorithms/assortativity/mixing.pyi | 30 ++++ .../assortativity/neighbor_degree.pyi | 9 ++ .../algorithms/assortativity/pairs.pyi | 13 ++ .../networkx/algorithms/asteroidal.pyi | 2 + .../algorithms/bipartite/__init__.pyi | 11 ++ .../networkx/algorithms/bipartite/basic.pyi | 8 ++ .../algorithms/bipartite/centrality.pyi | 3 + .../networkx/algorithms/bipartite/cluster.pyi | 8 ++ .../algorithms/bipartite/covering.pyi | 3 + .../algorithms/bipartite/edgelist.pyi | 32 +++++ .../algorithms/bipartite/generators.pyi | 18 +++ .../algorithms/bipartite/matching.pyi | 11 ++ .../networkx/algorithms/bipartite/matrix.pyi | 13 ++ .../algorithms/bipartite/projection.pyi | 9 ++ .../algorithms/bipartite/redundancy.pyi | 3 + .../algorithms/bipartite/spectral.pyi | 5 + .../networkx/networkx/algorithms/boundary.pyi | 67 +++++++++ .../networkx/networkx/algorithms/bridges.pyi | 21 +++ .../algorithms/centrality/__init__.pyi | 20 +++ .../algorithms/centrality/betweenness.pyi | 17 +++ .../centrality/betweenness_subset.pyi | 8 ++ .../algorithms/centrality/closeness.pyi | 15 ++ .../centrality/current_flow_betweenness.pyi | 26 ++++ .../current_flow_betweenness_subset.pyi | 20 +++ .../centrality/current_flow_closeness.pyi | 7 + .../algorithms/centrality/degree_alg.pyi | 3 + .../algorithms/centrality/dispersion.pyi | 11 ++ .../algorithms/centrality/eigenvector.pyi | 12 ++ .../algorithms/centrality/flow_matrix.pyi | 40 ++++++ .../networkx/algorithms/centrality/group.pyi | 22 +++ .../algorithms/centrality/harmonic.pyi | 8 ++ .../networkx/algorithms/centrality/katz.pyi | 19 +++ .../algorithms/centrality/laplacian.pyi | 10 ++ .../networkx/algorithms/centrality/load.pyi | 10 ++ .../algorithms/centrality/percolation.pyi | 8 ++ .../algorithms/centrality/reaching.pyi | 12 ++ .../algorithms/centrality/second_order.pyi | 1 + .../algorithms/centrality/subgraph_alg.pyi | 4 + .../algorithms/centrality/trophic.pyi | 5 + .../algorithms/centrality/voterank_alg.pyi | 3 + stubs/networkx/networkx/algorithms/chains.pyi | 7 + .../networkx/networkx/algorithms/chordal.pyi | 14 ++ stubs/networkx/networkx/algorithms/clique.pyi | 39 +++++ .../networkx/networkx/algorithms/cluster.pyi | 15 ++ .../networkx/algorithms/coloring/__init__.pyi | 7 + .../coloring/equitable_coloring.pyi | 1 + .../algorithms/coloring/greedy_coloring.pyi | 35 +++++ .../algorithms/communicability_alg.pyi | 2 + .../algorithms/community/__init__.pyi | 10 ++ .../algorithms/community/asyn_fluid.pyi | 3 + .../algorithms/community/centrality.pyi | 6 + .../algorithms/community/community_utils.pyi | 1 + .../networkx/algorithms/community/kclique.pyi | 6 + .../algorithms/community/kernighan_lin.pyi | 9 ++ .../community/label_propagation.pyi | 7 + .../networkx/algorithms/community/louvain.pyi | 17 +++ .../networkx/algorithms/community/lukes.pyi | 8 ++ .../algorithms/community/modularity_max.pyi | 12 ++ .../networkx/algorithms/community/quality.pyi | 7 + .../algorithms/components/__init__.pyi | 6 + .../algorithms/components/attracting.pyi | 6 + .../algorithms/components/biconnected.pyi | 7 + .../algorithms/components/connected.pyi | 7 + .../algorithms/components/semiconnected.pyi | 3 + .../components/strongly_connected.pyi | 18 +++ .../components/weakly_connected.pyi | 10 ++ .../algorithms/connectivity/__init__.pyi | 9 ++ .../algorithms/connectivity/connectivity.pyi | 41 ++++++ .../networkx/algorithms/connectivity/cuts.pyi | 34 +++++ .../connectivity/disjoint_paths.pyi | 25 ++++ .../connectivity/edge_augmentation.pyi | 19 +++ .../connectivity/edge_kcomponents.pyi | 14 ++ .../algorithms/connectivity/kcomponents.pyi | 7 + .../algorithms/connectivity/kcutsets.pyi | 10 ++ .../algorithms/connectivity/stoerwagner.pyi | 1 + .../algorithms/connectivity/utils.pyi | 2 + stubs/networkx/networkx/algorithms/core.pyi | 9 ++ .../networkx/networkx/algorithms/covering.pyi | 4 + stubs/networkx/networkx/algorithms/cuts.pyi | 18 +++ stubs/networkx/networkx/algorithms/cycles.pyi | 21 +++ .../networkx/algorithms/d_separation.pyi | 3 + stubs/networkx/networkx/algorithms/dag.pyi | 26 ++++ .../networkx/algorithms/distance_measures.pyi | 41 ++++++ .../networkx/algorithms/distance_regular.pyi | 4 + .../networkx/algorithms/dominance.pyi | 2 + .../networkx/algorithms/dominating.pyi | 4 + .../algorithms/efficiency_measures.pyi | 3 + stubs/networkx/networkx/algorithms/euler.pyi | 13 ++ .../networkx/algorithms/flow/__init__.pyi | 14 ++ .../algorithms/flow/boykovkolmogorov.pyi | 11 ++ .../algorithms/flow/capacityscaling.pyi | 7 + .../networkx/algorithms/flow/dinitz_alg.pyi | 11 ++ .../networkx/algorithms/flow/edmondskarp.pyi | 11 ++ .../networkx/algorithms/flow/gomory_hu.pyi | 9 ++ .../networkx/algorithms/flow/maxflow.pyi | 38 +++++ .../networkx/algorithms/flow/mincost.pyi | 8 ++ .../algorithms/flow/networksimplex.pyi | 48 +++++++ .../networkx/algorithms/flow/preflowpush.pyi | 11 ++ .../flow/shortestaugmentingpath.pyi | 12 ++ .../networkx/algorithms/flow/utils.pyi | 21 +++ .../networkx/algorithms/graph_hashing.pyi | 16 +++ .../networkx/algorithms/graphical.pyi | 6 + .../networkx/algorithms/hierarchy.pyi | 3 + stubs/networkx/networkx/algorithms/hybrid.pyi | 4 + .../networkx/networkx/algorithms/isolate.pyi | 3 + .../algorithms/isomorphism/__init__.pyi | 7 + .../algorithms/isomorphism/ismags.pyi | 29 ++++ .../algorithms/isomorphism/isomorph.pyi | 17 +++ .../algorithms/isomorphism/isomorphvf2.pyi | 66 +++++++++ .../algorithms/isomorphism/matchhelpers.pyi | 19 +++ .../isomorphism/temporalisomorphvf2.pyi | 26 ++++ .../isomorphism/tree_isomorphism.pyi | 2 + .../networkx/algorithms/isomorphism/vf2pp.pyi | 43 ++++++ .../algorithms/isomorphism/vf2userfunc.pyi | 34 +++++ .../algorithms/link_analysis/__init__.pyi | 2 + .../algorithms/link_analysis/hits_alg.pyi | 9 ++ .../algorithms/link_analysis/pagerank_alg.pyi | 20 +++ .../networkx/algorithms/link_prediction.pyi | 21 +++ .../algorithms/lowest_common_ancestors.pyi | 8 ++ .../networkx/networkx/algorithms/matching.pyi | 6 + .../networkx/algorithms/minors/__init__.pyi | 7 + .../algorithms/minors/contraction.pyi | 17 +++ stubs/networkx/networkx/algorithms/mis.pyi | 5 + stubs/networkx/networkx/algorithms/moral.pyi | 1 + .../algorithms/node_classification.pyi | 4 + .../networkx/algorithms/non_randomness.pyi | 3 + .../algorithms/operators/__init__.pyi | 4 + .../networkx/algorithms/operators/all.pyi | 4 + .../networkx/algorithms/operators/binary.pyi | 22 +++ .../networkx/algorithms/operators/product.pyi | 7 + .../networkx/algorithms/operators/unary.pyi | 9 ++ .../networkx/algorithms/planar_drawing.pyi | 1 + .../networkx/algorithms/planarity.pyi | 78 ++++++++++ .../networkx/algorithms/polynomials.pyi | 2 + .../networkx/algorithms/reciprocity.pyi | 4 + .../networkx/networkx/algorithms/regular.pyi | 3 + .../networkx/networkx/algorithms/richclub.pyi | 5 + .../algorithms/shortest_paths/__init__.pyi | 5 + .../algorithms/shortest_paths/astar.pyi | 8 ++ .../algorithms/shortest_paths/dense.pyi | 8 ++ .../algorithms/shortest_paths/generic.pyi | 42 ++++++ .../algorithms/shortest_paths/unweighted.pyi | 21 +++ .../algorithms/shortest_paths/weighted.pyi | 68 +++++++++ .../networkx/algorithms/similarity.pyi | 80 +++++++++++ .../networkx/algorithms/simple_paths.pyi | 24 ++++ .../networkx/algorithms/smallworld.pyi | 14 ++ .../networkx/networkx/algorithms/smetric.pyi | 1 + .../networkx/algorithms/sparsifiers.pyi | 5 + .../networkx/algorithms/structuralholes.pyi | 9 ++ .../networkx/algorithms/summarization.pyi | 11 ++ stubs/networkx/networkx/algorithms/swap.pyi | 11 ++ .../networkx/algorithms/threshold.pyi | 4 + .../networkx/algorithms/tournament.pyi | 8 ++ .../algorithms/traversal/__init__.pyi | 5 + .../algorithms/traversal/beamsearch.pyi | 6 + .../traversal/breadth_first_search.pyi | 31 ++++ .../traversal/depth_first_search.pyi | 29 ++++ .../networkx/algorithms/traversal/edgebfs.pyi | 6 + .../networkx/algorithms/traversal/edgedfs.pyi | 6 + .../networkx/algorithms/tree/__init__.pyi | 6 + .../networkx/algorithms/tree/branchings.pyi | 98 +++++++++++++ .../networkx/algorithms/tree/coding.pyi | 8 ++ .../algorithms/tree/decomposition.pyi | 1 + .../networkx/networkx/algorithms/tree/mst.pyi | 66 +++++++++ .../networkx/algorithms/tree/operations.pyi | 3 + .../networkx/algorithms/tree/recognition.pyi | 4 + stubs/networkx/networkx/algorithms/triads.pyi | 10 ++ .../networkx/networkx/algorithms/vitality.pyi | 8 ++ .../networkx/networkx/algorithms/voronoi.pyi | 1 + stubs/networkx/networkx/algorithms/wiener.pyi | 3 + stubs/networkx/networkx/classes/__init__.pyi | 13 ++ stubs/networkx/networkx/classes/backends.pyi | 11 ++ stubs/networkx/networkx/classes/coreviews.pyi | 64 +++++++++ stubs/networkx/networkx/classes/digraph.pyi | 32 +++++ stubs/networkx/networkx/classes/filters.pyi | 18 +++ stubs/networkx/networkx/classes/function.pyi | 114 +++++++++++++++ stubs/networkx/networkx/classes/graph.pyi | 106 ++++++++++++++ .../networkx/networkx/classes/graphviews.pyi | 5 + .../networkx/classes/multidigraph.pyi | 16 +++ .../networkx/networkx/classes/multigraph.pyi | 11 ++ .../networkx/networkx/classes/reportviews.pyi | 121 ++++++++++++++++ stubs/networkx/networkx/convert.pyi | 18 +++ stubs/networkx/networkx/convert_matrix.pyi | 50 +++++++ stubs/networkx/networkx/drawing/__init__.pyi | 4 + stubs/networkx/networkx/drawing/layout.pyi | 85 +++++++++++ stubs/networkx/networkx/drawing/nx_agraph.pyi | 34 +++++ stubs/networkx/networkx/drawing/nx_latex.pyi | 36 +++++ stubs/networkx/networkx/drawing/nx_pydot.pyi | 8 ++ stubs/networkx/networkx/drawing/nx_pylab.pyi | 91 ++++++++++++ stubs/networkx/networkx/exception.pyi | 16 +++ .../networkx/networkx/generators/__init__.pyi | 27 ++++ stubs/networkx/networkx/generators/atlas.pyi | 2 + .../networkx/networkx/generators/classic.pyi | 21 +++ .../networkx/networkx/generators/cographs.pyi | 3 + .../networkx/generators/community.pyi | 39 +++++ .../networkx/generators/degree_seq.pyi | 39 +++++ .../networkx/networkx/generators/directed.pyi | 28 ++++ .../networkx/generators/duplication.pyi | 4 + stubs/networkx/networkx/generators/ego.pyi | 10 ++ .../networkx/generators/expanders.pyi | 5 + .../networkx/generators/geometric.pyi | 52 +++++++ .../networkx/generators/harary_graph.pyi | 4 + .../generators/internet_as_graphs.pyi | 36 +++++ .../networkx/generators/intersection.pyi | 5 + .../networkx/generators/interval_graph.pyi | 1 + .../networkx/generators/joint_degree_seq.pyi | 8 ++ .../networkx/networkx/generators/lattice.pyi | 21 +++ stubs/networkx/networkx/generators/line.pyi | 4 + .../networkx/generators/mycielski.pyi | 2 + .../generators/nonisomorphic_trees.pyi | 7 + .../networkx/generators/random_clustered.pyi | 7 + .../networkx/generators/random_graphs.pyi | 45 ++++++ stubs/networkx/networkx/generators/small.pyi | 25 ++++ stubs/networkx/networkx/generators/social.pyi | 4 + .../generators/spectral_graph_forge.pyi | 5 + .../networkx/generators/stochastic.pyi | 1 + stubs/networkx/networkx/generators/sudoku.pyi | 1 + stubs/networkx/networkx/generators/trees.pyi | 7 + stubs/networkx/networkx/generators/triads.pyi | 1 + stubs/networkx/networkx/lazy_imports.pyi | 15 ++ stubs/networkx/networkx/linalg/__init__.pyi | 15 ++ .../networkx/linalg/algebraicconnectivity.pyi | 42 ++++++ stubs/networkx/networkx/linalg/attrmatrix.pyi | 19 +++ .../networkx/linalg/bethehessianmatrix.pyi | 5 + .../networkx/networkx/linalg/graphmatrix.pyi | 15 ++ .../networkx/linalg/laplacianmatrix.pyi | 21 +++ .../networkx/linalg/modularitymatrix.pyi | 8 ++ stubs/networkx/networkx/linalg/spectrum.pyi | 7 + .../networkx/networkx/readwrite/__init__.pyi | 12 ++ stubs/networkx/networkx/readwrite/adjlist.pyi | 22 +++ .../networkx/networkx/readwrite/edgelist.pyi | 43 ++++++ stubs/networkx/networkx/readwrite/gexf.pyi | 86 +++++++++++ stubs/networkx/networkx/readwrite/gml.pyi | 27 ++++ stubs/networkx/networkx/readwrite/graph6.pyi | 6 + stubs/networkx/networkx/readwrite/graphml.pyi | 133 +++++++++++++++++ .../readwrite/json_graph/__init__.pyi | 4 + .../readwrite/json_graph/adjacency.pyi | 7 + .../readwrite/json_graph/cytoscape.pyi | 2 + .../readwrite/json_graph/node_link.pyi | 24 ++++ .../networkx/readwrite/json_graph/tree.pyi | 2 + stubs/networkx/networkx/readwrite/leda.pyi | 2 + .../networkx/readwrite/multiline_adjlist.pyi | 26 ++++ stubs/networkx/networkx/readwrite/p2g.pyi | 3 + stubs/networkx/networkx/readwrite/pajek.pyi | 7 + stubs/networkx/networkx/readwrite/sparse6.pyi | 8 ++ stubs/networkx/networkx/readwrite/text.pyi | 62 ++++++++ stubs/networkx/networkx/relabel.pyi | 21 +++ stubs/networkx/networkx/utils/__init__.pyi | 6 + stubs/networkx/networkx/utils/decorators.pyi | 26 ++++ stubs/networkx/networkx/utils/heaps.pyi | 38 +++++ .../networkx/networkx/utils/mapped_queue.pyi | 22 +++ stubs/networkx/networkx/utils/misc.pyi | 27 ++++ .../networkx/utils/random_sequence.pyi | 13 ++ stubs/networkx/networkx/utils/rcm.pyi | 7 + stubs/networkx/networkx/utils/union_find.pyi | 11 ++ 276 files changed, 4817 insertions(+) create mode 100644 stubs/networkx/METADATA.toml create mode 100644 stubs/networkx/networkx/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/approximation/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/approximation/clique.pyi create mode 100644 stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi create mode 100644 stubs/networkx/networkx/algorithms/approximation/connectivity.pyi create mode 100644 stubs/networkx/networkx/algorithms/approximation/distance_measures.pyi create mode 100644 stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi create mode 100644 stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi create mode 100644 stubs/networkx/networkx/algorithms/approximation/matching.pyi create mode 100644 stubs/networkx/networkx/algorithms/approximation/maxcut.pyi create mode 100644 stubs/networkx/networkx/algorithms/approximation/ramsey.pyi create mode 100644 stubs/networkx/networkx/algorithms/approximation/steinertree.pyi create mode 100644 stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi create mode 100644 stubs/networkx/networkx/algorithms/approximation/treewidth.pyi create mode 100644 stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi create mode 100644 stubs/networkx/networkx/algorithms/assortativity/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi create mode 100644 stubs/networkx/networkx/algorithms/assortativity/correlation.pyi create mode 100644 stubs/networkx/networkx/algorithms/assortativity/mixing.pyi create mode 100644 stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi create mode 100644 stubs/networkx/networkx/algorithms/assortativity/pairs.pyi create mode 100644 stubs/networkx/networkx/algorithms/asteroidal.pyi create mode 100644 stubs/networkx/networkx/algorithms/bipartite/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/bipartite/basic.pyi create mode 100644 stubs/networkx/networkx/algorithms/bipartite/centrality.pyi create mode 100644 stubs/networkx/networkx/algorithms/bipartite/cluster.pyi create mode 100644 stubs/networkx/networkx/algorithms/bipartite/covering.pyi create mode 100644 stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi create mode 100644 stubs/networkx/networkx/algorithms/bipartite/generators.pyi create mode 100644 stubs/networkx/networkx/algorithms/bipartite/matching.pyi create mode 100644 stubs/networkx/networkx/algorithms/bipartite/matrix.pyi create mode 100644 stubs/networkx/networkx/algorithms/bipartite/projection.pyi create mode 100644 stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi create mode 100644 stubs/networkx/networkx/algorithms/bipartite/spectral.pyi create mode 100644 stubs/networkx/networkx/algorithms/boundary.pyi create mode 100644 stubs/networkx/networkx/algorithms/bridges.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/betweenness.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/closeness.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/degree_alg.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/dispersion.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/group.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/harmonic.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/katz.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/laplacian.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/load.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/percolation.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/reaching.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/second_order.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/trophic.pyi create mode 100644 stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi create mode 100644 stubs/networkx/networkx/algorithms/chains.pyi create mode 100644 stubs/networkx/networkx/algorithms/chordal.pyi create mode 100644 stubs/networkx/networkx/algorithms/clique.pyi create mode 100644 stubs/networkx/networkx/algorithms/cluster.pyi create mode 100644 stubs/networkx/networkx/algorithms/coloring/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi create mode 100644 stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi create mode 100644 stubs/networkx/networkx/algorithms/communicability_alg.pyi create mode 100644 stubs/networkx/networkx/algorithms/community/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi create mode 100644 stubs/networkx/networkx/algorithms/community/centrality.pyi create mode 100644 stubs/networkx/networkx/algorithms/community/community_utils.pyi create mode 100644 stubs/networkx/networkx/algorithms/community/kclique.pyi create mode 100644 stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi create mode 100644 stubs/networkx/networkx/algorithms/community/label_propagation.pyi create mode 100644 stubs/networkx/networkx/algorithms/community/louvain.pyi create mode 100644 stubs/networkx/networkx/algorithms/community/lukes.pyi create mode 100644 stubs/networkx/networkx/algorithms/community/modularity_max.pyi create mode 100644 stubs/networkx/networkx/algorithms/community/quality.pyi create mode 100644 stubs/networkx/networkx/algorithms/components/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/components/attracting.pyi create mode 100644 stubs/networkx/networkx/algorithms/components/biconnected.pyi create mode 100644 stubs/networkx/networkx/algorithms/components/connected.pyi create mode 100644 stubs/networkx/networkx/algorithms/components/semiconnected.pyi create mode 100644 stubs/networkx/networkx/algorithms/components/strongly_connected.pyi create mode 100644 stubs/networkx/networkx/algorithms/components/weakly_connected.pyi create mode 100644 stubs/networkx/networkx/algorithms/connectivity/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi create mode 100644 stubs/networkx/networkx/algorithms/connectivity/cuts.pyi create mode 100644 stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi create mode 100644 stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi create mode 100644 stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi create mode 100644 stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi create mode 100644 stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi create mode 100644 stubs/networkx/networkx/algorithms/connectivity/stoerwagner.pyi create mode 100644 stubs/networkx/networkx/algorithms/connectivity/utils.pyi create mode 100644 stubs/networkx/networkx/algorithms/core.pyi create mode 100644 stubs/networkx/networkx/algorithms/covering.pyi create mode 100644 stubs/networkx/networkx/algorithms/cuts.pyi create mode 100644 stubs/networkx/networkx/algorithms/cycles.pyi create mode 100644 stubs/networkx/networkx/algorithms/d_separation.pyi create mode 100644 stubs/networkx/networkx/algorithms/dag.pyi create mode 100644 stubs/networkx/networkx/algorithms/distance_measures.pyi create mode 100644 stubs/networkx/networkx/algorithms/distance_regular.pyi create mode 100644 stubs/networkx/networkx/algorithms/dominance.pyi create mode 100644 stubs/networkx/networkx/algorithms/dominating.pyi create mode 100644 stubs/networkx/networkx/algorithms/efficiency_measures.pyi create mode 100644 stubs/networkx/networkx/algorithms/euler.pyi create mode 100644 stubs/networkx/networkx/algorithms/flow/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi create mode 100644 stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi create mode 100644 stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi create mode 100644 stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi create mode 100644 stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi create mode 100644 stubs/networkx/networkx/algorithms/flow/maxflow.pyi create mode 100644 stubs/networkx/networkx/algorithms/flow/mincost.pyi create mode 100644 stubs/networkx/networkx/algorithms/flow/networksimplex.pyi create mode 100644 stubs/networkx/networkx/algorithms/flow/preflowpush.pyi create mode 100644 stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi create mode 100644 stubs/networkx/networkx/algorithms/flow/utils.pyi create mode 100644 stubs/networkx/networkx/algorithms/graph_hashing.pyi create mode 100644 stubs/networkx/networkx/algorithms/graphical.pyi create mode 100644 stubs/networkx/networkx/algorithms/hierarchy.pyi create mode 100644 stubs/networkx/networkx/algorithms/hybrid.pyi create mode 100644 stubs/networkx/networkx/algorithms/isolate.pyi create mode 100644 stubs/networkx/networkx/algorithms/isomorphism/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi create mode 100644 stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi create mode 100644 stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi create mode 100644 stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi create mode 100644 stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi create mode 100644 stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi create mode 100644 stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi create mode 100644 stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi create mode 100644 stubs/networkx/networkx/algorithms/link_analysis/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi create mode 100644 stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi create mode 100644 stubs/networkx/networkx/algorithms/link_prediction.pyi create mode 100644 stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi create mode 100644 stubs/networkx/networkx/algorithms/matching.pyi create mode 100644 stubs/networkx/networkx/algorithms/minors/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/minors/contraction.pyi create mode 100644 stubs/networkx/networkx/algorithms/mis.pyi create mode 100644 stubs/networkx/networkx/algorithms/moral.pyi create mode 100644 stubs/networkx/networkx/algorithms/node_classification.pyi create mode 100644 stubs/networkx/networkx/algorithms/non_randomness.pyi create mode 100644 stubs/networkx/networkx/algorithms/operators/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/operators/all.pyi create mode 100644 stubs/networkx/networkx/algorithms/operators/binary.pyi create mode 100644 stubs/networkx/networkx/algorithms/operators/product.pyi create mode 100644 stubs/networkx/networkx/algorithms/operators/unary.pyi create mode 100644 stubs/networkx/networkx/algorithms/planar_drawing.pyi create mode 100644 stubs/networkx/networkx/algorithms/planarity.pyi create mode 100644 stubs/networkx/networkx/algorithms/polynomials.pyi create mode 100644 stubs/networkx/networkx/algorithms/reciprocity.pyi create mode 100644 stubs/networkx/networkx/algorithms/regular.pyi create mode 100644 stubs/networkx/networkx/algorithms/richclub.pyi create mode 100644 stubs/networkx/networkx/algorithms/shortest_paths/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi create mode 100644 stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi create mode 100644 stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi create mode 100644 stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi create mode 100644 stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi create mode 100644 stubs/networkx/networkx/algorithms/similarity.pyi create mode 100644 stubs/networkx/networkx/algorithms/simple_paths.pyi create mode 100644 stubs/networkx/networkx/algorithms/smallworld.pyi create mode 100644 stubs/networkx/networkx/algorithms/smetric.pyi create mode 100644 stubs/networkx/networkx/algorithms/sparsifiers.pyi create mode 100644 stubs/networkx/networkx/algorithms/structuralholes.pyi create mode 100644 stubs/networkx/networkx/algorithms/summarization.pyi create mode 100644 stubs/networkx/networkx/algorithms/swap.pyi create mode 100644 stubs/networkx/networkx/algorithms/threshold.pyi create mode 100644 stubs/networkx/networkx/algorithms/tournament.pyi create mode 100644 stubs/networkx/networkx/algorithms/traversal/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi create mode 100644 stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi create mode 100644 stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi create mode 100644 stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi create mode 100644 stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi create mode 100644 stubs/networkx/networkx/algorithms/tree/__init__.pyi create mode 100644 stubs/networkx/networkx/algorithms/tree/branchings.pyi create mode 100644 stubs/networkx/networkx/algorithms/tree/coding.pyi create mode 100644 stubs/networkx/networkx/algorithms/tree/decomposition.pyi create mode 100644 stubs/networkx/networkx/algorithms/tree/mst.pyi create mode 100644 stubs/networkx/networkx/algorithms/tree/operations.pyi create mode 100644 stubs/networkx/networkx/algorithms/tree/recognition.pyi create mode 100644 stubs/networkx/networkx/algorithms/triads.pyi create mode 100644 stubs/networkx/networkx/algorithms/vitality.pyi create mode 100644 stubs/networkx/networkx/algorithms/voronoi.pyi create mode 100644 stubs/networkx/networkx/algorithms/wiener.pyi create mode 100644 stubs/networkx/networkx/classes/__init__.pyi create mode 100644 stubs/networkx/networkx/classes/backends.pyi create mode 100644 stubs/networkx/networkx/classes/coreviews.pyi create mode 100644 stubs/networkx/networkx/classes/digraph.pyi create mode 100644 stubs/networkx/networkx/classes/filters.pyi create mode 100644 stubs/networkx/networkx/classes/function.pyi create mode 100644 stubs/networkx/networkx/classes/graph.pyi create mode 100644 stubs/networkx/networkx/classes/graphviews.pyi create mode 100644 stubs/networkx/networkx/classes/multidigraph.pyi create mode 100644 stubs/networkx/networkx/classes/multigraph.pyi create mode 100644 stubs/networkx/networkx/classes/reportviews.pyi create mode 100644 stubs/networkx/networkx/convert.pyi create mode 100644 stubs/networkx/networkx/convert_matrix.pyi create mode 100644 stubs/networkx/networkx/drawing/__init__.pyi create mode 100644 stubs/networkx/networkx/drawing/layout.pyi create mode 100644 stubs/networkx/networkx/drawing/nx_agraph.pyi create mode 100644 stubs/networkx/networkx/drawing/nx_latex.pyi create mode 100644 stubs/networkx/networkx/drawing/nx_pydot.pyi create mode 100644 stubs/networkx/networkx/drawing/nx_pylab.pyi create mode 100644 stubs/networkx/networkx/exception.pyi create mode 100644 stubs/networkx/networkx/generators/__init__.pyi create mode 100644 stubs/networkx/networkx/generators/atlas.pyi create mode 100644 stubs/networkx/networkx/generators/classic.pyi create mode 100644 stubs/networkx/networkx/generators/cographs.pyi create mode 100644 stubs/networkx/networkx/generators/community.pyi create mode 100644 stubs/networkx/networkx/generators/degree_seq.pyi create mode 100644 stubs/networkx/networkx/generators/directed.pyi create mode 100644 stubs/networkx/networkx/generators/duplication.pyi create mode 100644 stubs/networkx/networkx/generators/ego.pyi create mode 100644 stubs/networkx/networkx/generators/expanders.pyi create mode 100644 stubs/networkx/networkx/generators/geometric.pyi create mode 100644 stubs/networkx/networkx/generators/harary_graph.pyi create mode 100644 stubs/networkx/networkx/generators/internet_as_graphs.pyi create mode 100644 stubs/networkx/networkx/generators/intersection.pyi create mode 100644 stubs/networkx/networkx/generators/interval_graph.pyi create mode 100644 stubs/networkx/networkx/generators/joint_degree_seq.pyi create mode 100644 stubs/networkx/networkx/generators/lattice.pyi create mode 100644 stubs/networkx/networkx/generators/line.pyi create mode 100644 stubs/networkx/networkx/generators/mycielski.pyi create mode 100644 stubs/networkx/networkx/generators/nonisomorphic_trees.pyi create mode 100644 stubs/networkx/networkx/generators/random_clustered.pyi create mode 100644 stubs/networkx/networkx/generators/random_graphs.pyi create mode 100644 stubs/networkx/networkx/generators/small.pyi create mode 100644 stubs/networkx/networkx/generators/social.pyi create mode 100644 stubs/networkx/networkx/generators/spectral_graph_forge.pyi create mode 100644 stubs/networkx/networkx/generators/stochastic.pyi create mode 100644 stubs/networkx/networkx/generators/sudoku.pyi create mode 100644 stubs/networkx/networkx/generators/trees.pyi create mode 100644 stubs/networkx/networkx/generators/triads.pyi create mode 100644 stubs/networkx/networkx/lazy_imports.pyi create mode 100644 stubs/networkx/networkx/linalg/__init__.pyi create mode 100644 stubs/networkx/networkx/linalg/algebraicconnectivity.pyi create mode 100644 stubs/networkx/networkx/linalg/attrmatrix.pyi create mode 100644 stubs/networkx/networkx/linalg/bethehessianmatrix.pyi create mode 100644 stubs/networkx/networkx/linalg/graphmatrix.pyi create mode 100644 stubs/networkx/networkx/linalg/laplacianmatrix.pyi create mode 100644 stubs/networkx/networkx/linalg/modularitymatrix.pyi create mode 100644 stubs/networkx/networkx/linalg/spectrum.pyi create mode 100644 stubs/networkx/networkx/readwrite/__init__.pyi create mode 100644 stubs/networkx/networkx/readwrite/adjlist.pyi create mode 100644 stubs/networkx/networkx/readwrite/edgelist.pyi create mode 100644 stubs/networkx/networkx/readwrite/gexf.pyi create mode 100644 stubs/networkx/networkx/readwrite/gml.pyi create mode 100644 stubs/networkx/networkx/readwrite/graph6.pyi create mode 100644 stubs/networkx/networkx/readwrite/graphml.pyi create mode 100644 stubs/networkx/networkx/readwrite/json_graph/__init__.pyi create mode 100644 stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi create mode 100644 stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi create mode 100644 stubs/networkx/networkx/readwrite/json_graph/node_link.pyi create mode 100644 stubs/networkx/networkx/readwrite/json_graph/tree.pyi create mode 100644 stubs/networkx/networkx/readwrite/leda.pyi create mode 100644 stubs/networkx/networkx/readwrite/multiline_adjlist.pyi create mode 100644 stubs/networkx/networkx/readwrite/p2g.pyi create mode 100644 stubs/networkx/networkx/readwrite/pajek.pyi create mode 100644 stubs/networkx/networkx/readwrite/sparse6.pyi create mode 100644 stubs/networkx/networkx/readwrite/text.pyi create mode 100644 stubs/networkx/networkx/relabel.pyi create mode 100644 stubs/networkx/networkx/utils/__init__.pyi create mode 100644 stubs/networkx/networkx/utils/decorators.pyi create mode 100644 stubs/networkx/networkx/utils/heaps.pyi create mode 100644 stubs/networkx/networkx/utils/mapped_queue.pyi create mode 100644 stubs/networkx/networkx/utils/misc.pyi create mode 100644 stubs/networkx/networkx/utils/random_sequence.pyi create mode 100644 stubs/networkx/networkx/utils/rcm.pyi create mode 100644 stubs/networkx/networkx/utils/union_find.pyi diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index e3a3839a003e..8af6e7da9b31 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -49,6 +49,7 @@ "stubs/mysqlclient", "stubs/oauthlib", "stubs/openpyxl", + "stubs/networkx", "stubs/passlib", "stubs/peewee", "stubs/pexpect", diff --git a/stubs/networkx/METADATA.toml b/stubs/networkx/METADATA.toml new file mode 100644 index 000000000000..68aab1119e28 --- /dev/null +++ b/stubs/networkx/METADATA.toml @@ -0,0 +1,4 @@ +version = "3.1" +upstream_repository = "https://github.com/networkx/networkx" +requires = ["pandas-stubs", "numpy"] +partial_stub = true diff --git a/stubs/networkx/networkx/__init__.pyi b/stubs/networkx/networkx/__init__.pyi new file mode 100644 index 000000000000..45fb09dc3bdd --- /dev/null +++ b/stubs/networkx/networkx/__init__.pyi @@ -0,0 +1,23 @@ +from networkx import ( + algorithms as algorithms, + classes as classes, + convert as convert, + convert_matrix as convert_matrix, + drawing as drawing, + generators as generators, + linalg as linalg, + readwrite as readwrite, + relabel as relabel, + utils as utils, +) +from networkx.algorithms import * +from networkx.classes import * +from networkx.classes import filters as filters +from networkx.convert import * +from networkx.convert_matrix import * +from networkx.drawing import * +from networkx.exception import * +from networkx.generators import * +from networkx.linalg import * +from networkx.readwrite import * +from networkx.relabel import * diff --git a/stubs/networkx/networkx/algorithms/__init__.pyi b/stubs/networkx/networkx/algorithms/__init__.pyi new file mode 100644 index 000000000000..8d47145126d6 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/__init__.pyi @@ -0,0 +1,135 @@ +from networkx.algorithms import ( + approximation as approximation, + assortativity as assortativity, + bipartite as bipartite, + centrality as centrality, + chordal as chordal, + clique as clique, + cluster as cluster, + coloring as coloring, + community as community, + components as components, + connectivity as connectivity, + flow as flow, + isomorphism as isomorphism, + link_analysis as link_analysis, + lowest_common_ancestors as lowest_common_ancestors, + node_classification as node_classification, + operators as operators, + shortest_paths as shortest_paths, + tournament as tournament, + traversal as traversal, + tree as tree, +) +from networkx.algorithms.assortativity import * +from networkx.algorithms.asteroidal import * +from networkx.algorithms.bipartite import ( + complete_bipartite_graph as complete_bipartite_graph, + is_bipartite as is_bipartite, + projected_graph as projected_graph, +) +from networkx.algorithms.boundary import * +from networkx.algorithms.bridges import * +from networkx.algorithms.centrality import * +from networkx.algorithms.chains import * +from networkx.algorithms.chordal import * +from networkx.algorithms.clique import * +from networkx.algorithms.cluster import * +from networkx.algorithms.coloring import * +from networkx.algorithms.communicability_alg import * +from networkx.algorithms.components import * +from networkx.algorithms.connectivity import ( + all_node_cuts as all_node_cuts, + all_pairs_node_connectivity as all_pairs_node_connectivity, + average_node_connectivity as average_node_connectivity, + edge_connectivity as edge_connectivity, + edge_disjoint_paths as edge_disjoint_paths, + is_k_edge_connected as is_k_edge_connected, + k_components as k_components, + k_edge_augmentation as k_edge_augmentation, + k_edge_components as k_edge_components, + k_edge_subgraphs as k_edge_subgraphs, + minimum_edge_cut as minimum_edge_cut, + minimum_node_cut as minimum_node_cut, + node_connectivity as node_connectivity, + node_disjoint_paths as node_disjoint_paths, + stoer_wagner as stoer_wagner, +) +from networkx.algorithms.core import * +from networkx.algorithms.covering import * +from networkx.algorithms.cuts import * +from networkx.algorithms.cycles import * +from networkx.algorithms.d_separation import * +from networkx.algorithms.dag import * +from networkx.algorithms.distance_measures import * +from networkx.algorithms.distance_regular import * +from networkx.algorithms.dominance import * +from networkx.algorithms.dominating import * +from networkx.algorithms.efficiency_measures import * +from networkx.algorithms.euler import * +from networkx.algorithms.flow import ( + capacity_scaling as capacity_scaling, + cost_of_flow as cost_of_flow, + gomory_hu_tree as gomory_hu_tree, + max_flow_min_cost as max_flow_min_cost, + maximum_flow as maximum_flow, + maximum_flow_value as maximum_flow_value, + min_cost_flow as min_cost_flow, + min_cost_flow_cost as min_cost_flow_cost, + minimum_cut as minimum_cut, + minimum_cut_value as minimum_cut_value, + network_simplex as network_simplex, +) +from networkx.algorithms.graph_hashing import * +from networkx.algorithms.graphical import * +from networkx.algorithms.hierarchy import * +from networkx.algorithms.hybrid import * +from networkx.algorithms.isolate import * +from networkx.algorithms.isomorphism import ( + could_be_isomorphic as could_be_isomorphic, + fast_could_be_isomorphic as fast_could_be_isomorphic, + faster_could_be_isomorphic as faster_could_be_isomorphic, + is_isomorphic as is_isomorphic, +) +from networkx.algorithms.isomorphism.vf2pp import * +from networkx.algorithms.link_analysis import * +from networkx.algorithms.link_prediction import * +from networkx.algorithms.lowest_common_ancestors import * +from networkx.algorithms.matching import * +from networkx.algorithms.minors import * +from networkx.algorithms.mis import * +from networkx.algorithms.moral import * +from networkx.algorithms.non_randomness import * +from networkx.algorithms.operators import * +from networkx.algorithms.planar_drawing import * +from networkx.algorithms.planarity import * +from networkx.algorithms.polynomials import * +from networkx.algorithms.reciprocity import * +from networkx.algorithms.regular import * +from networkx.algorithms.richclub import * +from networkx.algorithms.shortest_paths import * +from networkx.algorithms.similarity import * +from networkx.algorithms.simple_paths import * +from networkx.algorithms.smallworld import * +from networkx.algorithms.smetric import * +from networkx.algorithms.sparsifiers import * +from networkx.algorithms.structuralholes import * +from networkx.algorithms.summarization import * +from networkx.algorithms.swap import * +from networkx.algorithms.traversal import * +from networkx.algorithms.tree.branchings import ( + ArborescenceIterator as ArborescenceIterator, + maximum_branching as maximum_branching, + maximum_spanning_arborescence as maximum_spanning_arborescence, + minimum_branching as minimum_branching, + minimum_spanning_arborescence as minimum_spanning_arborescence, +) +from networkx.algorithms.tree.coding import * +from networkx.algorithms.tree.decomposition import * +from networkx.algorithms.tree.mst import * +from networkx.algorithms.tree.operations import * +from networkx.algorithms.tree.recognition import * +from networkx.algorithms.triads import * +from networkx.algorithms.vitality import * +from networkx.algorithms.voronoi import * +from networkx.algorithms.wiener import * diff --git a/stubs/networkx/networkx/algorithms/approximation/__init__.pyi b/stubs/networkx/networkx/algorithms/approximation/__init__.pyi new file mode 100644 index 000000000000..b355e7f39cba --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/__init__.pyi @@ -0,0 +1,13 @@ +from networkx.algorithms.approximation.clique import * +from networkx.algorithms.approximation.clustering_coefficient import * +from networkx.algorithms.approximation.connectivity import * +from networkx.algorithms.approximation.distance_measures import * +from networkx.algorithms.approximation.dominating_set import * +from networkx.algorithms.approximation.kcomponents import * +from networkx.algorithms.approximation.matching import * +from networkx.algorithms.approximation.maxcut import * +from networkx.algorithms.approximation.ramsey import * +from networkx.algorithms.approximation.steinertree import * +from networkx.algorithms.approximation.traveling_salesman import * +from networkx.algorithms.approximation.treewidth import * +from networkx.algorithms.approximation.vertex_cover import * diff --git a/stubs/networkx/networkx/algorithms/approximation/clique.pyi b/stubs/networkx/networkx/algorithms/approximation/clique.pyi new file mode 100644 index 000000000000..e917e7c36efc --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/clique.pyi @@ -0,0 +1,4 @@ +def maximum_independent_set(G): ... +def max_clique(G): ... +def clique_removal(G): ... +def large_clique_size(G): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi b/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi new file mode 100644 index 000000000000..6ccdd17f559e --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/clustering_coefficient.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +def average_clustering(G, trials: int = 1000, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi b/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi new file mode 100644 index 000000000000..91edbb44c1d0 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi @@ -0,0 +1,7 @@ +from _typeshed import Incomplete + +def local_node_connectivity(G, source, target, cutoff: Incomplete | None = None): ... +def node_connectivity(G, s: Incomplete | None = None, t: Incomplete | None = None): ... +def all_pairs_node_connectivity( + G, nbunch: Incomplete | None = None, cutoff: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/distance_measures.pyi b/stubs/networkx/networkx/algorithms/approximation/distance_measures.pyi new file mode 100644 index 000000000000..407a169f00a6 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/distance_measures.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +def diameter(G, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi b/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi new file mode 100644 index 000000000000..e1440657122c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi @@ -0,0 +1,4 @@ +from _typeshed import Incomplete + +def min_weighted_dominating_set(G, weight: Incomplete | None = None): ... +def min_edge_dominating_set(G): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi new file mode 100644 index 000000000000..abc93b71315f --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +def k_components(G: Incomplete, min_density: float = ...) -> Incomplete: ... diff --git a/stubs/networkx/networkx/algorithms/approximation/matching.pyi b/stubs/networkx/networkx/algorithms/approximation/matching.pyi new file mode 100644 index 000000000000..018588021789 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/matching.pyi @@ -0,0 +1 @@ +def min_maximal_matching(G): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi b/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi new file mode 100644 index 000000000000..f1286e8d3c31 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi @@ -0,0 +1,11 @@ +from _typeshed import Incomplete + +def randomized_partitioning( + G, seed: Incomplete | None = None, p: float = 0.5, weight: Incomplete | None = None +): ... +def one_exchange( + G, + initial_cut: Incomplete | None = None, + seed: Incomplete | None = None, + weight: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/ramsey.pyi b/stubs/networkx/networkx/algorithms/approximation/ramsey.pyi new file mode 100644 index 000000000000..b0dfc1cf39af --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/ramsey.pyi @@ -0,0 +1 @@ +def ramsey_R2(G): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi b/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi new file mode 100644 index 000000000000..a8ef401f5da1 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete + +def metric_closure(G, weight: str = "weight"): ... +def steiner_tree( + G, terminal_nodes, weight: str = "weight", method: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi new file mode 100644 index 000000000000..3bcb15dc8c27 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi @@ -0,0 +1,41 @@ +from _typeshed import Incomplete + +def christofides(G, weight: str = "weight", tree: Incomplete | None = None): ... +def traveling_salesman_problem( + G, + weight: str = "weight", + nodes: Incomplete | None = None, + cycle: bool = True, + method: Incomplete | None = None, +): ... +def asadpour_atsp( + G, + weight: str = "weight", + seed: Incomplete | None = None, + source: Incomplete | None = None, +): ... +def greedy_tsp(G, weight: str = "weight", source: Incomplete | None = None): ... +def simulated_annealing_tsp( + G, + init_cycle, + weight: str = "weight", + source: Incomplete | None = None, + temp: int = 100, + move: str = "1-1", + max_iterations: int = 10, + N_inner: int = 100, + alpha: float = 0.01, + seed: Incomplete | None = None, +): ... +def threshold_accepting_tsp( + G, + init_cycle, + weight: str = "weight", + source: Incomplete | None = None, + threshold: int = 1, + move: str = "1-1", + max_iterations: int = 10, + N_inner: int = 100, + alpha: float = 0.1, + seed: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi new file mode 100644 index 000000000000..6e6c5ec06923 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi @@ -0,0 +1,9 @@ +from _typeshed import Incomplete + +def treewidth_min_degree(G): ... +def treewidth_min_fill_in(G): ... + +class MinDegreeHeuristic: + count: Incomplete + def __init__(self, graph) -> None: ... + def best_node(self, graph): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi b/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi new file mode 100644 index 000000000000..38560009c88b --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +def min_weighted_vertex_cover(G, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/__init__.pyi b/stubs/networkx/networkx/algorithms/assortativity/__init__.pyi new file mode 100644 index 000000000000..4d9888609cbc --- /dev/null +++ b/stubs/networkx/networkx/algorithms/assortativity/__init__.pyi @@ -0,0 +1,5 @@ +from networkx.algorithms.assortativity.connectivity import * +from networkx.algorithms.assortativity.correlation import * +from networkx.algorithms.assortativity.mixing import * +from networkx.algorithms.assortativity.neighbor_degree import * +from networkx.algorithms.assortativity.pairs import * diff --git a/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi b/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi new file mode 100644 index 000000000000..bdce6a47ab6c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi @@ -0,0 +1,9 @@ +from _typeshed import Incomplete + +def average_degree_connectivity( + G, + source: str = "in+out", + target: str = "in+out", + nodes: Incomplete | None = None, + weight: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi new file mode 100644 index 000000000000..ca33e57deb75 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi @@ -0,0 +1,22 @@ +from _typeshed import Incomplete + +def degree_assortativity_coefficient( + G, + x: str = "out", + y: str = "in", + weight: Incomplete | None = None, + nodes: Incomplete | None = None, +): ... +def degree_pearson_correlation_coefficient( + G, + x: str = "out", + y: str = "in", + weight: Incomplete | None = None, + nodes: Incomplete | None = None, +): ... +def attribute_assortativity_coefficient( + G, attribute, nodes: Incomplete | None = None +): ... +def numeric_assortativity_coefficient( + G, attribute, nodes: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi new file mode 100644 index 000000000000..9fb4388ddba0 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi @@ -0,0 +1,30 @@ +from _typeshed import Incomplete + +def attribute_mixing_dict( + G, attribute, nodes: Incomplete | None = None, normalized: bool = False +): ... +def attribute_mixing_matrix( + G, + attribute, + nodes: Incomplete | None = None, + mapping: Incomplete | None = None, + normalized: bool = True, +): ... +def degree_mixing_dict( + G, + x: str = "out", + y: str = "in", + weight: Incomplete | None = None, + nodes: Incomplete | None = None, + normalized: bool = False, +): ... +def degree_mixing_matrix( + G, + x: str = "out", + y: str = "in", + weight: Incomplete | None = None, + nodes: Incomplete | None = None, + normalized: bool = True, + mapping: Incomplete | None = None, +): ... +def mixing_dict(xy, normalized: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi b/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi new file mode 100644 index 000000000000..ed3cf3e787c3 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi @@ -0,0 +1,9 @@ +from _typeshed import Incomplete + +def average_neighbor_degree( + G, + source: str = "out", + target: str = "out", + nodes: Incomplete | None = None, + weight: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi b/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi new file mode 100644 index 000000000000..cf97e98df58d --- /dev/null +++ b/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi @@ -0,0 +1,13 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def node_attribute_xy( + G, attribute, nodes: Incomplete | None = None +) -> Generator[Incomplete, None, None]: ... +def node_degree_xy( + G, + x: str = "out", + y: str = "in", + weight: Incomplete | None = None, + nodes: Incomplete | None = None, +) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/asteroidal.pyi b/stubs/networkx/networkx/algorithms/asteroidal.pyi new file mode 100644 index 000000000000..01d935ad92ba --- /dev/null +++ b/stubs/networkx/networkx/algorithms/asteroidal.pyi @@ -0,0 +1,2 @@ +def find_asteroidal_triple(G): ... +def is_at_free(G): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/__init__.pyi b/stubs/networkx/networkx/algorithms/bipartite/__init__.pyi new file mode 100644 index 000000000000..1f279a092959 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/__init__.pyi @@ -0,0 +1,11 @@ +from networkx.algorithms.bipartite.basic import * +from networkx.algorithms.bipartite.centrality import * +from networkx.algorithms.bipartite.cluster import * +from networkx.algorithms.bipartite.covering import * +from networkx.algorithms.bipartite.edgelist import * +from networkx.algorithms.bipartite.generators import * +from networkx.algorithms.bipartite.matching import * +from networkx.algorithms.bipartite.matrix import * +from networkx.algorithms.bipartite.projection import * +from networkx.algorithms.bipartite.redundancy import * +from networkx.algorithms.bipartite.spectral import * diff --git a/stubs/networkx/networkx/algorithms/bipartite/basic.pyi b/stubs/networkx/networkx/algorithms/bipartite/basic.pyi new file mode 100644 index 000000000000..6eba8bda5294 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/basic.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete + +def color(G): ... +def is_bipartite(G): ... +def is_bipartite_node_set(G, nodes): ... +def sets(G, top_nodes: Incomplete | None = None): ... +def density(B, nodes): ... +def degrees(B, nodes, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi b/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi new file mode 100644 index 000000000000..ccb668e7974a --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/centrality.pyi @@ -0,0 +1,3 @@ +def degree_centrality(G, nodes): ... +def betweenness_centrality(G, nodes): ... +def closeness_centrality(G, nodes, normalized: bool = True): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi b/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi new file mode 100644 index 000000000000..eb4427f502fd --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/cluster.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete + +def latapy_clustering(G, nodes: Incomplete | None = None, mode: str = "dot"): ... + +clustering = latapy_clustering + +def average_clustering(G, nodes: Incomplete | None = None, mode: str = "dot"): ... +def robins_alexander_clustering(G): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/covering.pyi b/stubs/networkx/networkx/algorithms/bipartite/covering.pyi new file mode 100644 index 000000000000..a27c5abfd712 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/covering.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +def min_edge_cover(G, matching_algorithm: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi b/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi new file mode 100644 index 000000000000..a36e756a3418 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi @@ -0,0 +1,32 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def write_edgelist( + G, + path, + comments: str = "#", + delimiter: str = " ", + data: bool = True, + encoding: str = "utf-8", +) -> None: ... +def generate_edgelist( + G, delimiter: str = " ", data: bool = True +) -> Generator[Incomplete, None, None]: ... +def parse_edgelist( + lines, + comments: str = "#", + delimiter: Incomplete | None = None, + create_using: Incomplete | None = None, + nodetype: Incomplete | None = None, + data: bool = True, +): ... +def read_edgelist( + path, + comments: str = "#", + delimiter: Incomplete | None = None, + create_using: Incomplete | None = None, + nodetype: Incomplete | None = None, + data: bool = True, + edgetype: Incomplete | None = None, + encoding: str = "utf-8", +): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/generators.pyi b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi new file mode 100644 index 000000000000..908f29d0c687 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi @@ -0,0 +1,18 @@ +from _typeshed import Incomplete + +def complete_bipartite_graph(n1, n2, create_using: Incomplete | None = None): ... +def configuration_model( + aseq, bseq, create_using: Incomplete | None = None, seed: Incomplete | None = None +): ... +def havel_hakimi_graph(aseq, bseq, create_using: Incomplete | None = None): ... +def reverse_havel_hakimi_graph(aseq, bseq, create_using: Incomplete | None = None): ... +def alternating_havel_hakimi_graph( + aseq, bseq, create_using: Incomplete | None = None +): ... +def preferential_attachment_graph( + aseq, p, create_using: Incomplete | None = None, seed: Incomplete | None = None +): ... +def random_graph(n, m, p, seed: Incomplete | None = None, directed: bool = False): ... +def gnmk_random_graph( + n, m, k, seed: Incomplete | None = None, directed: bool = False +): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi new file mode 100644 index 000000000000..106a7dad08d3 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi @@ -0,0 +1,11 @@ +from _typeshed import Incomplete + +def hopcroft_karp_matching(G, top_nodes: Incomplete | None = None): ... +def eppstein_matching(G, top_nodes: Incomplete | None = None): ... +def to_vertex_cover(G, matching, top_nodes: Incomplete | None = None): ... + +maximum_matching = hopcroft_karp_matching + +def minimum_weight_full_matching( + G, top_nodes: Incomplete | None = None, weight: str = "weight" +): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi new file mode 100644 index 000000000000..2230cc6b182b --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi @@ -0,0 +1,13 @@ +from _typeshed import Incomplete + +def biadjacency_matrix( + G, + row_order, + column_order: Incomplete | None = None, + dtype: Incomplete | None = None, + weight: str = "weight", + format: str = "csr", +): ... +def from_biadjacency_matrix( + A, create_using: Incomplete | None = None, edge_attribute: str = "weight" +): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/projection.pyi b/stubs/networkx/networkx/algorithms/bipartite/projection.pyi new file mode 100644 index 000000000000..32c60753b0e6 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/projection.pyi @@ -0,0 +1,9 @@ +from _typeshed import Incomplete + +def projected_graph(B, nodes, multigraph: bool = False): ... +def weighted_projected_graph(B, nodes, ratio: bool = False): ... +def collaboration_weighted_projected_graph(B, nodes): ... +def overlap_weighted_projected_graph(B, nodes, jaccard: bool = True): ... +def generic_weighted_projected_graph( + B, nodes, weight_function: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi b/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi new file mode 100644 index 000000000000..43d54ecb1776 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/redundancy.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +def node_redundancy(G, nodes: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi b/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi new file mode 100644 index 000000000000..9530b35c8906 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def spectral_bipartivity( + G, nodes: Incomplete | None = None, weight: str = "weight" +): ... diff --git a/stubs/networkx/networkx/algorithms/boundary.pyi b/stubs/networkx/networkx/algorithms/boundary.pyi new file mode 100644 index 000000000000..f5353289a06f --- /dev/null +++ b/stubs/networkx/networkx/algorithms/boundary.pyi @@ -0,0 +1,67 @@ +from collections.abc import Iterable +from typing import TypeVar, overload +from _typeshed import Incomplete + +from networkx.classes.graph import Graph +from typing_extensions import Literal + +_T = TypeVar("_T") +_U = TypeVar("_U") + +@overload +def edge_boundary( + G: Graph[_T], + nbunch1: Iterable[_T], + nbunch2: Iterable[_T] | None = ..., + data: Literal[False] = ..., + keys: Literal[False] = ..., + default: Incomplete = ..., +) -> Iterable[tuple[_T, _T]]: ... +@overload +def edge_boundary( + G: Graph[_T], + nbunch1: Iterable[_T], + nbunch2: Iterable[_T] | None = ..., + data: Literal[True] = ..., + keys: Literal[False] = ..., + default: Incomplete = ..., +) -> Iterable[tuple[_T, _T, dict[str, Incomplete]]]: ... +@overload +def edge_boundary( + G: Graph[_T], + nbunch1: Iterable[_T], + nbunch2: Iterable[_T] | None = ..., + data: str = ..., + keys: Literal[False] = ..., + default: _U | None = None, +) -> Iterable[tuple[_T, _T, dict[str, _U]]]: ... +@overload +def edge_boundary( + G: Graph[_T], + nbunch1: Iterable[_T], + nbunch2: Iterable[_T] | None = ..., + data: Literal[False] = ..., + keys: Literal[True] = ..., + default: Incomplete = ..., +) -> Iterable[tuple[_T, _T, int]]: ... +@overload +def edge_boundary( + G: Graph[_T], + nbunch1: Iterable[_T], + nbunch2: Iterable[_T] | None = ..., + data: Literal[True] = ..., + keys: Literal[True] = ..., + default: Incomplete = ..., +) -> Iterable[tuple[_T, _T, int, dict[str, Incomplete]]]: ... +@overload +def edge_boundary( + G: Graph[_T], + nbunch1: Iterable[_T], + nbunch2: Iterable[_T] | None = ..., + data: str = ..., + keys: Literal[True] = ..., + default: _U | None = None, +) -> Iterable[tuple[_T, _T, int, dict[str, _U]]]: ... +def node_boundary( + G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None = ... +) -> Iterable[_T]: ... diff --git a/stubs/networkx/networkx/algorithms/bridges.pyi b/stubs/networkx/networkx/algorithms/bridges.pyi new file mode 100644 index 000000000000..d51877395c36 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bridges.pyi @@ -0,0 +1,21 @@ +from collections.abc import Callable, Iterable +from typing import overload +from _typeshed import Incomplete + +from networkx.classes.graph import Graph, _Node +from typing_extensions import Literal + +def bridges(G: Graph[_Node], root: _Node | None = ...) -> Iterable[_Node]: ... +def has_bridges(G: Graph[_Node], root: Incomplete | None = ...) -> bool: ... +@overload +def local_bridges( + G: Graph[_Node], + with_span: Literal[False] = ..., + weight: str | Callable[[_Node], float] | None = ..., +) -> Iterable[tuple[_Node, _Node]]: ... +@overload +def local_bridges( + G: Graph[_Node], + with_span: Literal[True] = ..., + weight: str | Callable[[_Node], float] | None = ..., +) -> Iterable[tuple[_Node, _Node, int]]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/__init__.pyi b/stubs/networkx/networkx/algorithms/centrality/__init__.pyi new file mode 100644 index 000000000000..4a8ceb436a4b --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/__init__.pyi @@ -0,0 +1,20 @@ +from .betweenness import * +from .betweenness_subset import * +from .closeness import * +from .current_flow_betweenness import * +from .current_flow_betweenness_subset import * +from .current_flow_closeness import * +from .degree_alg import * +from .dispersion import * +from .eigenvector import * +from .group import * +from .harmonic import * +from .katz import * +from .laplacian import * +from .load import * +from .percolation import * +from .reaching import * +from .second_order import * +from .subgraph_alg import * +from .trophic import * +from .voterank_alg import * diff --git a/stubs/networkx/networkx/algorithms/centrality/betweenness.pyi b/stubs/networkx/networkx/algorithms/centrality/betweenness.pyi new file mode 100644 index 000000000000..9b54c2c919bc --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/betweenness.pyi @@ -0,0 +1,17 @@ +from _typeshed import Incomplete + +def betweenness_centrality( + G, + k: Incomplete | None = None, + normalized: bool = True, + weight: Incomplete | None = None, + endpoints: bool = False, + seed: Incomplete | None = None, +): ... +def edge_betweenness_centrality( + G, + k: Incomplete | None = None, + normalized: bool = True, + weight: Incomplete | None = None, + seed: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi b/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi new file mode 100644 index 000000000000..572d3ae30f05 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete + +def betweenness_centrality_subset( + G, sources, targets, normalized: bool = False, weight: Incomplete | None = None +): ... +def edge_betweenness_centrality_subset( + G, sources, targets, normalized: bool = False, weight: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi new file mode 100644 index 000000000000..74f15d68e839 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi @@ -0,0 +1,15 @@ +from _typeshed import Incomplete + +def closeness_centrality( + G, + u: Incomplete | None = None, + distance: Incomplete | None = None, + wf_improved: bool = True, +): ... +def incremental_closeness_centrality( + G, + edge, + prev_cc: Incomplete | None = None, + insertion: bool = True, + wf_improved: bool = True, +): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi new file mode 100644 index 000000000000..1916671ee620 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi @@ -0,0 +1,26 @@ +from _typeshed import Incomplete + +def approximate_current_flow_betweenness_centrality( + G, + normalized: bool = True, + weight: Incomplete | None = None, + dtype=..., + solver: str = "full", + epsilon: float = 0.5, + kmax: int = 10000, + seed: Incomplete | None = None, +): ... +def current_flow_betweenness_centrality( + G, + normalized: bool = True, + weight: Incomplete | None = None, + dtype=..., + solver: str = "full", +): ... +def edge_current_flow_betweenness_centrality( + G, + normalized: bool = True, + weight: Incomplete | None = None, + dtype=..., + solver: str = "full", +): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi new file mode 100644 index 000000000000..99ba44469748 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi @@ -0,0 +1,20 @@ +from _typeshed import Incomplete + +def current_flow_betweenness_centrality_subset( + G, + sources, + targets, + normalized: bool = True, + weight: Incomplete | None = None, + dtype=..., + solver: str = "lu", +): ... +def edge_current_flow_betweenness_centrality_subset( + G, + sources, + targets, + normalized: bool = True, + weight: Incomplete | None = None, + dtype=..., + solver: str = "lu", +): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi b/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi new file mode 100644 index 000000000000..361d1f04d03c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi @@ -0,0 +1,7 @@ +from _typeshed import Incomplete + +def current_flow_closeness_centrality( + G, weight: Incomplete | None = None, dtype=..., solver: str = "lu" +): ... + +information_centrality = current_flow_closeness_centrality diff --git a/stubs/networkx/networkx/algorithms/centrality/degree_alg.pyi b/stubs/networkx/networkx/algorithms/centrality/degree_alg.pyi new file mode 100644 index 000000000000..72f9f9bd605f --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/degree_alg.pyi @@ -0,0 +1,3 @@ +def degree_centrality(G): ... +def in_degree_centrality(G): ... +def out_degree_centrality(G): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/dispersion.pyi b/stubs/networkx/networkx/algorithms/centrality/dispersion.pyi new file mode 100644 index 000000000000..8b19af6fe2f1 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/dispersion.pyi @@ -0,0 +1,11 @@ +from _typeshed import Incomplete + +def dispersion( + G, + u: Incomplete | None = None, + v: Incomplete | None = None, + normalized: bool = True, + alpha: float = 1.0, + b: float = 0.0, + c: float = 0.0, +): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi new file mode 100644 index 000000000000..8af16a02dd72 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi @@ -0,0 +1,12 @@ +from _typeshed import Incomplete + +def eigenvector_centrality( + G, + max_iter: int = 100, + tol: float = 1e-06, + nstart: Incomplete | None = None, + weight: Incomplete | None = None, +): ... +def eigenvector_centrality_numpy( + G, weight: Incomplete | None = None, max_iter: int = 50, tol: int = 0 +): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi b/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi new file mode 100644 index 000000000000..fafcb009111f --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi @@ -0,0 +1,40 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def flow_matrix_row( + G, weight: Incomplete | None = None, dtype=..., solver: str = "lu" +) -> Generator[Incomplete, None, None]: ... + +class InverseLaplacian: + dtype: Incomplete + n: Incomplete + w: Incomplete + C: Incomplete + L1: Incomplete + def __init__( + self, L, width: Incomplete | None = None, dtype: Incomplete | None = None + ) -> None: ... + def init_solver(self, L) -> None: ... + def solve(self, r) -> None: ... + def solve_inverse(self, r) -> None: ... + def get_rows(self, r1, r2): ... + def get_row(self, r): ... + def width(self, L): ... + +class FullInverseLaplacian(InverseLaplacian): + IL: Incomplete + def init_solver(self, L) -> None: ... + def solve(self, rhs): ... + def solve_inverse(self, r): ... + +class SuperLUInverseLaplacian(InverseLaplacian): + lusolve: Incomplete + def init_solver(self, L) -> None: ... + def solve_inverse(self, r): ... + def solve(self, rhs): ... + +class CGInverseLaplacian(InverseLaplacian): + M: Incomplete + def init_solver(self, L) -> None: ... + def solve(self, rhs): ... + def solve_inverse(self, r): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/group.pyi b/stubs/networkx/networkx/algorithms/centrality/group.pyi new file mode 100644 index 000000000000..968b397d0295 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/group.pyi @@ -0,0 +1,22 @@ +from _typeshed import Incomplete + +def group_betweenness_centrality( + G, + C, + normalized: bool = True, + weight: Incomplete | None = None, + endpoints: bool = False, +): ... +def prominent_group( + G, + k, + weight: Incomplete | None = None, + C: Incomplete | None = None, + endpoints: bool = False, + normalized: bool = True, + greedy: bool = False, +): ... +def group_closeness_centrality(G, S, weight: Incomplete | None = None): ... +def group_degree_centrality(G, S): ... +def group_in_degree_centrality(G, S): ... +def group_out_degree_centrality(G, S): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi b/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi new file mode 100644 index 000000000000..bc975c6e7fba --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete + +def harmonic_centrality( + G, + nbunch: Incomplete | None = None, + distance: Incomplete | None = None, + sources: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/katz.pyi b/stubs/networkx/networkx/algorithms/centrality/katz.pyi new file mode 100644 index 000000000000..b9264e9d108b --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/katz.pyi @@ -0,0 +1,19 @@ +from _typeshed import Incomplete + +def katz_centrality( + G, + alpha: float = 0.1, + beta: float = 1.0, + max_iter: int = 1000, + tol: float = 1e-06, + nstart: Incomplete | None = None, + normalized: bool = True, + weight: Incomplete | None = None, +): ... +def katz_centrality_numpy( + G, + alpha: float = 0.1, + beta: float = 1.0, + normalized: bool = True, + weight: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi b/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi new file mode 100644 index 000000000000..3095884c768f --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi @@ -0,0 +1,10 @@ +from _typeshed import Incomplete + +def laplacian_centrality( + G, + normalized: bool = True, + nodelist: Incomplete | None = None, + weight: str = "weight", + walk_type: Incomplete | None = None, + alpha: float = 0.95, +): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/load.pyi b/stubs/networkx/networkx/algorithms/centrality/load.pyi new file mode 100644 index 000000000000..f02830e63e6a --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/load.pyi @@ -0,0 +1,10 @@ +from _typeshed import Incomplete + +def newman_betweenness_centrality( + G, + v: Incomplete | None = None, + cutoff: Incomplete | None = None, + normalized: bool = True, + weight: Incomplete | None = None, +): ... +def edge_load_centrality(G, cutoff: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/percolation.pyi b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi new file mode 100644 index 000000000000..80291b3b8718 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete + +def percolation_centrality( + G, + attribute: str = "percolation", + states: Incomplete | None = None, + weight: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/reaching.pyi b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi new file mode 100644 index 000000000000..2f1529d975ec --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi @@ -0,0 +1,12 @@ +from _typeshed import Incomplete + +def global_reaching_centrality( + G, weight: Incomplete | None = None, normalized: bool = True +): ... +def local_reaching_centrality( + G, + v, + paths: Incomplete | None = None, + weight: Incomplete | None = None, + normalized: bool = True, +): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/second_order.pyi b/stubs/networkx/networkx/algorithms/centrality/second_order.pyi new file mode 100644 index 000000000000..6197d1011dd6 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/second_order.pyi @@ -0,0 +1 @@ +def second_order_centrality(G): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi b/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi new file mode 100644 index 000000000000..30282362599c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/subgraph_alg.pyi @@ -0,0 +1,4 @@ +def subgraph_centrality_exp(G): ... +def subgraph_centrality(G): ... +def communicability_betweenness_centrality(G): ... +def estrada_index(G): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/trophic.pyi b/stubs/networkx/networkx/algorithms/centrality/trophic.pyi new file mode 100644 index 000000000000..d0861ad4aa00 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/trophic.pyi @@ -0,0 +1,5 @@ +def trophic_levels(G, weight: str = "weight"): ... +def trophic_differences(G, weight: str = "weight"): ... +def trophic_incoherence_parameter( + G, weight: str = "weight", cannibalism: bool = False +): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi b/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi new file mode 100644 index 000000000000..f8d829fa00d4 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/voterank_alg.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +def voterank(G, number_of_nodes: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/chains.pyi b/stubs/networkx/networkx/algorithms/chains.pyi new file mode 100644 index 000000000000..e9e77253101e --- /dev/null +++ b/stubs/networkx/networkx/algorithms/chains.pyi @@ -0,0 +1,7 @@ +from collections.abc import Iterable + +from networkx.classes.graph import Graph, _Node + +def chain_decomposition( + G: Graph[_Node], root: _Node | None = ... +) -> Iterable[tuple[_Node, _Node]]: ... diff --git a/stubs/networkx/networkx/algorithms/chordal.pyi b/stubs/networkx/networkx/algorithms/chordal.pyi new file mode 100644 index 000000000000..4150405e6918 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/chordal.pyi @@ -0,0 +1,14 @@ +from collections.abc import Iterable +from typing import Any + +import networkx as nx +from networkx.classes.graph import Graph, _Node + +class NetworkXTreewidthBoundExceeded(nx.NetworkXException): ... + +def is_chordal(G: Graph[Any]) -> bool: ... +def find_induced_nodes( + G: Graph[_Node], s: _Node, t: _Node, treewidth_bound: int = ... +) -> set[_Node]: ... +def chordal_graph_cliques(G: Graph[_Node]) -> Iterable[frozenset[_Node]]: ... +def chordal_graph_treewidth(G: Graph[Any]) -> int: ... diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi new file mode 100644 index 000000000000..97c816cd7b04 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -0,0 +1,39 @@ +from collections.abc import Iterable + +from networkx.classes.graph import Graph, _Node + +def enumerate_all_cliques(G: Graph[_Node]) -> Iterable[list[_Node]]: ... +def find_cliques( + G: Graph[_Node], nodes: list[_Node] | None = ... +) -> Iterable[list[_Node]]: ... +def find_cliques_recursive( + G: Graph[_Node], nodes: list[_Node] | None = ... +) -> Iterable[list[_Node]]: ... +def make_max_clique_graph( + G: Graph[_Node], create_using: type[Graph[_Node]] = ... +) -> Graph[_Node]: ... +def make_clique_bipartite( + G: Graph[_Node], + fpos: None = ..., + create_using: type[Graph[_Node]] = ..., + name: None = ..., +) -> Graph[_Node]: ... +def graph_clique_number(G: Graph[_Node], cliques: list[_Node] | None = ...) -> int: ... +def graph_number_of_cliques( + G: Graph[_Node], cliques: list[_Node] | None = ... +) -> int: ... +def node_clique_number( + G: Graph[_Node], + nodes: list[_Node] | None = ..., + cliques: list[list[_Node]] | None = ..., +) -> int: ... +def number_of_cliques( + G: Graph[_Node], + nodes: list[_Node] | None = ..., + cliques: list[list[_Node]] | None = ..., +) -> int: ... +def cliques_containing_node( + G: Graph[_Node], + nodes: list[_Node] | None = ..., + cliques: list[list[_Node]] | None = ..., +) -> Iterable[list[_Node]]: ... diff --git a/stubs/networkx/networkx/algorithms/cluster.pyi b/stubs/networkx/networkx/algorithms/cluster.pyi new file mode 100644 index 000000000000..c654c7df51e6 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/cluster.pyi @@ -0,0 +1,15 @@ +from _typeshed import Incomplete + +def triangles(G, nodes: Incomplete | None = None): ... +def average_clustering( + G, + nodes: Incomplete | None = None, + weight: Incomplete | None = None, + count_zeros: bool = True, +): ... +def clustering( + G, nodes: Incomplete | None = None, weight: Incomplete | None = None +): ... +def transitivity(G): ... +def square_clustering(G, nodes: Incomplete | None = None): ... +def generalized_degree(G, nodes: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/coloring/__init__.pyi b/stubs/networkx/networkx/algorithms/coloring/__init__.pyi new file mode 100644 index 000000000000..b6522e602914 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/coloring/__init__.pyi @@ -0,0 +1,7 @@ +from networkx.algorithms.coloring.equitable_coloring import ( + equitable_color as equitable_color, +) +from networkx.algorithms.coloring.greedy_coloring import * + +# Names in __all__ with no definition: +# greedy_color diff --git a/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi b/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi new file mode 100644 index 000000000000..d5a2ebe18f75 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/coloring/equitable_coloring.pyi @@ -0,0 +1 @@ +def equitable_color(G, num_colors): ... diff --git a/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi b/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi new file mode 100644 index 000000000000..5aed270b2ff7 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi @@ -0,0 +1,35 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def strategy_largest_first(G, colors): ... +def strategy_random_sequential(G, colors, seed: Incomplete | None = None): ... +def strategy_smallest_last(G, colors): ... +def strategy_independent_set(G, colors) -> Generator[Incomplete, Incomplete, None]: ... +def strategy_connected_sequential_bfs(G, colors): ... +def strategy_connected_sequential_dfs(G, colors): ... +def strategy_connected_sequential( + G, colors, traversal: str = "bfs" +) -> Generator[Incomplete, None, None]: ... +def strategy_saturation_largest_first( + G, colors +) -> Generator[Incomplete, None, Incomplete]: ... +def greedy_color(G, strategy: str = "largest_first", interchange: bool = False): ... + +class _Node: + node_id: Incomplete + color: int + adj_list: Incomplete + adj_color: Incomplete + def __init__(self, node_id, n) -> None: ... + def assign_color(self, adj_entry, color) -> None: ... + def clear_color(self, adj_entry, color) -> None: ... + def iter_neighbors(self) -> Generator[Incomplete, None, None]: ... + def iter_neighbors_color(self, color) -> Generator[Incomplete, None, None]: ... + +class _AdjEntry: + node_id: Incomplete + next: Incomplete + mate: Incomplete + col_next: Incomplete + col_prev: Incomplete + def __init__(self, node_id) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/communicability_alg.pyi b/stubs/networkx/networkx/algorithms/communicability_alg.pyi new file mode 100644 index 000000000000..df90b4c6fc44 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/communicability_alg.pyi @@ -0,0 +1,2 @@ +def communicability(G): ... +def communicability_exp(G): ... diff --git a/stubs/networkx/networkx/algorithms/community/__init__.pyi b/stubs/networkx/networkx/algorithms/community/__init__.pyi new file mode 100644 index 000000000000..88597e70592d --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/__init__.pyi @@ -0,0 +1,10 @@ +from networkx.algorithms.community.asyn_fluid import * +from networkx.algorithms.community.centrality import * +from networkx.algorithms.community.community_utils import * +from networkx.algorithms.community.kclique import * +from networkx.algorithms.community.kernighan_lin import * +from networkx.algorithms.community.label_propagation import * +from networkx.algorithms.community.louvain import * +from networkx.algorithms.community.lukes import * +from networkx.algorithms.community.modularity_max import * +from networkx.algorithms.community.quality import * diff --git a/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi b/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi new file mode 100644 index 000000000000..842f7c01152a --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/asyn_fluid.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +def asyn_fluidc(G, k, max_iter: int = 100, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/community/centrality.pyi b/stubs/networkx/networkx/algorithms/community/centrality.pyi new file mode 100644 index 000000000000..afee1196cba1 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/centrality.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def girvan_newman( + G, most_valuable_edge: Incomplete | None = None +) -> Generator[Incomplete, None, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/community/community_utils.pyi b/stubs/networkx/networkx/algorithms/community/community_utils.pyi new file mode 100644 index 000000000000..aa5517b41e30 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/community_utils.pyi @@ -0,0 +1 @@ +def is_partition(G, communities): ... diff --git a/stubs/networkx/networkx/algorithms/community/kclique.pyi b/stubs/networkx/networkx/algorithms/community/kclique.pyi new file mode 100644 index 000000000000..31489f8ed3a5 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/kclique.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def k_clique_communities( + G, k, cliques: Incomplete | None = None +) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi b/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi new file mode 100644 index 000000000000..c006baf208cc --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi @@ -0,0 +1,9 @@ +from _typeshed import Incomplete + +def kernighan_lin_bisection( + G, + partition: Incomplete | None = None, + max_iter: int = 10, + weight: str = "weight", + seed: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/community/label_propagation.pyi b/stubs/networkx/networkx/algorithms/community/label_propagation.pyi new file mode 100644 index 000000000000..af023350ec75 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/label_propagation.pyi @@ -0,0 +1,7 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def asyn_lpa_communities( + G, weight: Incomplete | None = None, seed: Incomplete | None = None +) -> Generator[Incomplete, Incomplete, None]: ... +def label_propagation_communities(G): ... diff --git a/stubs/networkx/networkx/algorithms/community/louvain.pyi b/stubs/networkx/networkx/algorithms/community/louvain.pyi new file mode 100644 index 000000000000..2f66d1206144 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/louvain.pyi @@ -0,0 +1,17 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def louvain_communities( + G, + weight: str = "weight", + resolution: int = 1, + threshold: float = 1e-07, + seed: Incomplete | None = None, +): ... +def louvain_partitions( + G, + weight: str = "weight", + resolution: int = 1, + threshold: float = 1e-07, + seed: Incomplete | None = None, +) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/community/lukes.pyi b/stubs/networkx/networkx/algorithms/community/lukes.pyi new file mode 100644 index 000000000000..c04b3b6e25c9 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/lukes.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete + +def lukes_partitioning( + G, + max_size, + node_weight: Incomplete | None = None, + edge_weight: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/community/modularity_max.pyi b/stubs/networkx/networkx/algorithms/community/modularity_max.pyi new file mode 100644 index 000000000000..efe754946bea --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/modularity_max.pyi @@ -0,0 +1,12 @@ +from _typeshed import Incomplete + +def greedy_modularity_communities( + G, + weight: Incomplete | None = None, + resolution: int = 1, + cutoff: int = 1, + best_n: Incomplete | None = None, +): ... +def naive_greedy_modularity_communities( + G, resolution: int = 1, weight: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/community/quality.pyi b/stubs/networkx/networkx/algorithms/community/quality.pyi new file mode 100644 index 000000000000..d9717783f178 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/quality.pyi @@ -0,0 +1,7 @@ +from networkx import NetworkXError + +class NotAPartition(NetworkXError): + def __init__(self, G, collection) -> None: ... + +def modularity(G, communities, weight: str = "weight", resolution: int = 1): ... +def partition_quality(G, partition): ... diff --git a/stubs/networkx/networkx/algorithms/components/__init__.pyi b/stubs/networkx/networkx/algorithms/components/__init__.pyi new file mode 100644 index 000000000000..1aee3fd63206 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/components/__init__.pyi @@ -0,0 +1,6 @@ +from .attracting import * +from .biconnected import * +from .connected import * +from .semiconnected import * +from .strongly_connected import * +from .weakly_connected import * diff --git a/stubs/networkx/networkx/algorithms/components/attracting.pyi b/stubs/networkx/networkx/algorithms/components/attracting.pyi new file mode 100644 index 000000000000..a954808ed8c6 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/components/attracting.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def attracting_components(G) -> Generator[Incomplete, None, None]: ... +def number_attracting_components(G): ... +def is_attracting_component(G): ... diff --git a/stubs/networkx/networkx/algorithms/components/biconnected.pyi b/stubs/networkx/networkx/algorithms/components/biconnected.pyi new file mode 100644 index 000000000000..384dbe18db01 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/components/biconnected.pyi @@ -0,0 +1,7 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def is_biconnected(G): ... +def biconnected_component_edges(G) -> Generator[Incomplete, Incomplete, None]: ... +def biconnected_components(G) -> Generator[Incomplete, None, None]: ... +def articulation_points(G) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/components/connected.pyi b/stubs/networkx/networkx/algorithms/components/connected.pyi new file mode 100644 index 000000000000..4ba209106d71 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/components/connected.pyi @@ -0,0 +1,7 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def connected_components(G) -> Generator[Incomplete, None, None]: ... +def number_connected_components(G): ... +def is_connected(G): ... +def node_connected_component(G, n): ... diff --git a/stubs/networkx/networkx/algorithms/components/semiconnected.pyi b/stubs/networkx/networkx/algorithms/components/semiconnected.pyi new file mode 100644 index 000000000000..10bf78a9da81 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/components/semiconnected.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +def is_semiconnected(G, topo_order: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi new file mode 100644 index 000000000000..90bef6de3585 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi @@ -0,0 +1,18 @@ +from collections.abc import Iterable +from typing import Any, TypeVar + +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import Graph + +_N = TypeVar("_N") + +def strongly_connected_components(G: Graph[_N]) -> Iterable[set[_N]]: ... +def kosaraju_strongly_connected_components( + G: Graph[_N], source: _N | None = ... +) -> Iterable[set[_N]]: ... +def strongly_connected_components_recursive(G: Graph[_N]) -> Iterable[set[_N]]: ... +def number_strongly_connected_components(G: Graph[Any]) -> int: ... +def is_strongly_connected(G: Graph[Any]) -> bool: ... +def condensation( + G: DiGraph[_N], scc: Iterable[set[_N]] | None = ... +) -> DiGraph[int]: ... diff --git a/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi b/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi new file mode 100644 index 000000000000..cd851dc9bb5b --- /dev/null +++ b/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi @@ -0,0 +1,10 @@ +from collections.abc import Iterable +from typing import Any, TypeVar + +from networkx.classes.graph import Graph + +_N = TypeVar("_N") + +def weakly_connected_components(G: Graph[_N]) -> Iterable[set[_N]]: ... +def number_weakly_connected_components(G: Graph[Any]) -> int: ... +def is_weakly_connected(G: Graph[Any]) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/__init__.pyi b/stubs/networkx/networkx/algorithms/connectivity/__init__.pyi new file mode 100644 index 000000000000..4c218403f17d --- /dev/null +++ b/stubs/networkx/networkx/algorithms/connectivity/__init__.pyi @@ -0,0 +1,9 @@ +from .connectivity import * +from .cuts import * +from .edge_augmentation import * +from .edge_kcomponents import * +from .disjoint_paths import * +from .kcomponents import * +from .kcutsets import * +from .stoerwagner import * +from .utils import * diff --git a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi new file mode 100644 index 000000000000..65e22e5b10b3 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi @@ -0,0 +1,41 @@ +from _typeshed import Incomplete + +from networkx.algorithms.flow import edmonds_karp + +default_flow_func = edmonds_karp + +def local_node_connectivity( + G, + s, + t, + flow_func: Incomplete | None = None, + auxiliary: Incomplete | None = None, + residual: Incomplete | None = None, + cutoff: Incomplete | None = None, +): ... +def node_connectivity( + G, + s: Incomplete | None = None, + t: Incomplete | None = None, + flow_func: Incomplete | None = None, +): ... +def average_node_connectivity(G, flow_func: Incomplete | None = None): ... +def all_pairs_node_connectivity( + G, nbunch: Incomplete | None = None, flow_func: Incomplete | None = None +): ... +def local_edge_connectivity( + G, + s, + t, + flow_func: Incomplete | None = None, + auxiliary: Incomplete | None = None, + residual: Incomplete | None = None, + cutoff: Incomplete | None = None, +): ... +def edge_connectivity( + G, + s: Incomplete | None = None, + t: Incomplete | None = None, + flow_func: Incomplete | None = None, + cutoff: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi new file mode 100644 index 000000000000..fe046e89cbd0 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi @@ -0,0 +1,34 @@ +from _typeshed import Incomplete + +from networkx.algorithms.flow import edmonds_karp + +default_flow_func = edmonds_karp + +def minimum_st_edge_cut( + G, + s, + t, + flow_func: Incomplete | None = None, + auxiliary: Incomplete | None = None, + residual: Incomplete | None = None, +): ... +def minimum_st_node_cut( + G, + s, + t, + flow_func: Incomplete | None = None, + auxiliary: Incomplete | None = None, + residual: Incomplete | None = None, +): ... +def minimum_node_cut( + G, + s: Incomplete | None = None, + t: Incomplete | None = None, + flow_func: Incomplete | None = None, +): ... +def minimum_edge_cut( + G, + s: Incomplete | None = None, + t: Incomplete | None = None, + flow_func: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi b/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi new file mode 100644 index 000000000000..a6f68190e634 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi @@ -0,0 +1,25 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from networkx.algorithms.flow import edmonds_karp + +default_flow_func = edmonds_karp + +def edge_disjoint_paths( + G, + s, + t, + flow_func: Incomplete | None = None, + cutoff: Incomplete | None = None, + auxiliary: Incomplete | None = None, + residual: Incomplete | None = None, +) -> Generator[Incomplete, None, None]: ... +def node_disjoint_paths( + G, + s, + t, + flow_func: Incomplete | None = None, + cutoff: Incomplete | None = None, + auxiliary: Incomplete | None = None, + residual: Incomplete | None = None, +) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi new file mode 100644 index 000000000000..aa14bdbbce99 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -0,0 +1,19 @@ +from collections.abc import Iterable +from typing import Any, TypeVar + +from _typeshed import Incomplete +from networkx.classes.graph import Graph + +_N = TypeVar("_N") + +def is_k_edge_connected(G: Graph[Any], k: int) -> Incomplete: ... +def is_locally_k_edge_connected( + G: Incomplete, s: Incomplete, t: Incomplete, k: Incomplete +) -> Incomplete: ... +def k_edge_augmentation( + G: Graph[_N], + k: int, + avail: tuple[_N, _N] | tuple[_N, _N, dict[str, int]] | None = ..., + weight: str | None = ..., + partial: bool = ..., +) -> Iterable[tuple[_N, _N]]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi new file mode 100644 index 000000000000..e6733f374430 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi @@ -0,0 +1,14 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def k_edge_components(G, k): ... +def k_edge_subgraphs(G, k): ... +def bridge_components(G) -> Generator[Incomplete, Incomplete, None]: ... + +class EdgeComponentAuxGraph: + A: Incomplete + H: Incomplete + @classmethod + def construct(EdgeComponentAuxGraph, G): ... + def k_edge_components(self, k) -> Generator[Incomplete, Incomplete, None]: ... + def k_edge_subgraphs(self, k) -> Generator[Incomplete, Incomplete, None]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi new file mode 100644 index 000000000000..a94ecbc78828 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi @@ -0,0 +1,7 @@ +from _typeshed import Incomplete + +from networkx.algorithms.flow import edmonds_karp + +default_flow_func = edmonds_karp + +def k_components(G, flow_func: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi b/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi new file mode 100644 index 000000000000..71f2ab76d70b --- /dev/null +++ b/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi @@ -0,0 +1,10 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from networkx.algorithms.flow import edmonds_karp + +default_flow_func = edmonds_karp + +def all_node_cuts( + G, k: Incomplete | None = None, flow_func: Incomplete | None = None +) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/stoerwagner.pyi b/stubs/networkx/networkx/algorithms/connectivity/stoerwagner.pyi new file mode 100644 index 000000000000..1463d416ce9d --- /dev/null +++ b/stubs/networkx/networkx/algorithms/connectivity/stoerwagner.pyi @@ -0,0 +1 @@ +def stoer_wagner(G, weight: str = "weight", heap=...): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/utils.pyi b/stubs/networkx/networkx/algorithms/connectivity/utils.pyi new file mode 100644 index 000000000000..c4c2f53ae208 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/connectivity/utils.pyi @@ -0,0 +1,2 @@ +def build_auxiliary_node_connectivity(G): ... +def build_auxiliary_edge_connectivity(G): ... diff --git a/stubs/networkx/networkx/algorithms/core.pyi b/stubs/networkx/networkx/algorithms/core.pyi new file mode 100644 index 000000000000..6e33b66147da --- /dev/null +++ b/stubs/networkx/networkx/algorithms/core.pyi @@ -0,0 +1,9 @@ +from _typeshed import Incomplete + +def core_number(G): ... +def k_core(G, k: Incomplete | None = None, core_number: Incomplete | None = None): ... +def k_shell(G, k: Incomplete | None = None, core_number: Incomplete | None = None): ... +def k_crust(G, k: Incomplete | None = None, core_number: Incomplete | None = None): ... +def k_corona(G, k, core_number: Incomplete | None = None): ... +def k_truss(G, k): ... +def onion_layers(G): ... diff --git a/stubs/networkx/networkx/algorithms/covering.pyi b/stubs/networkx/networkx/algorithms/covering.pyi new file mode 100644 index 000000000000..9685e76f994c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/covering.pyi @@ -0,0 +1,4 @@ +from _typeshed import Incomplete + +def min_edge_cover(G, matching_algorithm: Incomplete | None = None): ... +def is_edge_cover(G, cover): ... diff --git a/stubs/networkx/networkx/algorithms/cuts.pyi b/stubs/networkx/networkx/algorithms/cuts.pyi new file mode 100644 index 000000000000..9b5f35853b46 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/cuts.pyi @@ -0,0 +1,18 @@ +from _typeshed import Incomplete + +def cut_size(G, S, T: Incomplete | None = None, weight: Incomplete | None = None): ... +def volume(G, S, weight: Incomplete | None = None): ... +def normalized_cut_size( + G, S, T: Incomplete | None = None, weight: Incomplete | None = None +): ... +def conductance( + G, S, T: Incomplete | None = None, weight: Incomplete | None = None +): ... +def edge_expansion( + G, S, T: Incomplete | None = None, weight: Incomplete | None = None +): ... +def mixing_expansion( + G, S, T: Incomplete | None = None, weight: Incomplete | None = None +): ... +def node_expansion(G, S): ... +def boundary_expansion(G, S): ... diff --git a/stubs/networkx/networkx/algorithms/cycles.pyi b/stubs/networkx/networkx/algorithms/cycles.pyi new file mode 100644 index 000000000000..c47a0f482819 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/cycles.pyi @@ -0,0 +1,21 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def cycle_basis(G, root: Incomplete | None = None): ... +def simple_cycles( + G, length_bound: Incomplete | None = None +) -> Generator[Incomplete, Incomplete, None]: ... + +class _NeighborhoodCache(dict[Incomplete, Incomplete]): + G: Incomplete + def __init__(self, G) -> None: ... + def __missing__(self, v): ... + +def chordless_cycles( + G, length_bound: Incomplete | None = None +) -> Generator[Incomplete, Incomplete, None]: ... +def recursive_simple_cycles(G): ... +def find_cycle( + G, source: Incomplete | None = None, orientation: Incomplete | None = None +): ... +def minimum_cycle_basis(G, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/d_separation.pyi b/stubs/networkx/networkx/algorithms/d_separation.pyi new file mode 100644 index 000000000000..12a4a645cb3b --- /dev/null +++ b/stubs/networkx/networkx/algorithms/d_separation.pyi @@ -0,0 +1,3 @@ +def d_separated(G, x, y, z): ... +def minimal_d_separator(G, u, v): ... +def is_minimal_d_separator(G, u, v, z): ... diff --git a/stubs/networkx/networkx/algorithms/dag.pyi b/stubs/networkx/networkx/algorithms/dag.pyi new file mode 100644 index 000000000000..746924c435f0 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/dag.pyi @@ -0,0 +1,26 @@ +from typing import TypeVar + +from _typeshed import Incomplete +from networkx.classes.graph import Graph + +_T = TypeVar("_T") + +def descendants(G: Graph[_T], source: _T) -> set[_T]: ... +def ancestors(G: Graph[_T], source: _T) -> set[_T]: ... +def is_directed_acyclic_graph(G: Incomplete) -> Incomplete: ... +def topological_sort(G: Incomplete) -> None: ... +def lexicographical_topological_sort( + G: Incomplete, key: Incomplete | None = ... +) -> Incomplete: ... +def all_topological_sorts(G: Incomplete) -> None: ... +def is_aperiodic(G: Incomplete) -> Incomplete: ... +def transitive_closure(G: Incomplete) -> Incomplete: ... +def transitive_reduction(G: Incomplete) -> Incomplete: ... +def antichains(G: Incomplete) -> None: ... +def dag_longest_path( + G: Incomplete, weight: str = ..., default_weight: int = ... +) -> Incomplete: ... +def dag_longest_path_length( + G: Incomplete, weight: str = ..., default_weight: int = ... +) -> Incomplete: ... +def dag_to_branching(G: Incomplete) -> Incomplete: ... diff --git a/stubs/networkx/networkx/algorithms/distance_measures.pyi b/stubs/networkx/networkx/algorithms/distance_measures.pyi new file mode 100644 index 000000000000..29e076eb4b21 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/distance_measures.pyi @@ -0,0 +1,41 @@ +from _typeshed import Incomplete + +def eccentricity( + G, + v: Incomplete | None = None, + sp: Incomplete | None = None, + weight: Incomplete | None = None, +): ... +def diameter( + G, + e: Incomplete | None = None, + usebounds: bool = False, + weight: Incomplete | None = None, +): ... +def periphery( + G, + e: Incomplete | None = None, + usebounds: bool = False, + weight: Incomplete | None = None, +): ... +def radius( + G, + e: Incomplete | None = None, + usebounds: bool = False, + weight: Incomplete | None = None, +): ... +def center( + G, + e: Incomplete | None = None, + usebounds: bool = False, + weight: Incomplete | None = None, +): ... +def barycenter( + G, + weight: Incomplete | None = None, + attr: Incomplete | None = None, + sp: Incomplete | None = None, +): ... +def resistance_distance( + G, nodeA, nodeB, weight: Incomplete | None = None, invert_weight: bool = True +): ... diff --git a/stubs/networkx/networkx/algorithms/distance_regular.pyi b/stubs/networkx/networkx/algorithms/distance_regular.pyi new file mode 100644 index 000000000000..2a6f490323de --- /dev/null +++ b/stubs/networkx/networkx/algorithms/distance_regular.pyi @@ -0,0 +1,4 @@ +def is_distance_regular(G): ... +def global_parameters(b, c): ... +def intersection_array(G): ... +def is_strongly_regular(G): ... diff --git a/stubs/networkx/networkx/algorithms/dominance.pyi b/stubs/networkx/networkx/algorithms/dominance.pyi new file mode 100644 index 000000000000..707ccfc3de34 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/dominance.pyi @@ -0,0 +1,2 @@ +def immediate_dominators(G, start): ... +def dominance_frontiers(G, start): ... diff --git a/stubs/networkx/networkx/algorithms/dominating.pyi b/stubs/networkx/networkx/algorithms/dominating.pyi new file mode 100644 index 000000000000..e48c5e173672 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/dominating.pyi @@ -0,0 +1,4 @@ +from _typeshed import Incomplete + +def dominating_set(G, start_with: Incomplete | None = None): ... +def is_dominating_set(G, nbunch): ... diff --git a/stubs/networkx/networkx/algorithms/efficiency_measures.pyi b/stubs/networkx/networkx/algorithms/efficiency_measures.pyi new file mode 100644 index 000000000000..4a1b3e50d9f5 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/efficiency_measures.pyi @@ -0,0 +1,3 @@ +def efficiency(G, u, v): ... +def global_efficiency(G): ... +def local_efficiency(G): ... diff --git a/stubs/networkx/networkx/algorithms/euler.pyi b/stubs/networkx/networkx/algorithms/euler.pyi new file mode 100644 index 000000000000..72b40863e560 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/euler.pyi @@ -0,0 +1,13 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def is_eulerian(G): ... +def is_semieulerian(G): ... +def eulerian_circuit( + G, source: Incomplete | None = None, keys: bool = False +) -> Generator[Incomplete, Incomplete, None]: ... +def has_eulerian_path(G, source: Incomplete | None = None): ... +def eulerian_path( + G, source: Incomplete | None = None, keys: bool = False +) -> Generator[Incomplete, Incomplete, None]: ... +def eulerize(G): ... diff --git a/stubs/networkx/networkx/algorithms/flow/__init__.pyi b/stubs/networkx/networkx/algorithms/flow/__init__.pyi new file mode 100644 index 000000000000..a8659092bfba --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/__init__.pyi @@ -0,0 +1,14 @@ +from .boykovkolmogorov import * +from .capacityscaling import * +from .dinitz_alg import * +from .edmondskarp import * +from .gomory_hu import * +from .maxflow import * +from .mincost import * +from .networksimplex import * +from .preflowpush import * +from .shortestaugmentingpath import * +from .utils import ( + build_flow_dict as build_flow_dict, + build_residual_network as build_residual_network, +) diff --git a/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi b/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi new file mode 100644 index 000000000000..18c237d26255 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi @@ -0,0 +1,11 @@ +from _typeshed import Incomplete + +def boykov_kolmogorov( + G, + s, + t, + capacity: str = "capacity", + residual: Incomplete | None = None, + value_only: bool = False, + cutoff: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi b/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi new file mode 100644 index 000000000000..ca489742b135 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi @@ -0,0 +1,7 @@ +def capacity_scaling( + G, + demand: str = "demand", + capacity: str = "capacity", + weight: str = "weight", + heap=..., +): ... diff --git a/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi b/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi new file mode 100644 index 000000000000..1a96f54f1c38 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi @@ -0,0 +1,11 @@ +from _typeshed import Incomplete + +def dinitz( + G, + s, + t, + capacity: str = "capacity", + residual: Incomplete | None = None, + value_only: bool = False, + cutoff: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi b/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi new file mode 100644 index 000000000000..b9cee6b8a662 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi @@ -0,0 +1,11 @@ +from _typeshed import Incomplete + +def edmonds_karp( + G, + s, + t, + capacity: str = "capacity", + residual: Incomplete | None = None, + value_only: bool = False, + cutoff: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi b/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi new file mode 100644 index 000000000000..c4b78d0b1a5f --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi @@ -0,0 +1,9 @@ +from _typeshed import Incomplete + +from .edmondskarp import edmonds_karp + +default_flow_func = edmonds_karp + +def gomory_hu_tree( + G, capacity: str = "capacity", flow_func: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/flow/maxflow.pyi b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi new file mode 100644 index 000000000000..7bcf5ce17aaa --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi @@ -0,0 +1,38 @@ +from _typeshed import Incomplete + +from .preflowpush import preflow_push + +default_flow_func = preflow_push + +def maximum_flow( + flowG, + _s, + _t, + capacity: str = "capacity", + flow_func: Incomplete | None = None, + **kwargs +): ... +def maximum_flow_value( + flowG, + _s, + _t, + capacity: str = "capacity", + flow_func: Incomplete | None = None, + **kwargs +): ... +def minimum_cut( + flowG, + _s, + _t, + capacity: str = "capacity", + flow_func: Incomplete | None = None, + **kwargs +): ... +def minimum_cut_value( + flowG, + _s, + _t, + capacity: str = "capacity", + flow_func: Incomplete | None = None, + **kwargs +): ... diff --git a/stubs/networkx/networkx/algorithms/flow/mincost.pyi b/stubs/networkx/networkx/algorithms/flow/mincost.pyi new file mode 100644 index 000000000000..8a480fb4dd5c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/mincost.pyi @@ -0,0 +1,8 @@ +def min_cost_flow_cost( + G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight" +): ... +def min_cost_flow( + G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight" +): ... +def cost_of_flow(G, flowDict, weight: str = "weight"): ... +def max_flow_min_cost(G, s, t, capacity: str = "capacity", weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi b/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi new file mode 100644 index 000000000000..767d70ba174c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi @@ -0,0 +1,48 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +class _DataEssentialsAndFunctions: + node_list: Incomplete + node_indices: Incomplete + node_demands: Incomplete + edge_sources: Incomplete + edge_targets: Incomplete + edge_keys: Incomplete + edge_indices: Incomplete + edge_capacities: Incomplete + edge_weights: Incomplete + edge_count: Incomplete + edge_flow: Incomplete + node_potentials: Incomplete + parent: Incomplete + parent_edge: Incomplete + subtree_size: Incomplete + next_node_dft: Incomplete + prev_node_dft: Incomplete + last_descendent_dft: Incomplete + def __init__( + self, + G, + multigraph, + demand: str = "demand", + capacity: str = "capacity", + weight: str = "weight", + ) -> None: ... + def initialize_spanning_tree(self, n, faux_inf) -> None: ... + def find_apex(self, p, q): ... + def trace_path(self, p, w): ... + def find_cycle(self, i, p, q): ... + def augment_flow(self, Wn, We, f) -> None: ... + def trace_subtree(self, p) -> Generator[Incomplete, None, None]: ... + def remove_edge(self, s, t) -> None: ... + def make_root(self, q) -> None: ... + def add_edge(self, i, p, q) -> None: ... + def update_potentials(self, i, p, q) -> None: ... + def reduced_cost(self, i): ... + def find_entering_edges(self) -> Generator[Incomplete, None, None]: ... + def residual_capacity(self, i, p): ... + def find_leaving_edge(self, Wn, We): ... + +def network_simplex( + G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight" +): ... diff --git a/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi b/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi new file mode 100644 index 000000000000..9069a6de4253 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi @@ -0,0 +1,11 @@ +from _typeshed import Incomplete + +def preflow_push( + G, + s, + t, + capacity: str = "capacity", + residual: Incomplete | None = None, + global_relabel_freq: int = 1, + value_only: bool = False, +): ... diff --git a/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi b/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi new file mode 100644 index 000000000000..3d460bc43c6f --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/shortestaugmentingpath.pyi @@ -0,0 +1,12 @@ +from _typeshed import Incomplete + +def shortest_augmenting_path( + G, + s, + t, + capacity: str = "capacity", + residual: Incomplete | None = None, + value_only: bool = False, + two_phase: bool = False, + cutoff: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/flow/utils.pyi b/stubs/networkx/networkx/algorithms/flow/utils.pyi new file mode 100644 index 000000000000..b110dba94e43 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/utils.pyi @@ -0,0 +1,21 @@ +from _typeshed import Incomplete + +class CurrentEdge: + def __init__(self, edges) -> None: ... + def get(self): ... + def move_to_next(self) -> None: ... + +class Level: + active: Incomplete + inactive: Incomplete + def __init__(self) -> None: ... + +class GlobalRelabelThreshold: + def __init__(self, n, m, freq) -> None: ... + def add_work(self, work) -> None: ... + def is_reached(self): ... + def clear_work(self) -> None: ... + +def build_residual_network(G, capacity): ... +def detect_unboundedness(R, s, t) -> None: ... +def build_flow_dict(G, R): ... diff --git a/stubs/networkx/networkx/algorithms/graph_hashing.pyi b/stubs/networkx/networkx/algorithms/graph_hashing.pyi new file mode 100644 index 000000000000..b840beee06ae --- /dev/null +++ b/stubs/networkx/networkx/algorithms/graph_hashing.pyi @@ -0,0 +1,16 @@ +from _typeshed import Incomplete + +def weisfeiler_lehman_graph_hash( + G, + edge_attr: Incomplete | None = None, + node_attr: Incomplete | None = None, + iterations: int = 3, + digest_size: int = 16, +): ... +def weisfeiler_lehman_subgraph_hashes( + G, + edge_attr: Incomplete | None = None, + node_attr: Incomplete | None = None, + iterations: int = 3, + digest_size: int = 16, +): ... diff --git a/stubs/networkx/networkx/algorithms/graphical.pyi b/stubs/networkx/networkx/algorithms/graphical.pyi new file mode 100644 index 000000000000..f13f5e99c5ef --- /dev/null +++ b/stubs/networkx/networkx/algorithms/graphical.pyi @@ -0,0 +1,6 @@ +def is_graphical(sequence, method: str = "eg"): ... +def is_valid_degree_sequence_havel_hakimi(deg_sequence): ... +def is_valid_degree_sequence_erdos_gallai(deg_sequence): ... +def is_multigraphical(sequence): ... +def is_pseudographical(sequence): ... +def is_digraphical(in_sequence, out_sequence): ... diff --git a/stubs/networkx/networkx/algorithms/hierarchy.pyi b/stubs/networkx/networkx/algorithms/hierarchy.pyi new file mode 100644 index 000000000000..8919d04b111f --- /dev/null +++ b/stubs/networkx/networkx/algorithms/hierarchy.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +def flow_hierarchy(G, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/hybrid.pyi b/stubs/networkx/networkx/algorithms/hybrid.pyi new file mode 100644 index 000000000000..b46e569849ce --- /dev/null +++ b/stubs/networkx/networkx/algorithms/hybrid.pyi @@ -0,0 +1,4 @@ +def kl_connected_subgraph( + G, k, l, low_memory: bool = False, same_as_graph: bool = False +): ... +def is_kl_connected(G, k, l, low_memory: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/isolate.pyi b/stubs/networkx/networkx/algorithms/isolate.pyi new file mode 100644 index 000000000000..0b25847c8d3e --- /dev/null +++ b/stubs/networkx/networkx/algorithms/isolate.pyi @@ -0,0 +1,3 @@ +def is_isolate(G, n): ... +def isolates(G): ... +def number_of_isolates(G): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/__init__.pyi b/stubs/networkx/networkx/algorithms/isomorphism/__init__.pyi new file mode 100644 index 000000000000..878c13eed27c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/isomorphism/__init__.pyi @@ -0,0 +1,7 @@ +from networkx.algorithms.isomorphism.ismags import * +from networkx.algorithms.isomorphism.isomorph import * +from networkx.algorithms.isomorphism.matchhelpers import * +from networkx.algorithms.isomorphism.temporalisomorphvf2 import * +from networkx.algorithms.isomorphism.tree_isomorphism import * +from networkx.algorithms.isomorphism.vf2pp import * +from networkx.algorithms.isomorphism.vf2userfunc import * diff --git a/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi new file mode 100644 index 000000000000..1f123f1507d9 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi @@ -0,0 +1,29 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +class ISMAGS: + graph: Incomplete + subgraph: Incomplete + node_equality: Incomplete + edge_equality: Incomplete + def __init__( + self, + graph, + subgraph, + 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 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/isomorph.pyi b/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi new file mode 100644 index 000000000000..32c5b4416295 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi @@ -0,0 +1,17 @@ +from _typeshed import Incomplete + +def could_be_isomorphic(G1, G2): ... + +graph_could_be_isomorphic = could_be_isomorphic + +def fast_could_be_isomorphic(G1, G2): ... + +fast_graph_could_be_isomorphic = fast_could_be_isomorphic + +def faster_could_be_isomorphic(G1, G2): ... + +faster_graph_could_be_isomorphic = faster_could_be_isomorphic + +def is_isomorphic( + G1, G2, node_match: Incomplete | None = None, edge_match: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi b/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi new file mode 100644 index 000000000000..6c9d612db641 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi @@ -0,0 +1,66 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +class GraphMatcher: + G1: Incomplete + G2: Incomplete + G1_nodes: Incomplete + G2_nodes: Incomplete + G2_node_order: Incomplete + old_recursion_limit: Incomplete + test: str + def __init__(self, G1, G2) -> None: ... + def reset_recursion_limit(self) -> None: ... + def candidate_pairs_iter(self) -> Generator[Incomplete, None, None]: ... + core_1: Incomplete + core_2: Incomplete + inout_1: Incomplete + inout_2: Incomplete + state: Incomplete + mapping: Incomplete + def initialize(self) -> None: ... + def is_isomorphic(self): ... + def isomorphisms_iter(self) -> Generator[Incomplete, Incomplete, None]: ... + def match(self) -> Generator[Incomplete, Incomplete, None]: ... + def semantic_feasibility(self, G1_node, G2_node): ... + def subgraph_is_isomorphic(self): ... + def subgraph_is_monomorphic(self): ... + def subgraph_isomorphisms_iter(self) -> Generator[Incomplete, Incomplete, None]: ... + def subgraph_monomorphisms_iter( + self, + ) -> Generator[Incomplete, Incomplete, None]: ... + def syntactic_feasibility(self, G1_node, G2_node): ... + +class DiGraphMatcher(GraphMatcher): + def __init__(self, G1, G2) -> None: ... + def candidate_pairs_iter(self) -> Generator[Incomplete, None, None]: ... + core_1: Incomplete + core_2: Incomplete + in_1: Incomplete + in_2: Incomplete + out_1: Incomplete + out_2: Incomplete + state: Incomplete + mapping: Incomplete + def initialize(self) -> None: ... + def syntactic_feasibility(self, G1_node, G2_node): ... + +class GMState: + GM: Incomplete + G1_node: Incomplete + G2_node: Incomplete + depth: Incomplete + def __init__( + self, GM, G1_node: Incomplete | None = None, G2_node: Incomplete | None = None + ) -> None: ... + def restore(self) -> None: ... + +class DiGMState: + GM: Incomplete + G1_node: Incomplete + G2_node: Incomplete + depth: Incomplete + def __init__( + self, GM, G1_node: Incomplete | None = None, G2_node: Incomplete | None = None + ) -> None: ... + def restore(self) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi b/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi new file mode 100644 index 000000000000..f65c9817294d --- /dev/null +++ b/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi @@ -0,0 +1,19 @@ +from _typeshed import Incomplete + +def categorical_node_match(attr, default): ... + +categorical_edge_match: Incomplete + +def categorical_multiedge_match(attr, default): ... +def numerical_node_match(attr, default, rtol: float = 1e-05, atol: float = 1e-08): ... + +numerical_edge_match: Incomplete + +def numerical_multiedge_match( + attr, default, rtol: float = 1e-05, atol: float = 1e-08 +): ... +def generic_node_match(attr, default, op): ... + +generic_edge_match: Incomplete + +def generic_multiedge_match(attr, default, op): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi b/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi new file mode 100644 index 000000000000..94297ac3f2fd --- /dev/null +++ b/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi @@ -0,0 +1,26 @@ +from _typeshed import Incomplete + +from .isomorphvf2 import DiGraphMatcher, GraphMatcher + +class TimeRespectingGraphMatcher(GraphMatcher): + temporal_attribute_name: Incomplete + delta: Incomplete + def __init__(self, G1, G2, temporal_attribute_name, delta) -> None: ... + def one_hop(self, Gx, Gx_node, neighbors): ... + def two_hop(self, Gx, core_x, Gx_node, neighbors): ... + def semantic_feasibility(self, G1_node, G2_node): ... + +class TimeRespectingDiGraphMatcher(DiGraphMatcher): + temporal_attribute_name: Incomplete + delta: Incomplete + def __init__(self, G1, G2, temporal_attribute_name, delta) -> None: ... + def get_pred_dates(self, Gx, Gx_node, core_x, pred): ... + def get_succ_dates(self, Gx, Gx_node, core_x, succ): ... + 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 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/isomorphism/tree_isomorphism.pyi b/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi new file mode 100644 index 000000000000..b6502d719dd7 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/isomorphism/tree_isomorphism.pyi @@ -0,0 +1,2 @@ +def rooted_tree_isomorphism(t1, root1, t2, root2): ... +def tree_isomorphism(t1, t2): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi b/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi new file mode 100644 index 000000000000..88d3cdb7b9b3 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi @@ -0,0 +1,43 @@ +from _typeshed import Incomplete +from collections.abc import Generator +from typing import NamedTuple + +class _GraphParameters(NamedTuple): + G1: Incomplete + G2: Incomplete + G1_labels: Incomplete + G2_labels: Incomplete + nodes_of_G1Labels: Incomplete + nodes_of_G2Labels: Incomplete + G2_nodes_of_degree: Incomplete + +class _StateParameters(NamedTuple): + mapping: Incomplete + reverse_mapping: Incomplete + T1: Incomplete + T1_in: Incomplete + T1_tilde: Incomplete + T1_tilde_in: Incomplete + T2: Incomplete + T2_in: Incomplete + T2_tilde: Incomplete + T2_tilde_in: Incomplete + +def vf2pp_isomorphism( + G1, + G2, + node_label: Incomplete | None = None, + default_label: Incomplete | None = None, +): ... +def vf2pp_is_isomorphic( + G1, + G2, + node_label: Incomplete | None = None, + default_label: Incomplete | None = None, +): ... +def vf2pp_all_isomorphisms( + G1, + G2, + node_label: Incomplete | None = None, + default_label: Incomplete | None = None, +) -> Generator[Incomplete, None, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi b/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi new file mode 100644 index 000000000000..f908ee333979 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi @@ -0,0 +1,34 @@ +from _typeshed import Incomplete + +from . import isomorphvf2 as vf2 + +class GraphMatcher(vf2.GraphMatcher): + node_match: Incomplete + edge_match: Incomplete + G1_adj: Incomplete + G2_adj: Incomplete + def __init__( + self, + G1, + G2, + node_match: Incomplete | None = None, + edge_match: Incomplete | None = None, + ) -> None: ... + semantic_feasibility: Incomplete + +class DiGraphMatcher(vf2.DiGraphMatcher): + node_match: Incomplete + edge_match: Incomplete + G1_adj: Incomplete + G2_adj: Incomplete + def __init__( + self, + G1, + G2, + node_match: Incomplete | None = None, + edge_match: Incomplete | None = None, + ) -> None: ... + def semantic_feasibility(self, G1_node, G2_node): ... + +class MultiGraphMatcher(GraphMatcher): ... +class MultiDiGraphMatcher(DiGraphMatcher): ... diff --git a/stubs/networkx/networkx/algorithms/link_analysis/__init__.pyi b/stubs/networkx/networkx/algorithms/link_analysis/__init__.pyi new file mode 100644 index 000000000000..6009f0008147 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/link_analysis/__init__.pyi @@ -0,0 +1,2 @@ +from networkx.algorithms.link_analysis.hits_alg import * +from networkx.algorithms.link_analysis.pagerank_alg import * diff --git a/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi b/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi new file mode 100644 index 000000000000..96a6270d174a --- /dev/null +++ b/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi @@ -0,0 +1,9 @@ +from _typeshed import Incomplete + +def hits( + G, + max_iter: int = 100, + tol: float = 1e-08, + nstart: Incomplete | None = None, + normalized: bool = True, +): ... diff --git a/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi b/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi new file mode 100644 index 000000000000..048f4226cab9 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi @@ -0,0 +1,20 @@ +from _typeshed import Incomplete + +def pagerank( + G, + alpha: float = 0.85, + personalization: Incomplete | None = None, + max_iter: int = 100, + tol: float = 1e-06, + nstart: Incomplete | None = None, + weight: str = "weight", + dangling: Incomplete | None = None, +): ... +def google_matrix( + G, + alpha: float = 0.85, + personalization: Incomplete | None = None, + nodelist: Incomplete | None = None, + weight: str = "weight", + dangling: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/link_prediction.pyi b/stubs/networkx/networkx/algorithms/link_prediction.pyi new file mode 100644 index 000000000000..eb831afc69b7 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/link_prediction.pyi @@ -0,0 +1,21 @@ +from _typeshed import Incomplete + +def resource_allocation_index(G, ebunch: Incomplete | None = None): ... +def jaccard_coefficient(G, ebunch: Incomplete | None = None): ... +def adamic_adar_index(G, ebunch: Incomplete | None = None): ... +def common_neighbor_centrality( + G, ebunch: Incomplete | None = None, alpha: float = 0.8 +): ... +def preferential_attachment(G, ebunch: Incomplete | None = None): ... +def cn_soundarajan_hopcroft( + G, ebunch: Incomplete | None = None, community: str = "community" +): ... +def ra_index_soundarajan_hopcroft( + G, ebunch: Incomplete | None = None, community: str = "community" +): ... +def within_inter_cluster( + G, + ebunch: Incomplete | None = None, + delta: float = 0.001, + community: str = "community", +): ... diff --git a/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi b/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi new file mode 100644 index 000000000000..57b6f19bae93 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/lowest_common_ancestors.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def all_pairs_lowest_common_ancestor(G, pairs: Incomplete | None = None): ... +def lowest_common_ancestor(G, node1, node2, default: Incomplete | None = None): ... +def tree_all_pairs_lowest_common_ancestor( + G, root: Incomplete | None = None, pairs: Incomplete | None = None +) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/matching.pyi b/stubs/networkx/networkx/algorithms/matching.pyi new file mode 100644 index 000000000000..968e260453b4 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/matching.pyi @@ -0,0 +1,6 @@ +def maximal_matching(G): ... +def is_matching(G, matching): ... +def is_maximal_matching(G, matching): ... +def is_perfect_matching(G, matching): ... +def min_weight_matching(G, weight: str = "weight"): ... +def max_weight_matching(G, maxcardinality: bool = False, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/minors/__init__.pyi b/stubs/networkx/networkx/algorithms/minors/__init__.pyi new file mode 100644 index 000000000000..e8f96f71acd2 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/minors/__init__.pyi @@ -0,0 +1,7 @@ +from networkx.algorithms.minors.contraction import ( + contracted_edge as contracted_edge, + contracted_nodes as contracted_nodes, + equivalence_classes as equivalence_classes, + identified_nodes as identified_nodes, + quotient_graph as quotient_graph, +) diff --git a/stubs/networkx/networkx/algorithms/minors/contraction.pyi b/stubs/networkx/networkx/algorithms/minors/contraction.pyi new file mode 100644 index 000000000000..350c734b8117 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/minors/contraction.pyi @@ -0,0 +1,17 @@ +from _typeshed import Incomplete + +def equivalence_classes(iterable, relation): ... +def quotient_graph( + G, + partition, + edge_relation: Incomplete | None = None, + node_data: Incomplete | None = None, + edge_data: Incomplete | None = None, + relabel: bool = False, + create_using: Incomplete | None = None, +): ... +def contracted_nodes(G, u, v, self_loops: bool = True, copy: bool = True): ... + +identified_nodes = contracted_nodes + +def contracted_edge(G, edge, self_loops: bool = True, copy: bool = True): ... diff --git a/stubs/networkx/networkx/algorithms/mis.pyi b/stubs/networkx/networkx/algorithms/mis.pyi new file mode 100644 index 000000000000..9601a5a745ab --- /dev/null +++ b/stubs/networkx/networkx/algorithms/mis.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def maximal_independent_set( + G, nodes: Incomplete | None = None, seed: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/moral.pyi b/stubs/networkx/networkx/algorithms/moral.pyi new file mode 100644 index 000000000000..dad4d3ee33ad --- /dev/null +++ b/stubs/networkx/networkx/algorithms/moral.pyi @@ -0,0 +1 @@ +def moral_graph(G): ... diff --git a/stubs/networkx/networkx/algorithms/node_classification.pyi b/stubs/networkx/networkx/algorithms/node_classification.pyi new file mode 100644 index 000000000000..312054755f89 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/node_classification.pyi @@ -0,0 +1,4 @@ +def harmonic_function(G, max_iter: int = 30, label_name: str = "label"): ... +def local_and_global_consistency( + G, alpha: float = 0.99, max_iter: int = 30, label_name: str = "label" +): ... diff --git a/stubs/networkx/networkx/algorithms/non_randomness.pyi b/stubs/networkx/networkx/algorithms/non_randomness.pyi new file mode 100644 index 000000000000..da85a16ceef5 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/non_randomness.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +def non_randomness(G, k: Incomplete | None = None, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/operators/__init__.pyi b/stubs/networkx/networkx/algorithms/operators/__init__.pyi new file mode 100644 index 000000000000..0ebc6ab9998d --- /dev/null +++ b/stubs/networkx/networkx/algorithms/operators/__init__.pyi @@ -0,0 +1,4 @@ +from networkx.algorithms.operators.all import * +from networkx.algorithms.operators.binary import * +from networkx.algorithms.operators.product import * +from networkx.algorithms.operators.unary import * diff --git a/stubs/networkx/networkx/algorithms/operators/all.pyi b/stubs/networkx/networkx/algorithms/operators/all.pyi new file mode 100644 index 000000000000..e4cc8ea4fc7d --- /dev/null +++ b/stubs/networkx/networkx/algorithms/operators/all.pyi @@ -0,0 +1,4 @@ +def union_all(graphs, rename=()): ... +def disjoint_union_all(graphs): ... +def compose_all(graphs): ... +def intersection_all(graphs): ... diff --git a/stubs/networkx/networkx/algorithms/operators/binary.pyi b/stubs/networkx/networkx/algorithms/operators/binary.pyi new file mode 100644 index 000000000000..9796f469ad3b --- /dev/null +++ b/stubs/networkx/networkx/algorithms/operators/binary.pyi @@ -0,0 +1,22 @@ +from typing import TypeVar + +from _typeshed import Incomplete +from networkx.classes.digraph import DiGraph + +def disjoint_union(G: Incomplete, H: Incomplete) -> Incomplete: ... +def intersection(G: Incomplete, H: Incomplete) -> Incomplete: ... +def difference(G: Incomplete, H: Incomplete) -> Incomplete: ... +def symmetric_difference(G: Incomplete, H: Incomplete) -> Incomplete: ... + +_X = TypeVar("_X", covariant=True) +_Y = TypeVar("_Y", covariant=True) +# GT = TypeVar('GT', bound=Graph) +# TODO: This does not handle the cases when graphs of different types are passed which is allowed + +def compose(G: DiGraph[_X], H: DiGraph[_Y]) -> DiGraph[_X | _Y]: ... +def union( + G: DiGraph[_X], + H: DiGraph[_Y], + rename: Incomplete = ..., + name: Incomplete | None = ..., +) -> DiGraph[_X | _Y]: ... diff --git a/stubs/networkx/networkx/algorithms/operators/product.pyi b/stubs/networkx/networkx/algorithms/operators/product.pyi new file mode 100644 index 000000000000..8a3694580fef --- /dev/null +++ b/stubs/networkx/networkx/algorithms/operators/product.pyi @@ -0,0 +1,7 @@ +def tensor_product(G, H): ... +def cartesian_product(G, H): ... +def lexicographic_product(G, H): ... +def strong_product(G, H): ... +def power(G, k): ... +def rooted_product(G, H, root): ... +def corona_product(G, H): ... diff --git a/stubs/networkx/networkx/algorithms/operators/unary.pyi b/stubs/networkx/networkx/algorithms/operators/unary.pyi new file mode 100644 index 000000000000..c255e7205ae3 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/operators/unary.pyi @@ -0,0 +1,9 @@ +from typing import TypeVar + +from _typeshed import Incomplete +from networkx.classes.digraph import DiGraph + +_T = TypeVar("_T") + +def complement(G: Incomplete) -> Incomplete: ... +def reverse(G: DiGraph[_T], copy: bool = ...) -> DiGraph[_T]: ... diff --git a/stubs/networkx/networkx/algorithms/planar_drawing.pyi b/stubs/networkx/networkx/algorithms/planar_drawing.pyi new file mode 100644 index 000000000000..328b776bb01b --- /dev/null +++ b/stubs/networkx/networkx/algorithms/planar_drawing.pyi @@ -0,0 +1 @@ +def combinatorial_embedding_to_pos(embedding, fully_triangulate: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi new file mode 100644 index 000000000000..d64ed20a65b3 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -0,0 +1,78 @@ +from collections.abc import Iterable +from typing import Generic, TypeVar + +import networkx as nx +from _typeshed import Incomplete + +def check_planarity(G: Incomplete, counterexample: bool = ...) -> Incomplete: ... + +_N = TypeVar("_N") + +class Interval: + low: Incomplete = ... + high: Incomplete = ... + def __init__( + self, low: Incomplete | None = ..., high: Incomplete | None = ... + ) -> None: ... + def empty(self) -> Incomplete: ... + def copy(self) -> Incomplete: ... + def conflicting(self, b: Incomplete, planarity_state: Incomplete) -> Incomplete: ... + +class ConflictPair: + left: Incomplete = ... + right: Incomplete = ... + def __init__(self, left: Incomplete = ..., right: Incomplete = ...) -> None: ... + def swap(self) -> None: ... + def lowest(self, planarity_state: Incomplete) -> Incomplete: ... + +class LRPlanarity: + G: Incomplete = ... + roots: Incomplete = ... + height: Incomplete = ... + lowpt: Incomplete = ... + lowpt2: Incomplete = ... + nesting_depth: Incomplete = ... + parent_edge: Incomplete = ... + DG: Incomplete = ... + adjs: Incomplete = ... + ordered_adjs: Incomplete = ... + ref: Incomplete = ... + side: Incomplete = ... + S: Incomplete = ... + stack_bottom: Incomplete = ... + lowpt_edge: Incomplete = ... + left_ref: Incomplete = ... + right_ref: Incomplete = ... + embedding: Incomplete = ... + def __init__(self, G: Incomplete) -> None: ... + def lr_planarity(self) -> Incomplete: ... + def lr_planarity_recursive(self) -> Incomplete: ... + def dfs_orientation(self, v: Incomplete) -> Incomplete: ... + def dfs_orientation_recursive(self, v: Incomplete) -> None: ... + def dfs_testing(self, v: Incomplete) -> Incomplete: ... + def dfs_testing_recursive(self, v: Incomplete) -> Incomplete: ... + def add_constraints(self, ei: Incomplete, e: Incomplete) -> Incomplete: ... + def remove_back_edges(self, e: Incomplete) -> None: ... + def dfs_embedding(self, v: Incomplete) -> Incomplete: ... + def dfs_embedding_recursive(self, v: Incomplete) -> None: ... + def sign(self, e: Incomplete) -> Incomplete: ... + def sign_recursive(self, e: Incomplete) -> Incomplete: ... + +class PlanarEmbedding(Generic[_N], nx.DiGraph[_N]): + def get_data(self) -> dict[_N, list[_N]]: ... + def set_data(self, data: dict[_N, list[_N]]) -> None: ... + def neighbors_cw_order(self, v: _N) -> Iterable[_N]: ... + def check_structure(self) -> None: ... + def add_half_edge_ccw( + self, start_node: _N, end_node: _N, reference_neighbor: _N + ) -> None: ... + def add_half_edge_cw( + self, start_node: _N, end_node: _N, reference_neighbor: _N + ) -> None: ... + def connect_components(self, v: _N, w: _N) -> None: ... + def add_half_edge_first(self, start_node: _N, end_node: _N) -> None: ... + def next_face_half_edge(self, v: _N, w: _N) -> tuple[_N, _N]: ... + def traverse_face( + self, v: _N, w: _N, mark_half_edges: set[tuple[_N, _N]] | None = ... + ) -> list[_N]: ... + def is_directed(self) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/polynomials.pyi b/stubs/networkx/networkx/algorithms/polynomials.pyi new file mode 100644 index 000000000000..bbe5dcfb4648 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/polynomials.pyi @@ -0,0 +1,2 @@ +def tutte_polynomial(G): ... +def chromatic_polynomial(G): ... diff --git a/stubs/networkx/networkx/algorithms/reciprocity.pyi b/stubs/networkx/networkx/algorithms/reciprocity.pyi new file mode 100644 index 000000000000..cb181dd0930c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/reciprocity.pyi @@ -0,0 +1,4 @@ +from _typeshed import Incomplete + +def reciprocity(G, nodes: Incomplete | None = None): ... +def overall_reciprocity(G): ... diff --git a/stubs/networkx/networkx/algorithms/regular.pyi b/stubs/networkx/networkx/algorithms/regular.pyi new file mode 100644 index 000000000000..751e5cc78a63 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/regular.pyi @@ -0,0 +1,3 @@ +def is_regular(G): ... +def is_k_regular(G, k): ... +def k_factor(G, k, matching_weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/richclub.pyi b/stubs/networkx/networkx/algorithms/richclub.pyi new file mode 100644 index 000000000000..528d42cb3c3c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/richclub.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def rich_club_coefficient( + G, normalized: bool = True, Q: int = 100, seed: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/__init__.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/__init__.pyi new file mode 100644 index 000000000000..b64646da090c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/shortest_paths/__init__.pyi @@ -0,0 +1,5 @@ +from networkx.algorithms.shortest_paths.astar import * +from networkx.algorithms.shortest_paths.dense import * +from networkx.algorithms.shortest_paths.generic import * +from networkx.algorithms.shortest_paths.unweighted import * +from networkx.algorithms.shortest_paths.weighted import * diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi new file mode 100644 index 000000000000..fd118e3836ce --- /dev/null +++ b/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete + +def astar_path( + G, source, target, heuristic: Incomplete | None = None, weight: str = "weight" +): ... +def astar_path_length( + G, source, target, heuristic: Incomplete | None = None, weight: str = "weight" +): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi new file mode 100644 index 000000000000..3c8b52392e85 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete + +def floyd_warshall_numpy( + G, nodelist: Incomplete | None = None, weight: str = "weight" +): ... +def floyd_warshall_predecessor_and_distance(G, weight: str = "weight"): ... +def reconstruct_path(source, target, predecessors): ... +def floyd_warshall(G, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi new file mode 100644 index 000000000000..ac0bc9abfa93 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi @@ -0,0 +1,42 @@ +from collections.abc import Iterable +from typing import TypeVar, overload + +from _typeshed import Incomplete +from networkx.classes.graph import Graph + +_T = TypeVar("_T") + +def has_path(G: Incomplete, source: Incomplete, target: Incomplete) -> Incomplete: ... +@overload +def shortest_path( + G: Graph[_T], + source: _T, + target: _T, + weight: Incomplete | None = ..., + method: str = ..., +) -> list[_T]: ... +@overload +def shortest_path( + G: Graph[_T], target: _T, method: str = ... +) -> dict[_T, list[_T]]: ... +@overload +def shortest_path( + G: Graph[_T], source: _T, method: str = ... +) -> dict[_T, list[_T]]: ... +def shortest_path_length( + G: Incomplete, + source: Incomplete | None = ..., + target: Incomplete | None = ..., + weight: Incomplete | None = ..., + method: str = ..., +) -> Incomplete: ... +def average_shortest_path_length( + G: Incomplete, weight: Incomplete | None = ..., method: str = ... +) -> Incomplete: ... +def all_shortest_paths( + G: Graph[_T], + source: _T, + target: _T, + weight: Incomplete | None = ..., + method: str = ..., +) -> Iterable[list[_T]]: ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi new file mode 100644 index 000000000000..76eb9e9df3dc --- /dev/null +++ b/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi @@ -0,0 +1,21 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def single_source_shortest_path_length(G, source, cutoff: Incomplete | None = None): ... +def single_target_shortest_path_length(G, target, cutoff: Incomplete | None = None): ... +def all_pairs_shortest_path_length( + G, cutoff: Incomplete | None = None +) -> Generator[Incomplete, None, None]: ... +def bidirectional_shortest_path(G, source, target): ... +def single_source_shortest_path(G, source, cutoff: Incomplete | None = None): ... +def single_target_shortest_path(G, target, cutoff: Incomplete | None = None): ... +def all_pairs_shortest_path( + G, cutoff: Incomplete | None = None +) -> Generator[Incomplete, None, None]: ... +def predecessor( + G, + source, + target: Incomplete | None = None, + cutoff: Incomplete | None = None, + return_seen: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi new file mode 100644 index 000000000000..c67772b42a4f --- /dev/null +++ b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi @@ -0,0 +1,68 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def dijkstra_path(G, source, target, weight: str = "weight"): ... +def dijkstra_path_length(G, source, target, weight: str = "weight"): ... +def single_source_dijkstra_path( + G, source, cutoff: Incomplete | None = None, weight: str = "weight" +): ... +def single_source_dijkstra_path_length( + G, source, cutoff: Incomplete | None = None, weight: str = "weight" +): ... +def single_source_dijkstra( + G, + source, + target: Incomplete | None = None, + cutoff: Incomplete | None = None, + weight: str = "weight", +): ... +def multi_source_dijkstra_path( + G, sources, cutoff: Incomplete | None = None, weight: str = "weight" +): ... +def multi_source_dijkstra_path_length( + G, sources, cutoff: Incomplete | None = None, weight: str = "weight" +): ... +def multi_source_dijkstra( + G, + sources, + target: Incomplete | None = None, + cutoff: Incomplete | None = None, + weight: str = "weight", +): ... +def dijkstra_predecessor_and_distance( + G, source, cutoff: Incomplete | None = None, weight: str = "weight" +): ... +def all_pairs_dijkstra( + G, cutoff: Incomplete | None = None, weight: str = "weight" +) -> Generator[Incomplete, None, None]: ... +def all_pairs_dijkstra_path_length( + G, cutoff: Incomplete | None = None, weight: str = "weight" +) -> Generator[Incomplete, None, None]: ... +def all_pairs_dijkstra_path( + G, cutoff: Incomplete | None = None, weight: str = "weight" +) -> Generator[Incomplete, None, None]: ... +def bellman_ford_predecessor_and_distance( + G, + source, + target: Incomplete | None = None, + weight: str = "weight", + heuristic: bool = False, +): ... +def bellman_ford_path(G, source, target, weight: str = "weight"): ... +def bellman_ford_path_length(G, source, target, weight: str = "weight"): ... +def single_source_bellman_ford_path(G, source, weight: str = "weight"): ... +def single_source_bellman_ford_path_length(G, source, weight: str = "weight"): ... +def single_source_bellman_ford( + G, source, target: Incomplete | None = None, weight: str = "weight" +): ... +def all_pairs_bellman_ford_path_length( + G, weight: str = "weight" +) -> Generator[Incomplete, None, None]: ... +def all_pairs_bellman_ford_path( + G, weight: str = "weight" +) -> Generator[Incomplete, None, None]: ... +def goldberg_radzik(G, source, weight: str = "weight"): ... +def negative_edge_cycle(G, weight: str = "weight", heuristic: bool = True): ... +def find_negative_cycle(G, source, weight: str = "weight"): ... +def bidirectional_dijkstra(G, source, target, weight: str = "weight"): ... +def johnson(G, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/similarity.pyi b/stubs/networkx/networkx/algorithms/similarity.pyi new file mode 100644 index 000000000000..d1a6f6a5a2fe --- /dev/null +++ b/stubs/networkx/networkx/algorithms/similarity.pyi @@ -0,0 +1,80 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def graph_edit_distance( + G1, + G2, + node_match: Incomplete | None = None, + edge_match: Incomplete | None = None, + node_subst_cost: Incomplete | None = None, + node_del_cost: Incomplete | None = None, + node_ins_cost: Incomplete | None = None, + edge_subst_cost: Incomplete | None = None, + edge_del_cost: Incomplete | None = None, + edge_ins_cost: Incomplete | None = None, + roots: Incomplete | None = None, + upper_bound: Incomplete | None = None, + timeout: Incomplete | None = None, +): ... +def optimal_edit_paths( + G1, + G2, + node_match: Incomplete | None = None, + edge_match: Incomplete | None = None, + node_subst_cost: Incomplete | None = None, + node_del_cost: Incomplete | None = None, + node_ins_cost: Incomplete | None = None, + edge_subst_cost: Incomplete | None = None, + edge_del_cost: Incomplete | None = None, + edge_ins_cost: Incomplete | None = None, + upper_bound: Incomplete | None = None, +): ... +def optimize_graph_edit_distance( + G1, + G2, + node_match: Incomplete | None = None, + edge_match: Incomplete | None = None, + node_subst_cost: Incomplete | None = None, + node_del_cost: Incomplete | None = None, + node_ins_cost: Incomplete | None = None, + edge_subst_cost: Incomplete | None = None, + edge_del_cost: Incomplete | None = None, + edge_ins_cost: Incomplete | None = None, + upper_bound: Incomplete | None = None, +) -> Generator[Incomplete, None, None]: ... +def optimize_edit_paths( + G1, + G2, + node_match: Incomplete | None = None, + edge_match: Incomplete | None = None, + node_subst_cost: Incomplete | None = None, + node_del_cost: Incomplete | None = None, + node_ins_cost: Incomplete | None = None, + edge_subst_cost: Incomplete | None = None, + edge_del_cost: Incomplete | None = None, + edge_ins_cost: Incomplete | None = None, + upper_bound: Incomplete | None = None, + strictly_decreasing: bool = True, + roots: Incomplete | None = None, + timeout: Incomplete | None = None, +) -> Generator[Incomplete, None, Incomplete]: ... +def simrank_similarity( + G, + source: Incomplete | None = None, + target: Incomplete | None = None, + importance_factor: float = 0.9, + max_iterations: int = 1000, + tolerance: float = 0.0001, +): ... +def panther_similarity( + G, + source, + k: int = 5, + path_length: int = 5, + c: float = 0.5, + delta: float = 0.1, + eps: Incomplete | None = None, +): ... +def generate_random_paths( + G, sample_size, path_length: int = 5, index_map: Incomplete | None = None +) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/simple_paths.pyi b/stubs/networkx/networkx/algorithms/simple_paths.pyi new file mode 100644 index 000000000000..16c63db76606 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/simple_paths.pyi @@ -0,0 +1,24 @@ +from collections.abc import Iterator +from typing import TypeVar + +from _typeshed import Incomplete +from networkx.classes.graph import Graph + +_T = TypeVar("_T") + +def is_simple_path(G: Graph[_T], nodes: list[_T]) -> Incomplete: ... +def all_simple_paths( + G: Graph[_T], source: _T, target: _T, cutoff: Incomplete | None = ... +) -> Iterator[list[_T]]: ... +def shortest_simple_paths( + G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = ... +) -> Iterator[list[_T]]: ... + +class PathBuffer: + paths: Incomplete = ... + sortedpaths: Incomplete = ... + counter: Incomplete = ... + def __init__(self) -> None: ... + def __len__(self) -> Incomplete: ... + def push(self, cost: Incomplete, path: Incomplete) -> None: ... + def pop(self) -> Incomplete: ... diff --git a/stubs/networkx/networkx/algorithms/smallworld.pyi b/stubs/networkx/networkx/algorithms/smallworld.pyi new file mode 100644 index 000000000000..f4525c0550ac --- /dev/null +++ b/stubs/networkx/networkx/algorithms/smallworld.pyi @@ -0,0 +1,14 @@ +from _typeshed import Incomplete + +def random_reference( + G, niter: int = 1, connectivity: bool = True, seed: Incomplete | None = None +): ... +def lattice_reference( + G, + niter: int = 5, + D: Incomplete | None = None, + connectivity: bool = True, + seed: Incomplete | None = None, +): ... +def sigma(G, niter: int = 100, nrand: int = 10, seed: Incomplete | None = None): ... +def omega(G, niter: int = 5, nrand: int = 10, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/smetric.pyi b/stubs/networkx/networkx/algorithms/smetric.pyi new file mode 100644 index 000000000000..1a312747a930 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/smetric.pyi @@ -0,0 +1 @@ +def s_metric(G, normalized: bool = True): ... diff --git a/stubs/networkx/networkx/algorithms/sparsifiers.pyi b/stubs/networkx/networkx/algorithms/sparsifiers.pyi new file mode 100644 index 000000000000..0d17140307a7 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/sparsifiers.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def spanner( + G, stretch, weight: Incomplete | None = None, seed: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/structuralholes.pyi b/stubs/networkx/networkx/algorithms/structuralholes.pyi new file mode 100644 index 000000000000..48023e121730 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/structuralholes.pyi @@ -0,0 +1,9 @@ +from _typeshed import Incomplete + +def effective_size( + G, nodes: Incomplete | None = None, weight: Incomplete | None = None +): ... +def constraint( + G, nodes: Incomplete | None = None, weight: Incomplete | None = None +): ... +def local_constraint(G, u, v, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/summarization.pyi b/stubs/networkx/networkx/algorithms/summarization.pyi new file mode 100644 index 000000000000..0477d1f70b01 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/summarization.pyi @@ -0,0 +1,11 @@ +from _typeshed import Incomplete + +def dedensify(G, threshold, prefix: Incomplete | None = None, copy: bool = True): ... +def snap_aggregation( + G, + node_attributes, + edge_attributes=(), + prefix: str = "Supernode-", + supernode_attribute: str = "group", + superedge_attribute: str = "types", +): ... diff --git a/stubs/networkx/networkx/algorithms/swap.pyi b/stubs/networkx/networkx/algorithms/swap.pyi new file mode 100644 index 000000000000..098234460e21 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/swap.pyi @@ -0,0 +1,11 @@ +from _typeshed import Incomplete + +def directed_edge_swap( + G, *, nswap: int = 1, max_tries: int = 100, seed: Incomplete | None = None +): ... +def double_edge_swap( + G, nswap: int = 1, max_tries: int = 100, seed: Incomplete | None = None +): ... +def connected_double_edge_swap( + G, nswap: int = 1, _window_threshold: int = 3, seed: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/algorithms/threshold.pyi b/stubs/networkx/networkx/algorithms/threshold.pyi new file mode 100644 index 000000000000..dedeb06d52f3 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/threshold.pyi @@ -0,0 +1,4 @@ +from _typeshed import Incomplete + +def is_threshold_graph(G): ... +def find_threshold_graph(G, create_using: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/tournament.pyi b/stubs/networkx/networkx/algorithms/tournament.pyi new file mode 100644 index 000000000000..5fe9745bc258 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/tournament.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete + +def is_tournament(G): ... +def hamiltonian_path(G): ... +def random_tournament(n, seed: Incomplete | None = None): ... +def score_sequence(G): ... +def is_reachable(G, s, t): ... +def is_strongly_connected(G): ... diff --git a/stubs/networkx/networkx/algorithms/traversal/__init__.pyi b/stubs/networkx/networkx/algorithms/traversal/__init__.pyi new file mode 100644 index 000000000000..c97ceceb614a --- /dev/null +++ b/stubs/networkx/networkx/algorithms/traversal/__init__.pyi @@ -0,0 +1,5 @@ +from .beamsearch import * +from .breadth_first_search import * +from .depth_first_search import * +from .edgebfs import * +from .edgedfs import * diff --git a/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi b/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi new file mode 100644 index 000000000000..7c4a07b7255c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def bfs_beam_edges( + G, source, value, width: Incomplete | None = None +) -> Generator[Incomplete, Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi b/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi new file mode 100644 index 000000000000..b659f030723c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi @@ -0,0 +1,31 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def bfs_edges( + G, + source, + reverse: bool = False, + depth_limit: Incomplete | None = None, + sort_neighbors: Incomplete | None = None, +) -> Generator[Incomplete, Incomplete, None]: ... +def bfs_tree( + G, + source, + reverse: bool = False, + depth_limit: Incomplete | None = None, + sort_neighbors: Incomplete | None = None, +): ... +def bfs_predecessors( + G, + source, + depth_limit: Incomplete | None = None, + sort_neighbors: Incomplete | None = None, +) -> Generator[Incomplete, None, None]: ... +def bfs_successors( + G, + source, + depth_limit: Incomplete | None = None, + sort_neighbors: Incomplete | None = None, +) -> Generator[Incomplete, None, None]: ... +def bfs_layers(G, sources) -> Generator[Incomplete, None, None]: ... +def descendants_at_distance(G, source, distance): ... diff --git a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi new file mode 100644 index 000000000000..7427ca5e9131 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi @@ -0,0 +1,29 @@ +from collections.abc import Iterator +from typing import TypeVar + +from _typeshed import Incomplete +from networkx.classes.graph import Graph + +_T = TypeVar("_T") + +def dfs_edges( + G: Graph[_T], source: _T | None = ..., depth_limit: int | None = ... +) -> Iterator[tuple[_T, _T]]: ... +def dfs_tree( + G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ... +) -> Incomplete: ... +def dfs_predecessors( + G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ... +) -> Incomplete: ... +def dfs_successors( + G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ... +) -> Incomplete: ... +def dfs_postorder_nodes( + G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ... +) -> Incomplete: ... +def dfs_preorder_nodes( + G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ... +) -> Incomplete: ... +def dfs_labeled_edges( + G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ... +) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi b/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi new file mode 100644 index 000000000000..2220d26ff343 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/traversal/edgebfs.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def edge_bfs( + G, source: Incomplete | None = None, orientation: Incomplete | None = None +) -> Generator[Incomplete, None, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi b/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi new file mode 100644 index 000000000000..8c7dc084e51c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/traversal/edgedfs.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def edge_dfs( + G, source: Incomplete | None = None, orientation: Incomplete | None = None +) -> Generator[Incomplete, None, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/tree/__init__.pyi b/stubs/networkx/networkx/algorithms/tree/__init__.pyi new file mode 100644 index 000000000000..b6f2ed45da53 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/tree/__init__.pyi @@ -0,0 +1,6 @@ +from .branchings import * +from .coding import * +from .decomposition import * +from .mst import * +from .operations import * +from .recognition import * diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi new file mode 100644 index 000000000000..b1e1d182260a --- /dev/null +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -0,0 +1,98 @@ +from typing import Generic +from _typeshed import Incomplete + +from networkx.classes.multidigraph import MultiDiGraph, _Node + +def branching_weight(G, attr: str = "weight", default: int = 1): ... +def greedy_branching( + G, + attr: str = "weight", + default: int = 1, + kind: str = "max", + seed: Incomplete | None = None, +): ... + +class MultiDiGraph_EdgeKey(MultiDiGraph[_Node], Generic[_Node]): + edge_index: Incomplete + def __init__( + self, incoming_graph_data: Incomplete | None = None, **attr + ) -> None: ... + def remove_node(self, n) -> None: ... + def remove_nodes_from(self, nbunch) -> None: ... + def add_edge(self, u_for_edge, v_for_edge, key_for_edge, **attr) -> None: ... + def add_edges_from(self, ebunch_to_add, **attr) -> None: ... + def remove_edge_with_key(self, key) -> None: ... + def remove_edges_from(self, ebunch) -> None: ... + +class Edmonds: + G_original: Incomplete + store: bool + edges: Incomplete + template: Incomplete + def __init__(self, G, seed: Incomplete | None = None) -> None: ... + def find_optimum( + self, + attr: str = "weight", + default: int = 1, + kind: str = "max", + style: str = "branching", + preserve_attrs: bool = False, + partition: Incomplete | None = None, + seed: Incomplete | None = None, + ): ... + +def maximum_branching( + G, + attr: str = "weight", + default: int = 1, + preserve_attrs: bool = False, + partition: Incomplete | None = None, +): ... +def minimum_branching( + G, + attr: str = "weight", + default: int = 1, + preserve_attrs: bool = False, + partition: Incomplete | None = None, +): ... +def maximum_spanning_arborescence( + G, + attr: str = "weight", + default: int = 1, + preserve_attrs: bool = False, + partition: Incomplete | None = None, +): ... +def minimum_spanning_arborescence( + G, + attr: str = "weight", + default: int = 1, + preserve_attrs: bool = False, + partition: Incomplete | None = None, +): ... + +class ArborescenceIterator: + class Partition: + mst_weight: float + partition_dict: dict[Incomplete, Incomplete] + def __copy__(self): ... + def __init__(self, mst_weight, partition_dict) -> None: ... + def __lt__(self, other): ... + def __gt__(self, other): ... + def __le__(self, other): ... + def __ge__(self, other): ... + G: Incomplete + weight: Incomplete + minimum: Incomplete + method: Incomplete + partition_key: str + init_partition: Incomplete + def __init__( + self, + G, + weight: str = "weight", + minimum: bool = True, + init_partition: Incomplete | None = None, + ) -> None: ... + partition_queue: Incomplete + def __iter__(self): ... + def __next__(self): ... diff --git a/stubs/networkx/networkx/algorithms/tree/coding.pyi b/stubs/networkx/networkx/algorithms/tree/coding.pyi new file mode 100644 index 000000000000..592518f98166 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/tree/coding.pyi @@ -0,0 +1,8 @@ +import networkx as nx + +class NotATree(nx.NetworkXException): ... + +def to_nested_tuple(T, root, canonical_form: bool = False): ... +def from_nested_tuple(sequence, sensible_relabeling: bool = False): ... +def to_prufer_sequence(T): ... +def from_prufer_sequence(sequence): ... diff --git a/stubs/networkx/networkx/algorithms/tree/decomposition.pyi b/stubs/networkx/networkx/algorithms/tree/decomposition.pyi new file mode 100644 index 000000000000..bbafb2a06dbb --- /dev/null +++ b/stubs/networkx/networkx/algorithms/tree/decomposition.pyi @@ -0,0 +1 @@ +def junction_tree(G): ... diff --git a/stubs/networkx/networkx/algorithms/tree/mst.pyi b/stubs/networkx/networkx/algorithms/tree/mst.pyi new file mode 100644 index 000000000000..38256c06012f --- /dev/null +++ b/stubs/networkx/networkx/algorithms/tree/mst.pyi @@ -0,0 +1,66 @@ +from _typeshed import Incomplete +from enum import Enum + +class EdgePartition(Enum): + OPEN: int + INCLUDED: int + EXCLUDED: int + +def minimum_spanning_edges( + G, + algorithm: str = "kruskal", + weight: str = "weight", + keys: bool = True, + data: bool = True, + ignore_nan: bool = False, +): ... +def maximum_spanning_edges( + G, + algorithm: str = "kruskal", + weight: str = "weight", + keys: bool = True, + data: bool = True, + ignore_nan: bool = False, +): ... +def minimum_spanning_tree( + G, weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False +): ... +def partition_spanning_tree( + G, + minimum: bool = True, + weight: str = "weight", + partition: str = "partition", + ignore_nan: bool = False, +): ... +def maximum_spanning_tree( + G, weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False +): ... +def random_spanning_tree( + G, + weight: Incomplete | None = None, + *, + multiplicative: bool = True, + seed: Incomplete | None = None +): ... + +class SpanningTreeIterator: + class Partition: + mst_weight: float + partition_dict: dict[Incomplete, Incomplete] + def __copy__(self): ... + def __init__(self, mst_weight, partition_dict) -> None: ... + def __lt__(self, other): ... + def __gt__(self, other): ... + def __le__(self, other): ... + def __ge__(self, other): ... + G: Incomplete + weight: Incomplete + minimum: Incomplete + ignore_nan: Incomplete + partition_key: str + def __init__( + self, G, weight: str = "weight", minimum: bool = True, ignore_nan: bool = False + ) -> None: ... + partition_queue: Incomplete + def __iter__(self): ... + def __next__(self): ... diff --git a/stubs/networkx/networkx/algorithms/tree/operations.pyi b/stubs/networkx/networkx/algorithms/tree/operations.pyi new file mode 100644 index 000000000000..c6e5dcf589c2 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/tree/operations.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +def join(rooted_trees, label_attribute: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/tree/recognition.pyi b/stubs/networkx/networkx/algorithms/tree/recognition.pyi new file mode 100644 index 000000000000..e73e010c2c96 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/tree/recognition.pyi @@ -0,0 +1,4 @@ +def is_arborescence(G): ... +def is_branching(G): ... +def is_forest(G): ... +def is_tree(G): ... diff --git a/stubs/networkx/networkx/algorithms/triads.pyi b/stubs/networkx/networkx/algorithms/triads.pyi new file mode 100644 index 000000000000..860f407d2381 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/triads.pyi @@ -0,0 +1,10 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def triadic_census(G, nodelist: Incomplete | None = None): ... +def is_triad(G): ... +def all_triplets(G): ... +def all_triads(G) -> Generator[Incomplete, None, None]: ... +def triads_by_type(G): ... +def triad_type(G): ... +def random_triad(G, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/vitality.pyi b/stubs/networkx/networkx/algorithms/vitality.pyi new file mode 100644 index 000000000000..001a49a491ba --- /dev/null +++ b/stubs/networkx/networkx/algorithms/vitality.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete + +def closeness_vitality( + G, + node: Incomplete | None = None, + weight: Incomplete | None = None, + wiener_index: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/voronoi.pyi b/stubs/networkx/networkx/algorithms/voronoi.pyi new file mode 100644 index 000000000000..bb79ac621f09 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/voronoi.pyi @@ -0,0 +1 @@ +def voronoi_cells(G, center_nodes, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/wiener.pyi b/stubs/networkx/networkx/algorithms/wiener.pyi new file mode 100644 index 000000000000..5cfbf599e755 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/wiener.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +def wiener_index(G, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/classes/__init__.pyi b/stubs/networkx/networkx/classes/__init__.pyi new file mode 100644 index 000000000000..2e2f6c0eca62 --- /dev/null +++ b/stubs/networkx/networkx/classes/__init__.pyi @@ -0,0 +1,13 @@ +from networkx.classes import ( + backends as backends, + coreviews as coreviews, + filters as filters, + graphviews as graphviews, + reportviews as reportviews, +) + +from .digraph import DiGraph as DiGraph +from .function import * +from .graph import Graph as Graph +from .multidigraph import MultiDiGraph as MultiDiGraph +from .multigraph import MultiGraph as MultiGraph diff --git a/stubs/networkx/networkx/classes/backends.pyi b/stubs/networkx/networkx/classes/backends.pyi new file mode 100644 index 000000000000..f47d2afb0793 --- /dev/null +++ b/stubs/networkx/networkx/classes/backends.pyi @@ -0,0 +1,11 @@ +class PluginInfo: + def __init__(self) -> None: ... + def __bool__(self) -> bool: ... + @property + def items(self): ... + def __contains__(self, name) -> bool: ... + def __getitem__(self, name): ... + +# Names in __all__ with no definition: +# _dispatch +# _mark_tests diff --git a/stubs/networkx/networkx/classes/coreviews.pyi b/stubs/networkx/networkx/classes/coreviews.pyi new file mode 100644 index 000000000000..e5184561753f --- /dev/null +++ b/stubs/networkx/networkx/classes/coreviews.pyi @@ -0,0 +1,64 @@ +from collections.abc import Callable, Iterator, Mapping +from typing import Generic, TypeVar + +from _typeshed import Incomplete, Self + +_T = TypeVar("_T") +_U = TypeVar("_U") +_V = TypeVar("_V") + +class AtlasView(Mapping[_T, dict[_U, _V]], Generic[_T, _U, _V]): + def __init__(self, d: Mapping[_T, dict[_U, _V]]) -> None: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[_T]: ... + def __getitem__(self, key: _T) -> dict[_U, _V]: ... + def copy(self: Self) -> Self: ... + +class AdjacencyView(AtlasView[_T, _U, _V], Generic[_T, _U, _V]): ... +class MultiAdjacencyView(AdjacencyView[_T, _U, _V], Generic[_T, _U, _V]): ... + +class UnionAtlas(Mapping[_T, dict[_U, _V]], Generic[_T, _U, _V]): + def __init__( + self, succ: AtlasView[_T, _U, _V], pred: AtlasView[_T, _U, _V] + ) -> None: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[_T]: ... + def __getitem__(self, key: _T) -> dict[_U, _V]: ... + def copy(self: Self) -> Self: ... + +class UnionAdjacency(Mapping[_T, dict[_U, _V]], Generic[_T, _U, _V]): + def __init__( + self, succ: AdjacencyView[_T, _U, _V], pred: AdjacencyView[_T, _U, _V] + ) -> None: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[_T]: ... + def __getitem__(self, key: _T) -> dict[_U, _V]: ... + def copy(self: Self) -> Self: ... + +class UnionMultiInner(UnionAtlas[_T, _U, _V], Generic[_T, _U, _V]): ... +class UnionMultiAdjacency(UnionAdjacency[_T, _U, _V], Generic[_T, _U, _V]): ... + +class FilterAtlas(Mapping[_T, _U], Generic[_T, _U]): + NODE_OK: Callable[[_T], bool] + def __init__(self, d: Mapping[_T, _U], NODE_OK: Callable[[_T], bool]) -> None: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[_T]: ... + def __getitem__(self, key: _T) -> _U: ... + def copy(self: Self) -> Self: ... + +class FilterAdjacency(Mapping[_T, Mapping[_U, _V]], Generic[_T, _U, _V]): + NODE_OK: Callable[[_T], bool] + EDGE_OK: Callable[[_T, _T], bool] + def __init__( + self, + d: Mapping[_T, Mapping[_U, _V]], + NODE_OK: Callable[[_T], bool], + EDGE_OK: Callable[[_T, _T], bool], + ) -> None: ... + def __len__(self) -> Incomplete: ... + def __iter__(self) -> Incomplete: ... + def __getitem__(self, node: _T) -> FilterAtlas[_U, _V]: ... + def copy(self: Self) -> Self: ... + +class FilterMultiInner(FilterAdjacency[_T, _U, _V], Generic[_T, _U, _V]): ... +class FilterMultiAdjacency(FilterAdjacency[_T, _U, _V], Generic[_T, _U, _V]): ... diff --git a/stubs/networkx/networkx/classes/digraph.pyi b/stubs/networkx/networkx/classes/digraph.pyi new file mode 100644 index 000000000000..abae4f946bc0 --- /dev/null +++ b/stubs/networkx/networkx/classes/digraph.pyi @@ -0,0 +1,32 @@ +from collections.abc import Iterator +from typing import Generic +from _typeshed import Incomplete + +from networkx.classes.coreviews import AdjacencyView +from networkx.classes.graph import Graph, _Node +from networkx.classes.reportviews import ( + InDegreeView, + InEdgeView, + InMultiDegreeView, + OutDegreeView, + OutEdgeView, + OutMultiDegreeView, +) + +class DiGraph(Graph[_Node], Generic[_Node]): + succ: AdjacencyView[_Node, _Node, dict[str, Incomplete]] + pred: AdjacencyView[_Node, _Node, dict[str, Incomplete]] + 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]: ... + def predecessors(self, n: _Node) -> Iterator[_Node]: ... + in_edges: InEdgeView[_Node] + in_degree: InDegreeView[_Node] | InMultiDegreeView[ + _Node + ] # ugly hack to make MultiDiGraph work + out_edges: OutEdgeView[_Node] + out_degree: OutDegreeView[_Node] | OutMultiDegreeView[ + _Node + ] # ugly hack to make MultiDiGraph work + def reverse(self, copy: bool = ...) -> DiGraph[_Node]: ... + def copy(self, as_view: bool = ...) -> DiGraph[_Node]: ... diff --git a/stubs/networkx/networkx/classes/filters.pyi b/stubs/networkx/networkx/classes/filters.pyi new file mode 100644 index 000000000000..0d8e26af83cc --- /dev/null +++ b/stubs/networkx/networkx/classes/filters.pyi @@ -0,0 +1,18 @@ +from _typeshed import Incomplete + +def no_filter(*items): ... +def hide_nodes(nodes): ... +def hide_diedges(edges): ... +def hide_edges(edges): ... +def hide_multidiedges(edges): ... +def hide_multiedges(edges): ... + +class show_nodes: + nodes: Incomplete + def __init__(self, nodes) -> None: ... + def __call__(self, node): ... + +def show_diedges(edges): ... +def show_edges(edges): ... +def show_multidiedges(edges): ... +def show_multiedges(edges): ... diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi new file mode 100644 index 000000000000..3c99e00aa420 --- /dev/null +++ b/stubs/networkx/networkx/classes/function.pyi @@ -0,0 +1,114 @@ +from collections.abc import Iterable +from typing import Any, TypeVar, overload + +from _typeshed import Incomplete +from networkx.classes.graph import Graph +from typing_extensions import Literal + +_T = TypeVar("_T") +_U = TypeVar("_U") + +def nodes(G: Incomplete) -> Incomplete: ... +def edges(G: Incomplete, nbunch: Incomplete | None = ...) -> Incomplete: ... +def degree( + G: Incomplete, nbunch: Incomplete | None = ..., weight: Incomplete | None = ... +) -> Incomplete: ... +def neighbors(G: Incomplete, n: Incomplete) -> Incomplete: ... +def number_of_nodes(G: Incomplete) -> Incomplete: ... +def number_of_edges(G: Incomplete) -> Incomplete: ... +def density(G: Incomplete) -> Incomplete: ... +def degree_histogram(G: Incomplete) -> Incomplete: ... +def is_directed(G: Incomplete) -> Incomplete: ... +def freeze(G: Incomplete) -> Incomplete: ... +def is_frozen(G: Incomplete) -> Incomplete: ... +def add_star( + G_to_add_to: Incomplete, nodes_for_star: Incomplete, **attr: Incomplete +) -> None: ... +def add_path( + G_to_add_to: Incomplete, nodes_for_path: Incomplete, **attr: Incomplete +) -> None: ... +def add_cycle( + G_to_add_to: Incomplete, nodes_for_cycle: Incomplete, **attr: Incomplete +) -> None: ... +def subgraph(G: Incomplete, nbunch: Incomplete) -> Incomplete: ... +def induced_subgraph(G: Graph[_T], nbunch: _T | Iterable[_T] | None) -> Graph[_T]: ... +def edge_subgraph(G: Incomplete, edges: Incomplete) -> Incomplete: ... +def restricted_view( + G: Incomplete, nodes: Incomplete, edges: Incomplete +) -> Incomplete: ... +def reverse_view(digraph: Incomplete) -> Incomplete: ... +def to_directed(graph: Incomplete) -> Incomplete: ... +def to_undirected(graph: Incomplete) -> Incomplete: ... +def create_empty_copy(G: Incomplete, with_data: bool = ...) -> Incomplete: ... +def info(G: Incomplete, n: Incomplete | None = ...) -> Incomplete: ... +@overload +def set_node_attributes( + G: Graph[_T], values: dict[_T, Incomplete], name: str = ... +) -> None: ... + +# Can "Any scalar value" be enforced? +@overload +def set_node_attributes(G: Graph[Any], values: Incomplete, name: str = ...) -> None: ... +@overload +def set_node_attributes( + G: Graph[_T], values: dict[_T, dict[Incomplete, Incomplete]], name: None = ... +) -> None: ... +def get_node_attributes(G: Graph[_T], name: str) -> dict[_T, Incomplete]: ... +@overload +def set_edge_attributes( + G: Graph[_T], values: dict[tuple[_T, _T], Incomplete], name: str = ... +) -> None: ... +@overload +def set_edge_attributes( + G: Graph[Any], values: Incomplete, name: None = ... +) -> None: ... +def get_edge_attributes(G: Graph[_T], name: str) -> dict[tuple[_T, _T], Incomplete]: ... +def all_neighbors(graph: Graph[_T], node: _T) -> Iterable[_T]: ... +def non_neighbors(graph: Graph[_T], node: _T) -> Iterable[_T]: ... +def non_edges(graph: Graph[_T]) -> Iterable[tuple[_T, _T]]: ... +def common_neighbors(G: Graph[_T], u: _T, v: _T) -> Iterable[_T]: ... +def is_weighted( + G: Graph[_T], edge: tuple[_T, _T] | None = ..., weight: str | None = ... +) -> bool: ... +def is_negatively_weighted( + G: Graph[_T], edge: tuple[_T, _T] | None = ..., weight: str | None = ... +) -> Incomplete: ... +def is_empty(G: Graph[Any]) -> bool: ... +def nodes_with_selfloops(G: Graph[_T]) -> Iterable[_T]: ... +@overload +def selfloop_edges( + G: Graph[_T], + data: Literal[False] = ..., + keys: Literal[False] = ..., + default: Incomplete = ..., +) -> Iterable[tuple[_T, _T]]: ... +@overload +def selfloop_edges( + G: Graph[_T], + data: Literal[True] = ..., + keys: Literal[False] = ..., + default: Incomplete = ..., +) -> Iterable[tuple[_T, _T, dict[str, Incomplete]]]: ... +@overload +def selfloop_edges( + G: Graph[_T], data: str = ..., keys: Literal[False] = ..., default: _U | None = None +) -> Iterable[tuple[_T, _T, _U]]: ... +@overload +def selfloop_edges( + G: Graph[_T], + data: Literal[False] = ..., + keys: Literal[True] = ..., + default: Incomplete = ..., +) -> Iterable[tuple[_T, _T, int]]: ... +@overload +def selfloop_edges( + G: Graph[_T], + data: Literal[True] = ..., + keys: Literal[True] = ..., + default: Incomplete = ..., +) -> Iterable[tuple[_T, _T, int, dict[str, Incomplete]]]: ... +@overload +def selfloop_edges( + G: Graph[_T], data: str = ..., keys: Literal[True] = ..., default: _U | None = None +) -> Iterable[tuple[_T, _T, int, _U]]: ... +def number_of_selfloops(G: Graph[Any]) -> int: ... diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi new file mode 100644 index 000000000000..e09ead48a71a --- /dev/null +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -0,0 +1,106 @@ +from collections.abc import ( + Callable, + Collection, + Hashable, + Iterable, + Iterator, + Mapping, + MutableMapping, +) +from typing import ClassVar, Generic, TypeVar, overload + +from _typeshed import Self, Incomplete +from networkx.classes.coreviews import AdjacencyView +from networkx.classes.digraph import DiGraph +from networkx.classes.reportviews import DiDegreeView, NodeView, OutEdgeView +from networkx.convert import _Data +from typing_extensions import TypeAlias + +_Node = TypeVar("_Node", bound=Hashable) +Edge: TypeAlias = tuple[_Node, _Node] +EdgePlus: TypeAlias = Edge[_Node] | tuple[_Node, _Node, dict[str, Incomplete]] +MapFactory: TypeAlias = Callable[[], MutableMapping[str, Incomplete]] +NBunch: TypeAlias = None | _Node | Iterable[_Node] + +class Graph(Collection[_Node], Generic[_Node]): + node_dict_factory: ClassVar[MapFactory] = ... + node_attr_dict_factory: ClassVar[MapFactory] = ... + adjlist_outer_dict_factory: ClassVar[MapFactory] = ... + adjlist_inner_dict_factory: ClassVar[MapFactory] = ... + edge_attr_dict_factory: ClassVar[MapFactory] = ... + graph_attr_dict_factory: ClassVar[MapFactory] = ... + + def to_directed_class(self) -> type[DiGraph[_Node]]: ... + def to_undirected_class(self) -> type[Graph[_Node]]: ... + def __init__( + self, incoming_graph_data: _Data[_Node] | None = None, **attr: Incomplete + ) -> None: ... + + adj: AdjacencyView[_Node, _Node, dict[str, Incomplete]] + name: str + + def __getitem__(self, n: _Node) -> MutableMapping[Hashable, Incomplete]: ... + def __iter__(self) -> Iterator[_Node]: ... + def __contains__(self, n: object) -> bool: ... + def __len__(self) -> int: ... + def add_node(self, node_for_adding: _Node, **attr: Incomplete) -> None: ... + def add_nodes_from( + self, + nodes_for_adding: Iterable[_Node | tuple[_Node, dict[str, Incomplete]]], + **attr: Incomplete + ) -> None: ... + def remove_node(self, n: _Node) -> None: ... + def remove_nodes_from(self, nodes: Iterable[_Node]) -> None: ... + nodes: NodeView[_Node] + def number_of_nodes(self) -> int: ... + def order(self) -> int: ... + def has_node(self, n: _Node) -> bool: ... + def add_edge( + self, u_of_edge: _Node, v_of_edge: _Node, **attr: Incomplete + ) -> None: ... + def add_edges_from( + self, ebunch_to_add: Iterable[EdgePlus[_Node]], **attr: Incomplete + ) -> None: ... + def add_weighted_edges_from( + self, + ebunch_to_add: Iterable[tuple[_Node, _Node, Incomplete]], + weight: str = ..., + **attr: Incomplete + ) -> None: ... + def remove_edge(self, u: _Node, v: _Node) -> None: ... + def remove_edges_from(self, ebunch: Iterable[EdgePlus[_Node]]) -> None: ... + @overload + def update(self, edges: Graph[_Node], nodes: None = None) -> None: ... + @overload + def update( + self, + edges: Graph[_Node] | Iterable[EdgePlus[_Node]] | None = ..., + nodes: Iterable[_Node] | None = ..., + ) -> None: ... + def has_edge(self, u: _Node, v: _Node) -> bool: ... + def neighbors(self, n: _Node) -> Iterable[_Node]: ... + edges: OutEdgeView[_Node] + def get_edge_data( + self, u: _Node, v: _Node, default: Incomplete = ... + ) -> Mapping[str, Incomplete]: ... + def adjacency( + self, + ) -> Iterable[tuple[_Node, Mapping[_Node, Mapping[str, Incomplete]]]]: ... + + degree: DiDegreeView[_Node] + + def clear(self) -> None: ... + def clear_edges(self) -> None: ... + def is_multigraph(self) -> bool: ... + def is_directed(self) -> bool: ... + def copy(self: Self, as_view: bool = ...) -> Self: ... + def to_directed(self, as_view: bool = ...) -> DiGraph[_Node]: ... + def to_undirected(self, as_view: bool = ...) -> 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 = ...) -> int: ... + @overload + def size(self, weight: str) -> float: ... + def number_of_edges(self, u: _Node | None = ..., v: _Node | None = ...) -> int: ... + def nbunch_iter(self, nbunch: NBunch[_Node] = ...) -> Iterable[_Node]: ... diff --git a/stubs/networkx/networkx/classes/graphviews.pyi b/stubs/networkx/networkx/classes/graphviews.pyi new file mode 100644 index 000000000000..0774936b89c7 --- /dev/null +++ b/stubs/networkx/networkx/classes/graphviews.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def generic_graph_view(G, create_using: Incomplete | None = None): ... +def subgraph_view(G, filter_node=..., filter_edge=...): ... +def reverse_view(G): ... diff --git a/stubs/networkx/networkx/classes/multidigraph.pyi b/stubs/networkx/networkx/classes/multidigraph.pyi new file mode 100644 index 000000000000..1b15ec408150 --- /dev/null +++ b/stubs/networkx/networkx/classes/multidigraph.pyi @@ -0,0 +1,16 @@ +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import _Node +from networkx.classes.multigraph import MultiGraph +from networkx.classes.reportviews import ( + InMultiDegreeView, + MultiDegreeView, + OutMultiDegreeView, +) + +class MultiDiGraph(MultiGraph[_Node], DiGraph[_Node]): + degree: MultiDegreeView[_Node] + in_degree: InMultiDegreeView[_Node] + out_degree: OutMultiDegreeView[_Node] + def to_undirected(self, reciprocal: bool = ..., as_view: bool = ...) -> MultiGraph[_Node]: ... # type: ignore + def reverse(self, copy: bool = ...) -> MultiDiGraph[_Node]: ... + def copy(self, as_view: bool = ...) -> MultiDiGraph[_Node]: ... diff --git a/stubs/networkx/networkx/classes/multigraph.pyi b/stubs/networkx/networkx/classes/multigraph.pyi new file mode 100644 index 000000000000..088662fe9a4d --- /dev/null +++ b/stubs/networkx/networkx/classes/multigraph.pyi @@ -0,0 +1,11 @@ +from typing import Generic + +from networkx.classes.graph import Graph, _Node +from networkx.classes.multidigraph import MultiDiGraph + +class MultiGraph(Graph[_Node], Generic[_Node]): + def new_edge_key(self, u: _Node, v: _Node) -> int: ... + def copy(self, as_view: bool = ...) -> MultiGraph[_Node]: ... + def to_directed(self, as_view: bool = ...) -> MultiDiGraph[_Node]: ... + def to_undirected(self, as_view: bool = ...) -> MultiGraph[_Node]: ... + def number_of_edges(self, u: _Node | None = ..., v: _Node | None = ...) -> int: ... diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi new file mode 100644 index 000000000000..44548196b080 --- /dev/null +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -0,0 +1,121 @@ +from collections.abc import Iterator +from typing import Generic, TypeVar, overload + +from _typeshed import Incomplete +from networkx.classes.graph import Edge, Graph, NBunch, _Node +from typing_extensions import Literal + +_D = TypeVar("_D") +_U = TypeVar("_U") + +class NodeView(Generic[_Node]): + def __init__(self, graph: Graph[_Node]) -> None: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[_Node]: ... + def __getitem__(self, n: _Node) -> _Node: ... + def __contains__(self, n: object) -> bool: ... + @overload + def __call__( + self, data: Literal[False] = ..., default: Incomplete = ... + ) -> NodeView[_Node]: ... + @overload + def __call__( + self, data: Literal[True] | str, default: Incomplete = ... + ) -> NodeDataView[_Node]: ... + def data( + self, data: bool | str = ..., default: Incomplete = ... + ) -> NodeDataView[_Node]: ... + +class NodeDataView(Generic[_Node]): + def __init__( + self, + nodedict: dict[str, Incomplete], + data: bool | str = ..., + default: Incomplete = ..., + ) -> None: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[tuple[_Node, Incomplete]]: ... + def __contains__(self, n: _Node) -> bool: ... + def __getitem__(self, n: _Node) -> Incomplete: ... + +class DiDegreeView(Generic[_Node]): + def __init__( + self, + G: Graph[_Node], + nbunch: NBunch[_Node] = ..., + weight: None | bool | str = ..., + ) -> None: ... + def __call__( + self, nbunch: NBunch[_Node] = ..., weight: None | bool | str = ... + ) -> DiDegreeView[_Node]: ... + def __getitem__(self, n: _Node) -> float: ... + def __iter__(self) -> Iterator[tuple[_Node, float]]: ... + def __len__(self) -> int: ... + +class DegreeView(DiDegreeView[_Node], Generic[_Node]): ... +class OutDegreeView(DiDegreeView[_Node], Generic[_Node]): ... +class InDegreeView(DiDegreeView[_Node], Generic[_Node]): ... +class MultiDegreeView(DiDegreeView[_Node], Generic[_Node]): ... +class DiMultiDegreeView(DiDegreeView[_Node], Generic[_Node]): ... +class InMultiDegreeView(DiDegreeView[_Node], Generic[_Node]): ... +class OutMultiDegreeView(DiDegreeView[_Node], Generic[_Node]): ... + +class OutEdgeDataView(Generic[_Node, _D]): + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[_D]: ... + def __contains__(self, e: Edge[_Node]) -> bool: ... + +class EdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): ... +class InEdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): ... +class OutMultiEdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): ... +class MultiEdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): ... +class InMultiEdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): ... + +class OutEdgeView(Generic[_Node]): + def __init__(self, graph: Graph[_Node]) -> None: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[tuple[_Node, _Node]]: ... + def __contains__(self, e: Edge[_Node]) -> bool: ... + def __getitem__(self, e: Edge[_Node]) -> dict[str, Incomplete]: ... + @overload + def __call__( + self, + nbunch: NBunch[_Node] = ..., + data: Literal[False] = ..., + default: Incomplete = ..., + ) -> OutEdgeView[_Node]: ... + @overload + def __call__( + self, + nbunch: NBunch[_Node] = ..., + data: Literal[True] = ..., + default: Incomplete = ..., + ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... + @overload + def __call__( + self, nbunch: NBunch[_Node] = ..., data: str = ..., default: _U | None = None + ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... + @overload + def data( + self, + data: Literal[False] = ..., + default: Incomplete = ..., + nbunch: NBunch[_Node] = ..., + ) -> OutEdgeView[_Node]: ... + @overload + def data( + self, + data: Literal[True] = ..., + default: Incomplete = ..., + nbunch: NBunch[_Node] = ..., + ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... + @overload + def data( + self, data: str = ..., default: _U | None = None, nbunch: NBunch[_Node] = ... + ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... + +class EdgeView(OutEdgeView[_Node], Generic[_Node]): ... +class InEdgeView(OutEdgeView[_Node], Generic[_Node]): ... +class OutMultiEdgeView(OutEdgeView[_Node], Generic[_Node]): ... +class MultiEdgeView(OutMultiEdgeView[_Node], Generic[_Node]): ... +class InMultiEdgeView(OutMultiEdgeView[_Node], Generic[_Node]): ... diff --git a/stubs/networkx/networkx/convert.pyi b/stubs/networkx/networkx/convert.pyi new file mode 100644 index 000000000000..7acd905eaee7 --- /dev/null +++ b/stubs/networkx/networkx/convert.pyi @@ -0,0 +1,18 @@ +from collections.abc import Iterable + +import numpy +from _typeshed import Incomplete + +# import scipy +from networkx.classes.graph import EdgePlus, Graph, _Node +from typing_extensions import TypeAlias + +# this is imported from other stub files +_Data: TypeAlias = ( # noqa: Y047 + Graph[_Node] + | dict[_Node, dict[_Node, dict[str, Incomplete]]] + | dict[_Node, Iterable[_Node]] + | Iterable[EdgePlus[_Node]] + | numpy.ndarray[_Node, Incomplete] + # | scipy.sparse.base.spmatrix +) diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi new file mode 100644 index 000000000000..773a726efaff --- /dev/null +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -0,0 +1,50 @@ +from collections.abc import Callable, Iterable +from _typeshed import Incomplete + +import numpy +from networkx.classes.graph import Graph, _Node +from pandas import DataFrame +from pandas.core.dtypes.base import ExtensionDtype +from typing_extensions import Literal + +def to_pandas_adjacency( + G: Graph[_Node], + nodelist: list[_Node] | None = ..., + dtype: numpy.dtype[Incomplete] | None = ..., + order: Literal["C", "F"] | None = ..., + multigraph_weight: Callable[[Iterable[float]], float] = ..., + weight: str = ..., + nonedge: float = ..., +) -> DataFrame: ... +def from_pandas_adjacency( + df: DataFrame, create_using: type[Graph[Incomplete]] = ... +) -> Graph[Incomplete]: ... +def to_pandas_edgelist( + G: Graph[_Node], + source: str | int = ..., + target: str | int = ..., + nodelist: list[_Node] | None = ..., + dtype: ExtensionDtype | None = ..., + edge_key: str | int | None = ..., +) -> DataFrame: ... +def from_pandas_edgelist( + df: DataFrame, + source: str | int = ..., + target: str | int = ..., + edge_attr: str | int | Iterable[str | int] | Literal[True] | None = ..., + create_using: type[Graph[Incomplete]] = ..., +) -> Graph[Incomplete]: ... +def to_numpy_array( + G: Graph[_Node], + nodelist: list[_Node] | None = ..., + dtype: numpy.dtype[Incomplete] | None = ..., + order: Literal["C", "F"] | None = ..., + multigraph_weight: Callable[[Iterable[float]], float] = ..., + weight: str = ..., + nonedge: float = ..., +) -> numpy.ndarray[Incomplete, numpy.dtype[Incomplete]]: ... +def from_numpy_array( + A: numpy.ndarray[Incomplete, Incomplete], + parallel_edges: bool = ..., + create_using: type[Graph[Incomplete]] = ..., +) -> Graph[Incomplete]: ... diff --git a/stubs/networkx/networkx/drawing/__init__.pyi b/stubs/networkx/networkx/drawing/__init__.pyi new file mode 100644 index 000000000000..ce16049ef6fa --- /dev/null +++ b/stubs/networkx/networkx/drawing/__init__.pyi @@ -0,0 +1,4 @@ +from . import nx_agraph as nx_agraph, nx_pydot as nx_pydot +from .layout import * +from .nx_latex import * +from .nx_pylab import * diff --git a/stubs/networkx/networkx/drawing/layout.pyi b/stubs/networkx/networkx/drawing/layout.pyi new file mode 100644 index 000000000000..3786ad937ad6 --- /dev/null +++ b/stubs/networkx/networkx/drawing/layout.pyi @@ -0,0 +1,85 @@ +from _typeshed import Incomplete + +def random_layout( + G, center: Incomplete | None = None, dim: int = 2, seed: Incomplete | None = None +): ... +def circular_layout( + G, scale: int = 1, center: Incomplete | None = None, dim: int = 2 +): ... +def shell_layout( + G, + nlist: Incomplete | None = None, + rotate: Incomplete | None = None, + scale: int = 1, + center: Incomplete | None = None, + dim: int = 2, +): ... +def bipartite_layout( + G, + nodes, + align: str = "vertical", + scale: int = 1, + center: Incomplete | None = None, + aspect_ratio: float = ..., +): ... +def spring_layout( + G, + k: Incomplete | None = None, + pos: Incomplete | None = None, + fixed: Incomplete | None = None, + iterations: int = 50, + threshold: float = 0.0001, + weight: str = "weight", + scale: int = 1, + center: Incomplete | None = None, + dim: int = 2, + seed: Incomplete | None = None, +): ... + +fruchterman_reingold_layout = spring_layout + +def kamada_kawai_layout( + G, + dist: Incomplete | None = None, + pos: Incomplete | None = None, + weight: str = "weight", + scale: int = 1, + center: Incomplete | None = None, + dim: int = 2, +): ... +def spectral_layout( + G, + weight: str = "weight", + scale: int = 1, + center: Incomplete | None = None, + dim: int = 2, +): ... +def planar_layout( + G, scale: int = 1, center: Incomplete | None = None, dim: int = 2 +): ... +def spiral_layout( + G, + scale: int = 1, + center: Incomplete | None = None, + dim: int = 2, + resolution: float = 0.35, + equidistant: bool = False, +): ... +def multipartite_layout( + G, + subset_key: str = "subset", + align: str = "vertical", + scale: int = 1, + center: Incomplete | None = None, +): ... +def arf_layout( + G, + pos: Incomplete | None = None, + scaling: int = 1, + a: float = 1.1, + etol: float = 1e-06, + dt: float = 0.001, + max_iter: int = 1000, +): ... +def rescale_layout(pos, scale: int = 1): ... +def rescale_layout_dict(pos, scale: int = 1): ... diff --git a/stubs/networkx/networkx/drawing/nx_agraph.pyi b/stubs/networkx/networkx/drawing/nx_agraph.pyi new file mode 100644 index 000000000000..7738d069a41e --- /dev/null +++ b/stubs/networkx/networkx/drawing/nx_agraph.pyi @@ -0,0 +1,34 @@ +from collections.abc import Callable +from io import TextIOBase +from typing import Any, TypeVar + +from _typeshed import Incomplete +from typing_extensions import TypeAlias + +from networkx.classes.graph import Graph + +# from pygraphviz.agraph import AGraph as _AGraph + +_AGraph: TypeAlias = Incomplete +_T = TypeVar("_T") + +def from_agraph( + A: Incomplete, create_using: Incomplete | None = ... +) -> Graph[Incomplete]: ... +def to_agraph(N: Graph[Any]) -> _AGraph: ... +def write_dot(G: Graph[Any], path: str | TextIOBase) -> None: ... +def read_dot(path: str | TextIOBase) -> Graph[Incomplete]: ... +def graphviz_layout( + G: Graph[_T], prog: str = ..., root: str | None = ..., args: str = ... +) -> dict[_T, tuple[float, float]]: ... + +pygraphviz_layout = graphviz_layout + +def view_pygraphviz( + G: Graph[_T], + edgelabel: str | Callable[[_T], str] | None = ..., + prog: str = ..., + args: str = ..., + suffix: str = ..., + path: str | None = ..., +) -> Incomplete: ... diff --git a/stubs/networkx/networkx/drawing/nx_latex.pyi b/stubs/networkx/networkx/drawing/nx_latex.pyi new file mode 100644 index 000000000000..ae19dd148b76 --- /dev/null +++ b/stubs/networkx/networkx/drawing/nx_latex.pyi @@ -0,0 +1,36 @@ +from _typeshed import Incomplete + +def to_latex_raw( + G, + pos: str = "pos", + tikz_options: str = "", + default_node_options: str = "", + node_options: str = "node_options", + node_label: str = "label", + default_edge_options: str = "", + edge_options: str = "edge_options", + edge_label: str = "label", + edge_label_options: str = "edge_label_options", +): ... +def to_latex( + Gbunch, + pos: str = "pos", + tikz_options: str = "", + default_node_options: str = "", + node_options: str = "node_options", + node_label: str = "node_label", + default_edge_options: str = "", + edge_options: str = "edge_options", + edge_label: str = "edge_label", + edge_label_options: str = "edge_label_options", + caption: str = "", + latex_label: str = "", + sub_captions: Incomplete | None = None, + sub_labels: Incomplete | None = None, + n_rows: int = 1, + as_document: bool = True, + document_wrapper: str = ..., + figure_wrapper: str = ..., + subfigure_wrapper: str = ..., +): ... +def write_latex(Gbunch, path, **options) -> None: ... diff --git a/stubs/networkx/networkx/drawing/nx_pydot.pyi b/stubs/networkx/networkx/drawing/nx_pydot.pyi new file mode 100644 index 000000000000..bdd3931ef53d --- /dev/null +++ b/stubs/networkx/networkx/drawing/nx_pydot.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete + +def write_dot(G, path) -> None: ... +def read_dot(path): ... +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): ... diff --git a/stubs/networkx/networkx/drawing/nx_pylab.pyi b/stubs/networkx/networkx/drawing/nx_pylab.pyi new file mode 100644 index 000000000000..3c7e74b2c74f --- /dev/null +++ b/stubs/networkx/networkx/drawing/nx_pylab.pyi @@ -0,0 +1,91 @@ +from _typeshed import Incomplete + +def draw( + G, 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 +) -> None: ... +def draw_networkx_nodes( + G, + pos, + nodelist: Incomplete | None = None, + node_size: 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, +): ... +def draw_networkx_edges( + G, + pos, + edgelist: Incomplete | None = None, + width: float = 1.0, + edge_color: str = "k", + style: str = "solid", + alpha: Incomplete | None = None, + arrowstyle: Incomplete | None = None, + arrowsize: int = 10, + edge_cmap: Incomplete | None = None, + edge_vmin: Incomplete | None = None, + edge_vmax: Incomplete | None = None, + ax: Incomplete | None = None, + arrows: Incomplete | None = None, + label: Incomplete | None = None, + node_size: int = 300, + nodelist: Incomplete | None = None, + node_shape: str = "o", + connectionstyle: str = "arc3", + min_source_margin: int = 0, + min_target_margin: int = 0, +): ... +def draw_networkx_labels( + G, + pos, + labels: Incomplete | None = 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, + horizontalalignment: str = "center", + verticalalignment: str = "center", + ax: Incomplete | None = None, + clip_on: bool = True, +): ... +def draw_networkx_edge_labels( + G, + pos, + edge_labels: Incomplete | None = 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, + horizontalalignment: str = "center", + verticalalignment: str = "center", + ax: Incomplete | None = None, + rotate: bool = True, + clip_on: 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: ... diff --git a/stubs/networkx/networkx/exception.pyi b/stubs/networkx/networkx/exception.pyi new file mode 100644 index 000000000000..ab6a0e2e0c26 --- /dev/null +++ b/stubs/networkx/networkx/exception.pyi @@ -0,0 +1,16 @@ +class NetworkXException(Exception): ... +class NetworkXError(NetworkXException): ... +class NetworkXPointlessConcept(NetworkXException): ... +class NetworkXAlgorithmError(NetworkXException): ... +class NetworkXUnfeasible(NetworkXAlgorithmError): ... +class NetworkXNoPath(NetworkXUnfeasible): ... +class NetworkXNoCycle(NetworkXUnfeasible): ... +class HasACycle(NetworkXException): ... +class NetworkXUnbounded(NetworkXAlgorithmError): ... +class NetworkXNotImplemented(NetworkXException): ... +class NodeNotFound(NetworkXException): ... +class AmbiguousSolution(NetworkXException): ... +class ExceededMaxIterations(NetworkXException): ... + +class PowerIterationFailedConvergence(ExceededMaxIterations): + def __init__(self, num_iterations, *args, **kw) -> None: ... diff --git a/stubs/networkx/networkx/generators/__init__.pyi b/stubs/networkx/networkx/generators/__init__.pyi new file mode 100644 index 000000000000..c19ff74b7229 --- /dev/null +++ b/stubs/networkx/networkx/generators/__init__.pyi @@ -0,0 +1,27 @@ +from networkx.generators.atlas import * +from networkx.generators.classic import * +from networkx.generators.cographs import * +from networkx.generators.community import * +from networkx.generators.degree_seq import * +from networkx.generators.directed import * +from networkx.generators.duplication import * +from networkx.generators.ego import * +from networkx.generators.expanders import * +from networkx.generators.geometric import * +from networkx.generators.internet_as_graphs import * +from networkx.generators.intersection import * +from networkx.generators.interval_graph import * +from networkx.generators.joint_degree_seq import * +from networkx.generators.lattice import * +from networkx.generators.line import * +from networkx.generators.mycielski import * +from networkx.generators.nonisomorphic_trees import * +from networkx.generators.random_clustered import * +from networkx.generators.random_graphs import * +from networkx.generators.small import * +from networkx.generators.social import * +from networkx.generators.spectral_graph_forge import * +from networkx.generators.stochastic import * +from networkx.generators.sudoku import * +from networkx.generators.trees import * +from networkx.generators.triads import * diff --git a/stubs/networkx/networkx/generators/atlas.pyi b/stubs/networkx/networkx/generators/atlas.pyi new file mode 100644 index 000000000000..568996e5cb8d --- /dev/null +++ b/stubs/networkx/networkx/generators/atlas.pyi @@ -0,0 +1,2 @@ +def graph_atlas(i): ... +def graph_atlas_g(): ... diff --git a/stubs/networkx/networkx/generators/classic.pyi b/stubs/networkx/networkx/generators/classic.pyi new file mode 100644 index 000000000000..26e7a87062b2 --- /dev/null +++ b/stubs/networkx/networkx/generators/classic.pyi @@ -0,0 +1,21 @@ +from _typeshed import Incomplete + +def full_rary_tree(r, n, create_using: Incomplete | None = None): ... +def balanced_tree(r, h, create_using: Incomplete | None = None): ... +def barbell_graph(m1, m2, create_using: Incomplete | None = None): ... +def binomial_tree(n, create_using: Incomplete | None = None): ... +def complete_graph(n, create_using: Incomplete | None = None): ... +def circular_ladder_graph(n, create_using: Incomplete | None = None): ... +def circulant_graph(n, offsets, create_using: Incomplete | None = None): ... +def cycle_graph(n, create_using: Incomplete | None = None): ... +def dorogovtsev_goltsev_mendes_graph(n, create_using: Incomplete | None = None): ... +def empty_graph(n: int = 0, create_using: Incomplete | None = None, default=...): ... +def ladder_graph(n, create_using: Incomplete | None = None): ... +def lollipop_graph(m, n, create_using: Incomplete | None = None): ... +def null_graph(create_using: Incomplete | None = None): ... +def path_graph(n, create_using: Incomplete | None = None): ... +def star_graph(n, create_using: Incomplete | None = None): ... +def trivial_graph(create_using: Incomplete | None = None): ... +def turan_graph(n, r): ... +def wheel_graph(n, create_using: Incomplete | None = None): ... +def complete_multipartite_graph(*subset_sizes): ... diff --git a/stubs/networkx/networkx/generators/cographs.pyi b/stubs/networkx/networkx/generators/cographs.pyi new file mode 100644 index 000000000000..148b1e7256c6 --- /dev/null +++ b/stubs/networkx/networkx/generators/cographs.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +def random_cograph(n, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/community.pyi b/stubs/networkx/networkx/generators/community.pyi new file mode 100644 index 000000000000..76fa14c13561 --- /dev/null +++ b/stubs/networkx/networkx/generators/community.pyi @@ -0,0 +1,39 @@ +from _typeshed import Incomplete + +def caveman_graph(l, k): ... +def connected_caveman_graph(l, k): ... +def relaxed_caveman_graph(l, k, p, seed: Incomplete | None = None): ... +def random_partition_graph( + sizes, p_in, p_out, seed: Incomplete | None = None, directed: bool = False +): ... +def planted_partition_graph( + l, k, p_in, p_out, seed: Incomplete | None = None, directed: bool = False +): ... +def gaussian_random_partition_graph( + n, s, v, p_in, p_out, directed: bool = False, seed: Incomplete | None = None +): ... +def ring_of_cliques(num_cliques, clique_size): ... +def windmill_graph(n, k): ... +def stochastic_block_model( + sizes, + p, + nodelist: Incomplete | None = None, + seed: Incomplete | None = None, + directed: bool = False, + selfloops: bool = False, + sparse: bool = True, +): ... +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, + 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 new file mode 100644 index 000000000000..a5e6e73f71a3 --- /dev/null +++ b/stubs/networkx/networkx/generators/degree_seq.pyi @@ -0,0 +1,39 @@ +from _typeshed import Incomplete + +def configuration_model( + deg_sequence, create_using: Incomplete | None = None, seed: Incomplete | None = None +): ... +def directed_configuration_model( + in_degree_sequence, + out_degree_sequence, + create_using: Incomplete | None = None, + seed: Incomplete | None = None, +): ... +def expected_degree_graph( + w, seed: Incomplete | None = None, selfloops: bool = True +): ... +def havel_hakimi_graph(deg_sequence, create_using: Incomplete | None = None): ... +def directed_havel_hakimi_graph( + in_deg_sequence, out_deg_sequence, create_using: Incomplete | None = None +): ... +def degree_sequence_tree(deg_sequence, create_using: Incomplete | None = None): ... +def random_degree_sequence_graph( + sequence, seed: Incomplete | None = None, tries: int = 10 +): ... + +class DegreeSequenceRandomGraph: + rng: Incomplete + degree: Incomplete + m: Incomplete + dmax: Incomplete + def __init__(self, degree, rng) -> None: ... + remaining_degree: Incomplete + graph: Incomplete + def generate(self): ... + def update_remaining(self, u, v, aux_graph: Incomplete | None = None) -> None: ... + def p(self, u, v): ... + def q(self, u, v): ... + def suitable_edge(self): ... + def phase1(self) -> None: ... + def phase2(self) -> None: ... + def phase3(self) -> None: ... diff --git a/stubs/networkx/networkx/generators/directed.pyi b/stubs/networkx/networkx/generators/directed.pyi new file mode 100644 index 000000000000..a8413aedf934 --- /dev/null +++ b/stubs/networkx/networkx/generators/directed.pyi @@ -0,0 +1,28 @@ +from _typeshed import Incomplete + +def gn_graph( + n, + kernel: Incomplete | None = None, + create_using: Incomplete | None = None, + seed: Incomplete | None = None, +): ... +def gnr_graph( + n, p, create_using: Incomplete | None = None, seed: Incomplete | None = None +): ... +def gnc_graph( + n, create_using: Incomplete | None = None, seed: Incomplete | None = None +): ... +def scale_free_graph( + n, + alpha: float = 0.41, + beta: float = 0.54, + gamma: float = 0.05, + delta_in: float = 0.2, + delta_out: int = 0, + create_using: Incomplete | None = None, + seed: Incomplete | None = None, + initial_graph: Incomplete | None = None, +): ... +def random_k_out_graph( + n, k, alpha, self_loops: bool = True, seed: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/generators/duplication.pyi b/stubs/networkx/networkx/generators/duplication.pyi new file mode 100644 index 000000000000..7127ab1883b3 --- /dev/null +++ b/stubs/networkx/networkx/generators/duplication.pyi @@ -0,0 +1,4 @@ +from _typeshed import Incomplete + +def partial_duplication_graph(N, n, p, q, seed: Incomplete | None = None): ... +def duplication_divergence_graph(n, p, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/ego.pyi b/stubs/networkx/networkx/generators/ego.pyi new file mode 100644 index 000000000000..cd26c4ca9ff3 --- /dev/null +++ b/stubs/networkx/networkx/generators/ego.pyi @@ -0,0 +1,10 @@ +from _typeshed import Incomplete + +def ego_graph( + G, + n, + radius: int = 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 new file mode 100644 index 000000000000..1fed931ba3ca --- /dev/null +++ b/stubs/networkx/networkx/generators/expanders.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def margulis_gabber_galil_graph(n, create_using: Incomplete | None = None): ... +def chordal_cycle_graph(p, create_using: Incomplete | None = None): ... +def paley_graph(p, create_using: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/geometric.pyi b/stubs/networkx/networkx/generators/geometric.pyi new file mode 100644 index 000000000000..601bfe8ccafe --- /dev/null +++ b/stubs/networkx/networkx/generators/geometric.pyi @@ -0,0 +1,52 @@ +from _typeshed import Incomplete + +def geometric_edges(G, radius, p: int = 2): ... +def random_geometric_graph( + n, + radius, + dim: int = 2, + pos: Incomplete | None = None, + p: int = 2, + seed: Incomplete | None = None, +): ... +def soft_random_geometric_graph( + n, + radius, + dim: int = 2, + pos: Incomplete | None = None, + p: int = 2, + p_dist: Incomplete | None = None, + seed: Incomplete | None = None, +): ... +def geographical_threshold_graph( + n, + theta, + dim: int = 2, + pos: Incomplete | None = None, + weight: Incomplete | None = None, + metric: Incomplete | None = None, + p_dist: Incomplete | None = None, + seed: Incomplete | None = None, +): ... +def waxman_graph( + n, + beta: float = 0.4, + alpha: float = 0.1, + L: Incomplete | None = None, + domain=(0, 0, 1, 1), + metric: Incomplete | None = None, + seed: Incomplete | None = None, +): ... +def navigable_small_world_graph( + n, p: int = 1, q: int = 1, r: int = 2, dim: int = 2, seed: Incomplete | None = None +): ... +def thresholded_random_geometric_graph( + n, + radius, + theta, + dim: int = 2, + pos: Incomplete | None = None, + weight: Incomplete | None = None, + p: int = 2, + seed: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/generators/harary_graph.pyi b/stubs/networkx/networkx/generators/harary_graph.pyi new file mode 100644 index 000000000000..ed11de40daa0 --- /dev/null +++ b/stubs/networkx/networkx/generators/harary_graph.pyi @@ -0,0 +1,4 @@ +from _typeshed import Incomplete + +def hnm_harary_graph(n, m, create_using: Incomplete | None = None): ... +def hkn_harary_graph(k, n, create_using: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/internet_as_graphs.pyi b/stubs/networkx/networkx/generators/internet_as_graphs.pyi new file mode 100644 index 000000000000..3641675d11e7 --- /dev/null +++ b/stubs/networkx/networkx/generators/internet_as_graphs.pyi @@ -0,0 +1,36 @@ +from _typeshed import Incomplete + +class AS_graph_generator: + seed: Incomplete + n_t: Incomplete + n_m: Incomplete + n_cp: Incomplete + n_c: Incomplete + d_m: Incomplete + d_cp: Incomplete + d_c: Incomplete + p_m_m: Incomplete + p_cp_m: Incomplete + p_cp_cp: Incomplete + t_m: float + t_cp: float + t_c: float + def __init__(self, n, seed) -> None: ... + G: Incomplete + def t_graph(self): ... + def add_edge(self, i, j, kind) -> None: ... + 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): ... + regions: Incomplete + def graph_regions(self, rn) -> None: ... + def add_peering_links(self, from_kind, to_kind) -> None: ... + customers: Incomplete + providers: Incomplete + nodes: Incomplete + def generate(self): ... + +def random_internet_as_graph(n, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/intersection.pyi b/stubs/networkx/networkx/generators/intersection.pyi new file mode 100644 index 000000000000..373de5eddd67 --- /dev/null +++ b/stubs/networkx/networkx/generators/intersection.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def uniform_random_intersection_graph(n, m, p, seed: Incomplete | None = None): ... +def k_random_intersection_graph(n, m, k, seed: Incomplete | None = None): ... +def general_random_intersection_graph(n, m, p, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/interval_graph.pyi b/stubs/networkx/networkx/generators/interval_graph.pyi new file mode 100644 index 000000000000..b9e29f29b937 --- /dev/null +++ b/stubs/networkx/networkx/generators/interval_graph.pyi @@ -0,0 +1 @@ +def interval_graph(intervals): ... diff --git a/stubs/networkx/networkx/generators/joint_degree_seq.pyi b/stubs/networkx/networkx/generators/joint_degree_seq.pyi new file mode 100644 index 000000000000..226d2c2e0e5e --- /dev/null +++ b/stubs/networkx/networkx/generators/joint_degree_seq.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete + +def is_valid_joint_degree(joint_degrees): ... +def joint_degree_graph(joint_degrees, seed: Incomplete | None = None): ... +def is_valid_directed_joint_degree(in_degrees, out_degrees, nkk): ... +def directed_joint_degree_graph( + in_degrees, out_degrees, nkk, seed: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/generators/lattice.pyi b/stubs/networkx/networkx/generators/lattice.pyi new file mode 100644 index 000000000000..0e7190616714 --- /dev/null +++ b/stubs/networkx/networkx/generators/lattice.pyi @@ -0,0 +1,21 @@ +from _typeshed import Incomplete + +def grid_2d_graph( + m, n, periodic: bool = False, create_using: Incomplete | None = None +): ... +def grid_graph(dim, periodic: bool = False): ... +def hypercube_graph(n): ... +def triangular_lattice_graph( + m, + n, + periodic: bool = False, + with_positions: bool = True, + create_using: Incomplete | None = None, +): ... +def hexagonal_lattice_graph( + m, + n, + periodic: bool = False, + with_positions: bool = True, + create_using: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/generators/line.pyi b/stubs/networkx/networkx/generators/line.pyi new file mode 100644 index 000000000000..75ad81cd6c5c --- /dev/null +++ b/stubs/networkx/networkx/generators/line.pyi @@ -0,0 +1,4 @@ +from _typeshed import Incomplete + +def line_graph(G, create_using: Incomplete | None = None): ... +def inverse_line_graph(G): ... diff --git a/stubs/networkx/networkx/generators/mycielski.pyi b/stubs/networkx/networkx/generators/mycielski.pyi new file mode 100644 index 000000000000..0036c330c6b3 --- /dev/null +++ b/stubs/networkx/networkx/generators/mycielski.pyi @@ -0,0 +1,2 @@ +def mycielskian(G, iterations: int = 1): ... +def mycielski_graph(n): ... diff --git a/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi b/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi new file mode 100644 index 000000000000..6c4ed0391b2c --- /dev/null +++ b/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi @@ -0,0 +1,7 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def nonisomorphic_trees( + order, create: str = "graph" +) -> Generator[Incomplete, None, None]: ... +def number_of_nonisomorphic_trees(order): ... diff --git a/stubs/networkx/networkx/generators/random_clustered.pyi b/stubs/networkx/networkx/generators/random_clustered.pyi new file mode 100644 index 000000000000..002067467452 --- /dev/null +++ b/stubs/networkx/networkx/generators/random_clustered.pyi @@ -0,0 +1,7 @@ +from _typeshed import Incomplete + +def random_clustered_graph( + joint_degree_sequence, + create_using: Incomplete | None = None, + seed: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/generators/random_graphs.pyi b/stubs/networkx/networkx/generators/random_graphs.pyi new file mode 100644 index 000000000000..bfc26206914b --- /dev/null +++ b/stubs/networkx/networkx/generators/random_graphs.pyi @@ -0,0 +1,45 @@ +from _typeshed import Incomplete + +def fast_gnp_random_graph( + n, p, seed: Incomplete | None = None, directed: bool = False +): ... +def gnp_random_graph(n, p, seed: Incomplete | None = None, directed: bool = False): ... + +binomial_graph = gnp_random_graph +erdos_renyi_graph = gnp_random_graph + +def dense_gnm_random_graph(n, m, seed: Incomplete | None = None): ... +def gnm_random_graph(n, m, seed: Incomplete | None = None, directed: bool = False): ... +def newman_watts_strogatz_graph(n, k, p, seed: Incomplete | None = None): ... +def watts_strogatz_graph(n, k, p, seed: Incomplete | None = None): ... +def connected_watts_strogatz_graph( + n, k, p, tries: int = 100, seed: Incomplete | None = None +): ... +def random_regular_graph(d, n, seed: Incomplete | None = None): ... +def barabasi_albert_graph( + n, m, seed: Incomplete | None = None, initial_graph: Incomplete | None = None +): ... +def dual_barabasi_albert_graph( + n, + m1, + m2, + p, + seed: Incomplete | None = None, + initial_graph: Incomplete | None = None, +): ... +def extended_barabasi_albert_graph(n, m, p, q, seed: Incomplete | None = None): ... +def powerlaw_cluster_graph(n, m, p, seed: Incomplete | None = None): ... +def random_lobster(n, p1, p2, seed: Incomplete | None = None): ... +def random_shell_graph(constructor, seed: Incomplete | None = None): ... +def random_powerlaw_tree( + n, gamma: int = 3, seed: Incomplete | None = None, tries: int = 100 +): ... +def random_powerlaw_tree_sequence( + n, gamma: int = 3, seed: Incomplete | None = None, tries: int = 100 +): ... +def random_kernel_graph( + n, + kernel_integral, + kernel_root: Incomplete | None = None, + seed: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/generators/small.pyi b/stubs/networkx/networkx/generators/small.pyi new file mode 100644 index 000000000000..ef08aa1fd673 --- /dev/null +++ b/stubs/networkx/networkx/generators/small.pyi @@ -0,0 +1,25 @@ +from _typeshed import Incomplete + +def LCF_graph(n, shift_list, repeats, create_using: Incomplete | None = None): ... +def bull_graph(create_using: Incomplete | None = None): ... +def chvatal_graph(create_using: Incomplete | None = None): ... +def cubical_graph(create_using: Incomplete | None = None): ... +def desargues_graph(create_using: Incomplete | None = None): ... +def diamond_graph(create_using: Incomplete | None = None): ... +def dodecahedral_graph(create_using: Incomplete | None = None): ... +def frucht_graph(create_using: Incomplete | None = None): ... +def heawood_graph(create_using: Incomplete | None = None): ... +def hoffman_singleton_graph(): ... +def house_graph(create_using: Incomplete | None = None): ... +def house_x_graph(create_using: Incomplete | None = None): ... +def icosahedral_graph(create_using: Incomplete | None = None): ... +def krackhardt_kite_graph(create_using: Incomplete | None = None): ... +def moebius_kantor_graph(create_using: Incomplete | None = None): ... +def octahedral_graph(create_using: Incomplete | None = None): ... +def pappus_graph(): ... +def petersen_graph(create_using: Incomplete | None = None): ... +def sedgewick_maze_graph(create_using: Incomplete | None = None): ... +def tetrahedral_graph(create_using: Incomplete | None = None): ... +def truncated_cube_graph(create_using: Incomplete | None = None): ... +def truncated_tetrahedron_graph(create_using: Incomplete | None = None): ... +def tutte_graph(create_using: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/social.pyi b/stubs/networkx/networkx/generators/social.pyi new file mode 100644 index 000000000000..c28651c1cbb8 --- /dev/null +++ b/stubs/networkx/networkx/generators/social.pyi @@ -0,0 +1,4 @@ +def karate_club_graph(): ... +def davis_southern_women_graph(): ... +def florentine_families_graph(): ... +def les_miserables_graph(): ... diff --git a/stubs/networkx/networkx/generators/spectral_graph_forge.pyi b/stubs/networkx/networkx/generators/spectral_graph_forge.pyi new file mode 100644 index 000000000000..9c9bbd16eaf7 --- /dev/null +++ b/stubs/networkx/networkx/generators/spectral_graph_forge.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def spectral_graph_forge( + G, alpha, transformation: str = "identity", seed: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/generators/stochastic.pyi b/stubs/networkx/networkx/generators/stochastic.pyi new file mode 100644 index 000000000000..3b1d05ad1ef5 --- /dev/null +++ b/stubs/networkx/networkx/generators/stochastic.pyi @@ -0,0 +1 @@ +def stochastic_graph(G, copy: bool = True, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/generators/sudoku.pyi b/stubs/networkx/networkx/generators/sudoku.pyi new file mode 100644 index 000000000000..0012273811b3 --- /dev/null +++ b/stubs/networkx/networkx/generators/sudoku.pyi @@ -0,0 +1 @@ +def sudoku_graph(n: int = 3): ... diff --git a/stubs/networkx/networkx/generators/trees.pyi b/stubs/networkx/networkx/generators/trees.pyi new file mode 100644 index 000000000000..052151909840 --- /dev/null +++ b/stubs/networkx/networkx/generators/trees.pyi @@ -0,0 +1,7 @@ +from _typeshed import Incomplete + +def prefix_tree(paths): ... +def prefix_tree_recursive(paths): ... +def random_tree( + n, seed: Incomplete | None = None, create_using: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/generators/triads.pyi b/stubs/networkx/networkx/generators/triads.pyi new file mode 100644 index 000000000000..73290b745959 --- /dev/null +++ b/stubs/networkx/networkx/generators/triads.pyi @@ -0,0 +1 @@ +def triad_graph(triad_name): ... diff --git a/stubs/networkx/networkx/lazy_imports.pyi b/stubs/networkx/networkx/lazy_imports.pyi new file mode 100644 index 000000000000..7ba1f79daff8 --- /dev/null +++ b/stubs/networkx/networkx/lazy_imports.pyi @@ -0,0 +1,15 @@ +import types +from _typeshed import Incomplete + +def attach( + module_name, + submodules: Incomplete | None = None, + submod_attrs: Incomplete | None = None, +): ... + +class DelayedImportErrorModule(types.ModuleType): + def __init__(self, frame_data, *args, **kwargs) -> None: ... + def __getattr__(self, x) -> None: ... + +# Names in __all__ with no definition: +# _lazy_import diff --git a/stubs/networkx/networkx/linalg/__init__.pyi b/stubs/networkx/networkx/linalg/__init__.pyi new file mode 100644 index 000000000000..af8d23d18616 --- /dev/null +++ b/stubs/networkx/networkx/linalg/__init__.pyi @@ -0,0 +1,15 @@ +from networkx.linalg import ( + attrmatrix as attrmatrix, + bethehessianmatrix as bethehessianmatrix, + graphmatrix as graphmatrix, + laplacianmatrix as laplacianmatrix, + modularitymatrix as modularitymatrix, + spectrum as spectrum, +) +from networkx.linalg.algebraicconnectivity import * +from networkx.linalg.attrmatrix import * +from networkx.linalg.bethehessianmatrix import * +from networkx.linalg.graphmatrix import * +from networkx.linalg.laplacianmatrix import * +from networkx.linalg.modularitymatrix import * +from networkx.linalg.spectrum import * diff --git a/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi b/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi new file mode 100644 index 000000000000..1a1cb701b04b --- /dev/null +++ b/stubs/networkx/networkx/linalg/algebraicconnectivity.pyi @@ -0,0 +1,42 @@ +from _typeshed import Incomplete + +class _PCGSolver: + def __init__(self, A, M) -> None: ... + def solve(self, B, tol): ... + +class _LUSolver: + def __init__(self, A) -> None: ... + def solve(self, B, tol: Incomplete | None = None): ... + +def algebraic_connectivity( + G, + weight: str = "weight", + normalized: bool = False, + tol: float = 1e-08, + method: str = "tracemin_pcg", + seed: Incomplete | None = None, +): ... +def fiedler_vector( + G, + weight: str = "weight", + normalized: bool = False, + tol: float = 1e-08, + method: str = "tracemin_pcg", + seed: Incomplete | None = None, +): ... +def spectral_ordering( + G, + weight: str = "weight", + normalized: bool = False, + tol: float = 1e-08, + method: str = "tracemin_pcg", + seed: Incomplete | None = None, +): ... +def spectral_bisection( + G, + weight: str = "weight", + normalized: bool = False, + tol: float = 1e-08, + method: str = "tracemin_pcg", + seed: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/linalg/attrmatrix.pyi b/stubs/networkx/networkx/linalg/attrmatrix.pyi new file mode 100644 index 000000000000..4383cdd66019 --- /dev/null +++ b/stubs/networkx/networkx/linalg/attrmatrix.pyi @@ -0,0 +1,19 @@ +from _typeshed import Incomplete + +def attr_matrix( + G, + edge_attr: Incomplete | None = None, + node_attr: Incomplete | None = None, + normalized: bool = False, + rc_order: Incomplete | None = None, + dtype: Incomplete | None = None, + order: Incomplete | None = None, +): ... +def attr_sparse_matrix( + G, + edge_attr: Incomplete | None = None, + node_attr: 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 new file mode 100644 index 000000000000..9c74a0bcab7f --- /dev/null +++ b/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi @@ -0,0 +1,5 @@ +from _typeshed import Incomplete + +def bethe_hessian_matrix( + G, r: Incomplete | None = None, nodelist: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/linalg/graphmatrix.pyi b/stubs/networkx/networkx/linalg/graphmatrix.pyi new file mode 100644 index 000000000000..8338bc38cd4d --- /dev/null +++ b/stubs/networkx/networkx/linalg/graphmatrix.pyi @@ -0,0 +1,15 @@ +from _typeshed import Incomplete + +def incidence_matrix( + G, + nodelist: Incomplete | None = None, + edgelist: Incomplete | None = None, + oriented: bool = False, + weight: Incomplete | None = None, +): ... +def adjacency_matrix( + G, + nodelist: Incomplete | None = None, + dtype: Incomplete | None = None, + weight: str = "weight", +): ... diff --git a/stubs/networkx/networkx/linalg/laplacianmatrix.pyi b/stubs/networkx/networkx/linalg/laplacianmatrix.pyi new file mode 100644 index 000000000000..7ce9e72d541b --- /dev/null +++ b/stubs/networkx/networkx/linalg/laplacianmatrix.pyi @@ -0,0 +1,21 @@ +from _typeshed import Incomplete + +def laplacian_matrix(G, nodelist: Incomplete | None = None, weight: str = "weight"): ... +def normalized_laplacian_matrix( + G, nodelist: Incomplete | None = None, weight: str = "weight" +): ... +def total_spanning_tree_weight(G, weight: Incomplete | None = None): ... +def directed_laplacian_matrix( + G, + nodelist: Incomplete | None = None, + weight: str = "weight", + walk_type: Incomplete | None = None, + alpha: float = 0.95, +): ... +def directed_combinatorial_laplacian_matrix( + G, + nodelist: Incomplete | None = None, + weight: str = "weight", + walk_type: Incomplete | None = None, + alpha: float = 0.95, +): ... diff --git a/stubs/networkx/networkx/linalg/modularitymatrix.pyi b/stubs/networkx/networkx/linalg/modularitymatrix.pyi new file mode 100644 index 000000000000..84f7c22d3c92 --- /dev/null +++ b/stubs/networkx/networkx/linalg/modularitymatrix.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete + +def modularity_matrix( + G, nodelist: Incomplete | None = None, weight: Incomplete | None = None +): ... +def directed_modularity_matrix( + G, nodelist: Incomplete | None = None, weight: Incomplete | None = None +): ... diff --git a/stubs/networkx/networkx/linalg/spectrum.pyi b/stubs/networkx/networkx/linalg/spectrum.pyi new file mode 100644 index 000000000000..d8cc72d89ada --- /dev/null +++ b/stubs/networkx/networkx/linalg/spectrum.pyi @@ -0,0 +1,7 @@ +from _typeshed import Incomplete + +def laplacian_spectrum(G, weight: str = "weight"): ... +def normalized_laplacian_spectrum(G, weight: str = "weight"): ... +def adjacency_spectrum(G, weight: str = "weight"): ... +def modularity_spectrum(G): ... +def bethe_hessian_spectrum(G, r: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/readwrite/__init__.pyi b/stubs/networkx/networkx/readwrite/__init__.pyi new file mode 100644 index 000000000000..038e3613e9c3 --- /dev/null +++ b/stubs/networkx/networkx/readwrite/__init__.pyi @@ -0,0 +1,12 @@ +from networkx.readwrite.adjlist import * +from networkx.readwrite.edgelist import * +from networkx.readwrite.gexf import * +from networkx.readwrite.gml import * +from networkx.readwrite.graph6 import * +from networkx.readwrite.graphml import * +from networkx.readwrite.json_graph import * +from networkx.readwrite.leda import * +from networkx.readwrite.multiline_adjlist import * +from networkx.readwrite.pajek import * +from networkx.readwrite.sparse6 import * +from networkx.readwrite.text import * diff --git a/stubs/networkx/networkx/readwrite/adjlist.pyi b/stubs/networkx/networkx/readwrite/adjlist.pyi new file mode 100644 index 000000000000..aa0b881f155b --- /dev/null +++ b/stubs/networkx/networkx/readwrite/adjlist.pyi @@ -0,0 +1,22 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +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 parse_adjlist( + lines, + comments: str = "#", + delimiter: Incomplete | None = None, + create_using: Incomplete | None = None, + nodetype: Incomplete | None = None, +): ... +def read_adjlist( + path, + comments: str = "#", + delimiter: Incomplete | 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 new file mode 100644 index 000000000000..5388f5e8f6b0 --- /dev/null +++ b/stubs/networkx/networkx/readwrite/edgelist.pyi @@ -0,0 +1,43 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +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 parse_edgelist( + lines, + comments: str = "#", + delimiter: Incomplete | None = None, + create_using: Incomplete | None = None, + nodetype: Incomplete | None = None, + data: bool = True, +): ... +def read_edgelist( + path, + comments: str = "#", + delimiter: Incomplete | None = None, + create_using: Incomplete | None = None, + nodetype: Incomplete | None = None, + data: bool = True, + edgetype: Incomplete | None = None, + encoding: str = "utf-8", +): ... +def write_weighted_edgelist( + G, path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8" +) -> None: ... +def read_weighted_edgelist( + path, + comments: str = "#", + delimiter: Incomplete | 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 new file mode 100644 index 000000000000..5ae5fbc7e967 --- /dev/null +++ b/stubs/networkx/networkx/readwrite/gexf.pyi @@ -0,0 +1,86 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def write_gexf( + G, + path, + encoding: str = "utf-8", + prettyprint: bool = True, + version: str = "1.2draft", +) -> None: ... +def generate_gexf( + G, encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft" +) -> Generator[Incomplete, Incomplete, None]: ... +def read_gexf( + path, + node_type: Incomplete | None = None, + relabel: bool = False, + version: str = "1.2draft", +): ... + +class GEXF: + versions: Incomplete + xml_type: Incomplete + python_type: Incomplete + def construct_types(self) -> None: ... + convert_bool: Incomplete + NS_GEXF: Incomplete + NS_VIZ: Incomplete + NS_XSI: Incomplete + SCHEMALOCATION: Incomplete + VERSION: Incomplete + version: Incomplete + def set_version(self, version) -> None: ... + +class GEXFWriter(GEXF): + prettyprint: Incomplete + encoding: Incomplete + xml: Incomplete + edge_id: Incomplete + 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: ... + 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_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): ... + def add_parents(self, node_element, node_data): ... + def add_slices(self, node_or_edge_element, node_or_edge_data): ... + def add_spells(self, node_or_edge_element, node_or_edge_data): ... + def alter_graph_mode_timeformat(self, start_or_end) -> None: ... + def write(self, fh) -> None: ... + def indent(self, elem, level: int = 0) -> None: ... + +class GEXFReader(GEXF): + node_type: Incomplete + simple_graph: bool + def __init__( + self, node_type: Incomplete | None = 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, 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 decode_attr_elements(self, gexf_keys, obj_xml): ... + def find_gexf_attributes(self, attributes_element): ... + +def relabel_gexf_graph(G): ... diff --git a/stubs/networkx/networkx/readwrite/gml.pyi b/stubs/networkx/networkx/readwrite/gml.pyi new file mode 100644 index 000000000000..5d0c93e20c67 --- /dev/null +++ b/stubs/networkx/networkx/readwrite/gml.pyi @@ -0,0 +1,27 @@ +from _typeshed import Incomplete +from collections.abc import Generator +from enum import Enum +from typing import Any, NamedTuple + +def read_gml(path, label: str = "label", destringizer: Incomplete | None = None): ... +def parse_gml(lines, label: str = "label", destringizer: Incomplete | None = None): ... + +class Pattern(Enum): + KEYS: int + REALS: int + INTS: int + STRINGS: int + DICT_START: int + DICT_END: int + COMMENT_WHITESPACE: int + +class Token(NamedTuple): + category: Pattern + value: Any + 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: ... diff --git a/stubs/networkx/networkx/readwrite/graph6.pyi b/stubs/networkx/networkx/readwrite/graph6.pyi new file mode 100644 index 000000000000..fa668ef8ecde --- /dev/null +++ b/stubs/networkx/networkx/readwrite/graph6.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete + +def from_graph6_bytes(bytes_in): ... +def to_graph6_bytes(G, nodes: Incomplete | None = None, header: bool = True): ... +def read_graph6(path): ... +def write_graph6(G, path, nodes: Incomplete | None = None, header: bool = True): ... diff --git a/stubs/networkx/networkx/readwrite/graphml.pyi b/stubs/networkx/networkx/readwrite/graphml.pyi new file mode 100644 index 000000000000..29626940d732 --- /dev/null +++ b/stubs/networkx/networkx/readwrite/graphml.pyi @@ -0,0 +1,133 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def write_graphml_xml( + G, + path, + encoding: str = "utf-8", + prettyprint: bool = True, + infer_numeric_types: bool = False, + named_key_ids: bool = False, + edge_id_from_attribute: Incomplete | None = None, +) -> None: ... +def write_graphml_lxml( + G, + path, + encoding: str = "utf-8", + prettyprint: bool = True, + infer_numeric_types: bool = False, + named_key_ids: bool = False, + edge_id_from_attribute: Incomplete | None = None, +): ... +def generate_graphml( + G, + encoding: str = "utf-8", + prettyprint: bool = True, + named_key_ids: bool = False, + edge_id_from_attribute: Incomplete | None = None, +) -> Generator[Incomplete, Incomplete, None]: ... +def read_graphml( + path, node_type=..., edge_key_type=..., force_multigraph: bool = False +): ... +def parse_graphml( + graphml_string, node_type=..., edge_key_type=..., force_multigraph: bool = False +): ... + +class GraphML: + NS_GRAPHML: str + NS_XSI: str + NS_Y: str + SCHEMALOCATION: Incomplete + xml_type: Incomplete + python_type: Incomplete + def construct_types(self) -> None: ... + convert_bool: Incomplete + def get_xml_type(self, key): ... + +class GraphMLWriter(GraphML): + myElement: Incomplete + infer_numeric_types: Incomplete + prettyprint: Incomplete + named_key_ids: Incomplete + edge_id_from_attribute: Incomplete + encoding: Incomplete + xml: Incomplete + keys: Incomplete + attributes: Incomplete + attribute_types: Incomplete + def __init__( + self, + graph: Incomplete | None = 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, + ) -> 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_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_graph_element(self, G) -> None: ... + def add_graphs(self, graph_list) -> None: ... + def dump(self, stream) -> None: ... + def indent(self, elem, level: int = 0) -> None: ... + +class IncrementalElement: + xml: Incomplete + prettyprint: Incomplete + def __init__(self, xml, prettyprint) -> None: ... + def append(self, element) -> None: ... + +class GraphMLWriterLxml(GraphMLWriter): + myElement: Incomplete + named_key_ids: Incomplete + edge_id_from_attribute: Incomplete + infer_numeric_types: Incomplete + xml: Incomplete + keys: Incomplete + attribute_types: Incomplete + def __init__( + self, + path, + graph: Incomplete | None = 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, + ) -> None: ... + def add_graph_element(self, G) -> None: ... + def add_attributes(self, scope, xml_obj, data, default) -> None: ... + def dump(self) -> None: ... + +write_graphml = write_graphml_lxml + +class GraphMLReader(GraphML): + node_type: Incomplete + edge_key_type: Incomplete + multigraph: Incomplete + 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 add_node(self, G, node_xml, graphml_keys, defaults) -> None: ... + def add_edge(self, G, 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/__init__.pyi b/stubs/networkx/networkx/readwrite/json_graph/__init__.pyi new file mode 100644 index 000000000000..56ff476831de --- /dev/null +++ b/stubs/networkx/networkx/readwrite/json_graph/__init__.pyi @@ -0,0 +1,4 @@ +from networkx.readwrite.json_graph.adjacency import * +from networkx.readwrite.json_graph.cytoscape import * +from networkx.readwrite.json_graph.node_link import * +from networkx.readwrite.json_graph.tree import * diff --git a/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi b/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi new file mode 100644 index 000000000000..9dae24dd81f3 --- /dev/null +++ b/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi @@ -0,0 +1,7 @@ +def adjacency_data(G, attrs={"id": "id", "key": "key"}): ... +def adjacency_graph( + data, + directed: bool = False, + multigraph: bool = True, + attrs={"id": "id", "key": "key"}, +): ... diff --git a/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi b/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi new file mode 100644 index 000000000000..ad9f229239fd --- /dev/null +++ b/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi @@ -0,0 +1,2 @@ +def cytoscape_data(G, name: str = "name", ident: str = "id"): ... +def cytoscape_graph(data, name: str = "name", ident: str = "id"): ... diff --git a/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi b/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi new file mode 100644 index 000000000000..319c21153530 --- /dev/null +++ b/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi @@ -0,0 +1,24 @@ +from _typeshed import Incomplete + +def node_link_data( + G, + attrs: Incomplete | None = None, + *, + source: str = "source", + target: str = "target", + name: str = "id", + key: str = "key", + link: str = "links", +): ... +def node_link_graph( + data, + directed: bool = False, + multigraph: bool = True, + attrs: Incomplete | None = None, + *, + source: str = "source", + target: str = "target", + name: str = "id", + key: str = "key", + link: str = "links", +): ... diff --git a/stubs/networkx/networkx/readwrite/json_graph/tree.pyi b/stubs/networkx/networkx/readwrite/json_graph/tree.pyi new file mode 100644 index 000000000000..b6cae9443a18 --- /dev/null +++ b/stubs/networkx/networkx/readwrite/json_graph/tree.pyi @@ -0,0 +1,2 @@ +def tree_data(G, root, ident: str = "id", children: str = "children"): ... +def tree_graph(data, ident: str = "id", children: str = "children"): ... diff --git a/stubs/networkx/networkx/readwrite/leda.pyi b/stubs/networkx/networkx/readwrite/leda.pyi new file mode 100644 index 000000000000..c0701362fd56 --- /dev/null +++ b/stubs/networkx/networkx/readwrite/leda.pyi @@ -0,0 +1,2 @@ +def read_leda(path, encoding: str = "UTF-8"): ... +def parse_leda(lines): ... diff --git a/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi b/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi new file mode 100644 index 000000000000..ae5f3f92525a --- /dev/null +++ b/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi @@ -0,0 +1,26 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +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 parse_multiline_adjlist( + lines, + comments: str = "#", + delimiter: Incomplete | None = None, + create_using: Incomplete | None = None, + nodetype: Incomplete | None = None, + edgetype: Incomplete | None = None, +): ... +def read_multiline_adjlist( + path, + comments: str = "#", + delimiter: Incomplete | None = None, + create_using: Incomplete | None = None, + nodetype: Incomplete | None = None, + edgetype: Incomplete | None = None, + encoding: str = "utf-8", +): ... diff --git a/stubs/networkx/networkx/readwrite/p2g.pyi b/stubs/networkx/networkx/readwrite/p2g.pyi new file mode 100644 index 000000000000..a50ea09af38b --- /dev/null +++ b/stubs/networkx/networkx/readwrite/p2g.pyi @@ -0,0 +1,3 @@ +def write_p2g(G, path, encoding: str = "utf-8") -> None: ... +def read_p2g(path, encoding: str = "utf-8"): ... +def parse_p2g(lines): ... diff --git a/stubs/networkx/networkx/readwrite/pajek.pyi b/stubs/networkx/networkx/readwrite/pajek.pyi new file mode 100644 index 000000000000..e1b59215b007 --- /dev/null +++ b/stubs/networkx/networkx/readwrite/pajek.pyi @@ -0,0 +1,7 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def generate_pajek(G) -> Generator[Incomplete, None, None]: ... +def write_pajek(G, path, encoding: str = "UTF-8") -> None: ... +def read_pajek(path, encoding: str = "UTF-8"): ... +def parse_pajek(lines): ... diff --git a/stubs/networkx/networkx/readwrite/sparse6.pyi b/stubs/networkx/networkx/readwrite/sparse6.pyi new file mode 100644 index 000000000000..75cb5b58d7b9 --- /dev/null +++ b/stubs/networkx/networkx/readwrite/sparse6.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete + +def from_sparse6_bytes(string): ... +def to_sparse6_bytes(G, nodes: Incomplete | None = None, header: bool = True): ... +def read_sparse6(path): ... +def write_sparse6( + G, path, nodes: Incomplete | None = None, header: bool = True +) -> None: ... diff --git a/stubs/networkx/networkx/readwrite/text.pyi b/stubs/networkx/networkx/readwrite/text.pyi new file mode 100644 index 000000000000..b718cb604062 --- /dev/null +++ b/stubs/networkx/networkx/readwrite/text.pyi @@ -0,0 +1,62 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +class _AsciiBaseGlyphs: + empty: str + newtree_last: str + newtree_mid: str + endof_forest: str + within_forest: str + within_tree: str + +class AsciiDirectedGlyphs(_AsciiBaseGlyphs): + last: str + mid: str + backedge: str + +class AsciiUndirectedGlyphs(_AsciiBaseGlyphs): + last: str + mid: str + backedge: str + +class _UtfBaseGlyphs: + empty: str + newtree_last: str + newtree_mid: str + endof_forest: str + within_forest: str + within_tree: str + +class UtfDirectedGlyphs(_UtfBaseGlyphs): + last: str + mid: str + backedge: str + +class UtfUndirectedGlyphs(_UtfBaseGlyphs): + last: str + mid: str + backedge: str + +def generate_network_text( + graph, + with_labels: bool = True, + sources: Incomplete | None = None, + max_depth: Incomplete | None = None, + ascii_only: bool = False, +) -> Generator[Incomplete, None, Incomplete]: ... +def write_network_text( + graph, + path: Incomplete | None = None, + with_labels: bool = True, + sources: Incomplete | None = None, + max_depth: Incomplete | None = None, + ascii_only: bool = False, + end: str = "\n", +) -> None: ... +def forest_str( + graph, + with_labels: bool = True, + sources: Incomplete | None = None, + write: Incomplete | None = None, + ascii_only: bool = False, +): ... diff --git a/stubs/networkx/networkx/relabel.pyi b/stubs/networkx/networkx/relabel.pyi new file mode 100644 index 000000000000..708b59f9ea94 --- /dev/null +++ b/stubs/networkx/networkx/relabel.pyi @@ -0,0 +1,21 @@ +from collections.abc import Mapping +from typing import Any, TypeVar +from _typeshed import Incomplete + +from networkx.classes.graph import Graph +from typing_extensions import Literal + +_X = TypeVar("_X") +_Y = TypeVar("_Y") + +def relabel_nodes( + G: Graph[_X], mapping: Mapping[_X, _Y], copy: bool = ... +) -> Graph[_X | _Y]: ... +def convert_node_labels_to_integers( + G: Graph[Any], + first_label: int = ..., + ordering: Literal[ + "default", "sorted", "increasing degree", "decreasing degree" + ] = ..., + label_attribute: Incomplete | None = ..., +) -> Graph[int]: ... diff --git a/stubs/networkx/networkx/utils/__init__.pyi b/stubs/networkx/networkx/utils/__init__.pyi new file mode 100644 index 000000000000..1417c4af9e2e --- /dev/null +++ b/stubs/networkx/networkx/utils/__init__.pyi @@ -0,0 +1,6 @@ +from networkx.utils.decorators import * +from networkx.utils.heaps import * +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 new file mode 100644 index 000000000000..82cd9492d643 --- /dev/null +++ b/stubs/networkx/networkx/utils/decorators.pyi @@ -0,0 +1,26 @@ +from _typeshed import Incomplete +from typing import NamedTuple + +def not_implemented_for(*graph_types): ... +def open_file(path_arg, mode: str = "r"): ... +def nodes_or_number(which_args): ... +def np_random_state(random_state_argument): ... +def py_random_state(random_state_argument): ... + +class argmap: + def __init__(self, func, *args, try_finally: bool = False) -> None: ... + def __call__(self, f): ... + def compile(self, f): ... + def assemble(self, f): ... + @classmethod + def signature(cls, f): ... + + class Signature(NamedTuple): + name: Incomplete + signature: Incomplete + def_sig: Incomplete + call_sig: Incomplete + names: Incomplete + n_positional: Incomplete + args: Incomplete + kwargs: Incomplete diff --git a/stubs/networkx/networkx/utils/heaps.pyi b/stubs/networkx/networkx/utils/heaps.pyi new file mode 100644 index 000000000000..e7d610aa922b --- /dev/null +++ b/stubs/networkx/networkx/utils/heaps.pyi @@ -0,0 +1,38 @@ +from _typeshed import Incomplete + +class MinHeap: + class _Item: + key: Incomplete + value: Incomplete + 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 __nonzero__(self): ... + def __bool__(self) -> bool: ... + def __len__(self) -> int: ... + def __contains__(self, key) -> bool: ... + +class PairingHeap(MinHeap): + class _Node(MinHeap._Item): + left: Incomplete + next: Incomplete + prev: Incomplete + parent: Incomplete + def __init__(self, key, value) -> None: ... + + def __init__(self) -> None: ... + def min(self): ... + def pop(self): ... + def get(self, key, default: Incomplete | None = None): ... + def insert(self, key, value, allow_increase: bool = False): ... + +class BinaryHeap(MinHeap): + def __init__(self) -> None: ... + def min(self): ... + def pop(self): ... + def get(self, key, default: Incomplete | None = None): ... + def insert(self, key, value, allow_increase: bool = False): ... diff --git a/stubs/networkx/networkx/utils/mapped_queue.pyi b/stubs/networkx/networkx/utils/mapped_queue.pyi new file mode 100644 index 000000000000..2d3923881676 --- /dev/null +++ b/stubs/networkx/networkx/utils/mapped_queue.pyi @@ -0,0 +1,22 @@ +from _typeshed import Incomplete + +class _HeapElement: + priority: Incomplete + element: Incomplete + def __init__(self, priority, element) -> None: ... + def __lt__(self, other): ... + def __gt__(self, other): ... + def __eq__(self, other): ... + def __hash__(self): ... + def __getitem__(self, indx): ... + def __iter__(self): ... + +class MappedQueue: + heap: Incomplete + position: Incomplete + def __init__(self, data: Incomplete | None = None) -> None: ... + def __len__(self) -> int: ... + def push(self, elt, priority: Incomplete | None = None): ... + def pop(self): ... + def update(self, elt, new, priority: Incomplete | None = None) -> None: ... + def remove(self, elt) -> None: ... diff --git a/stubs/networkx/networkx/utils/misc.pyi b/stubs/networkx/networkx/utils/misc.pyi new file mode 100644 index 000000000000..ee1f811ebd4b --- /dev/null +++ b/stubs/networkx/networkx/utils/misc.pyi @@ -0,0 +1,27 @@ +from _typeshed import Incomplete + +def flatten(obj, result: Incomplete | None = None): ... +def make_list_of_ints(sequence): ... +def dict_to_numpy_array(d, mapping: Incomplete | None = 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): ... + +class PythonRandomInterface: + def __init__(self, rng: Incomplete | None = None) -> None: ... + def random(self): ... + def uniform(self, a, b): ... + def randrange(self, a, b: Incomplete | None = None): ... + def choice(self, seq): ... + def gauss(self, mu, sigma): ... + def shuffle(self, seq): ... + def sample(self, seq, k): ... + def randint(self, a, b): ... + def expovariate(self, scale): ... + def paretovariate(self, shape): ... + +def create_py_random_state(random_state: Incomplete | None = None): ... +def nodes_equal(nodes1, nodes2): ... +def edges_equal(edges1, edges2): ... +def graphs_equal(graph1, graph2): ... diff --git a/stubs/networkx/networkx/utils/random_sequence.pyi b/stubs/networkx/networkx/utils/random_sequence.pyi new file mode 100644 index 000000000000..94d6b544a1fe --- /dev/null +++ b/stubs/networkx/networkx/utils/random_sequence.pyi @@ -0,0 +1,13 @@ +from _typeshed import Incomplete + +def powerlaw_sequence(n, exponent: float = 2.0, seed: Incomplete | None = None): ... +def zipf_rv(alpha, xmin: int = 1, seed: Incomplete | None = None): ... +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): ... diff --git a/stubs/networkx/networkx/utils/rcm.pyi b/stubs/networkx/networkx/utils/rcm.pyi new file mode 100644 index 000000000000..dc63681426f3 --- /dev/null +++ b/stubs/networkx/networkx/utils/rcm.pyi @@ -0,0 +1,7 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def cuthill_mckee_ordering( + G, heuristic: Incomplete | None = None +) -> Generator[Incomplete, Incomplete, None]: ... +def reverse_cuthill_mckee_ordering(G, heuristic: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/utils/union_find.pyi b/stubs/networkx/networkx/utils/union_find.pyi new file mode 100644 index 000000000000..ecb881cee44e --- /dev/null +++ b/stubs/networkx/networkx/utils/union_find.pyi @@ -0,0 +1,11 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +class UnionFind: + parents: Incomplete + weights: Incomplete + def __init__(self, elements: Incomplete | None = None) -> None: ... + def __getitem__(self, object): ... + def __iter__(self): ... + def to_sets(self) -> Generator[Incomplete, Incomplete, None]: ... + def union(self, *objects): ... From 915599873ddb1e2e275618d9b6e319e99e107667 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 31 Aug 2023 21:57:31 +0000 Subject: [PATCH 02/37] [pre-commit.ci] auto fixes from pre-commit.com hooks --- .../algorithms/approximation/connectivity.pyi | 4 +- .../algorithms/approximation/maxcut.pyi | 11 +-- .../algorithms/approximation/steinertree.pyi | 4 +- .../approximation/traveling_salesman.pyi | 13 +--- .../algorithms/assortativity/connectivity.pyi | 6 +- .../algorithms/assortativity/correlation.pyi | 20 ++---- .../algorithms/assortativity/mixing.pyi | 17 +---- .../assortativity/neighbor_degree.pyi | 6 +- .../algorithms/assortativity/pairs.pyi | 10 +-- .../algorithms/bipartite/edgelist.pyi | 13 +--- .../algorithms/bipartite/generators.pyi | 16 ++--- .../algorithms/bipartite/matching.pyi | 4 +- .../networkx/algorithms/bipartite/matrix.pyi | 4 +- .../algorithms/bipartite/projection.pyi | 4 +- .../algorithms/bipartite/spectral.pyi | 4 +- .../networkx/networkx/algorithms/boundary.pyi | 8 +-- .../networkx/networkx/algorithms/bridges.pyi | 12 ++-- .../algorithms/centrality/betweenness.pyi | 6 +- .../centrality/betweenness_subset.pyi | 8 +-- .../algorithms/centrality/closeness.pyi | 13 +--- .../centrality/current_flow_betweenness.pyi | 12 +--- .../current_flow_betweenness_subset.pyi | 16 +---- .../centrality/current_flow_closeness.pyi | 4 +- .../algorithms/centrality/eigenvector.pyi | 10 +-- .../algorithms/centrality/flow_matrix.pyi | 8 +-- .../networkx/algorithms/centrality/group.pyi | 8 +-- .../algorithms/centrality/harmonic.pyi | 5 +- .../networkx/algorithms/centrality/katz.pyi | 6 +- .../networkx/algorithms/centrality/load.pyi | 6 +- .../algorithms/centrality/percolation.pyi | 5 +- .../algorithms/centrality/reaching.pyi | 10 +-- .../algorithms/centrality/trophic.pyi | 4 +- stubs/networkx/networkx/algorithms/chains.pyi | 4 +- .../networkx/networkx/algorithms/chordal.pyi | 4 +- stubs/networkx/networkx/algorithms/clique.pyi | 37 +++------- .../networkx/networkx/algorithms/cluster.pyi | 11 +-- .../networkx/algorithms/coloring/__init__.pyi | 4 +- .../algorithms/coloring/greedy_coloring.pyi | 8 +-- .../algorithms/community/centrality.pyi | 4 +- .../networkx/algorithms/community/kclique.pyi | 4 +- .../algorithms/community/kernighan_lin.pyi | 6 +- .../networkx/algorithms/community/louvain.pyi | 12 +--- .../networkx/algorithms/community/lukes.pyi | 7 +- .../algorithms/community/modularity_max.pyi | 10 +-- .../components/strongly_connected.pyi | 8 +-- .../algorithms/connectivity/__init__.pyi | 2 +- .../algorithms/connectivity/connectivity.pyi | 11 +-- .../networkx/algorithms/connectivity/cuts.pyi | 28 ++------ .../connectivity/edge_augmentation.pyi | 6 +- .../algorithms/connectivity/kcutsets.pyi | 4 +- stubs/networkx/networkx/algorithms/cuts.pyi | 16 ++--- stubs/networkx/networkx/algorithms/cycles.pyi | 12 +--- stubs/networkx/networkx/algorithms/dag.pyi | 14 ++-- .../networkx/algorithms/distance_measures.pyi | 46 ++----------- stubs/networkx/networkx/algorithms/euler.pyi | 8 +-- .../networkx/algorithms/flow/__init__.pyi | 5 +- .../algorithms/flow/capacityscaling.pyi | 8 +-- .../networkx/algorithms/flow/gomory_hu.pyi | 4 +- .../networkx/algorithms/flow/maxflow.pyi | 36 ++-------- .../networkx/algorithms/flow/mincost.pyi | 8 +-- .../algorithms/flow/networksimplex.pyi | 13 +--- .../networkx/algorithms/graph_hashing.pyi | 12 +--- stubs/networkx/networkx/algorithms/hybrid.pyi | 4 +- .../algorithms/isomorphism/ismags.pyi | 12 +--- .../algorithms/isomorphism/isomorph.pyi | 4 +- .../algorithms/isomorphism/isomorphvf2.pyi | 12 +--- .../algorithms/isomorphism/matchhelpers.pyi | 4 +- .../networkx/algorithms/isomorphism/vf2pp.pyi | 19 +----- .../algorithms/isomorphism/vf2userfunc.pyi | 16 +---- .../algorithms/link_analysis/hits_alg.pyi | 8 +-- .../networkx/algorithms/link_prediction.pyi | 19 ++---- stubs/networkx/networkx/algorithms/mis.pyi | 4 +- .../algorithms/node_classification.pyi | 4 +- .../networkx/algorithms/operators/binary.pyi | 9 +-- .../networkx/algorithms/operators/unary.pyi | 2 +- .../networkx/algorithms/planarity.pyi | 18 ++--- .../networkx/networkx/algorithms/richclub.pyi | 4 +- .../algorithms/shortest_paths/astar.pyi | 8 +-- .../algorithms/shortest_paths/dense.pyi | 4 +- .../algorithms/shortest_paths/generic.pyi | 28 ++------ .../algorithms/shortest_paths/unweighted.pyi | 14 +--- .../algorithms/shortest_paths/weighted.pyi | 58 ++++------------ .../networkx/algorithms/similarity.pyi | 8 +-- .../networkx/algorithms/simple_paths.pyi | 10 +-- .../networkx/algorithms/smallworld.pyi | 10 +-- .../networkx/algorithms/sparsifiers.pyi | 4 +- .../networkx/algorithms/structuralholes.pyi | 8 +-- stubs/networkx/networkx/algorithms/swap.pyi | 12 +--- .../algorithms/traversal/beamsearch.pyi | 4 +- .../traversal/breadth_first_search.pyi | 22 ++---- .../traversal/depth_first_search.pyi | 30 +++----- .../networkx/algorithms/tree/branchings.pyi | 46 +++---------- .../networkx/networkx/algorithms/tree/mst.pyi | 40 ++--------- .../networkx/networkx/algorithms/vitality.pyi | 5 +- stubs/networkx/networkx/classes/coreviews.pyi | 16 ++--- stubs/networkx/networkx/classes/digraph.pyi | 10 +-- stubs/networkx/networkx/classes/function.pyi | 68 +++++-------------- stubs/networkx/networkx/classes/graph.pyi | 47 +++---------- .../networkx/classes/multidigraph.pyi | 6 +- .../networkx/networkx/classes/reportviews.pyi | 56 ++++----------- stubs/networkx/networkx/convert.pyi | 4 +- stubs/networkx/networkx/convert_matrix.pyi | 12 ++-- stubs/networkx/networkx/drawing/layout.pyi | 40 ++--------- stubs/networkx/networkx/drawing/nx_agraph.pyi | 11 +-- stubs/networkx/networkx/drawing/nx_pylab.pyi | 10 +-- .../networkx/generators/community.pyi | 12 +--- .../networkx/generators/degree_seq.pyi | 21 ++---- .../networkx/networkx/generators/directed.pyi | 19 ++---- stubs/networkx/networkx/generators/ego.pyi | 9 +-- .../networkx/generators/geometric.pyi | 11 +-- .../networkx/generators/joint_degree_seq.pyi | 4 +- .../networkx/networkx/generators/lattice.pyi | 16 +---- .../generators/nonisomorphic_trees.pyi | 4 +- .../networkx/generators/random_clustered.pyi | 6 +- .../networkx/generators/random_graphs.pyi | 36 ++-------- .../generators/spectral_graph_forge.pyi | 4 +- stubs/networkx/networkx/generators/trees.pyi | 4 +- stubs/networkx/networkx/lazy_imports.pyi | 6 +- .../networkx/linalg/bethehessianmatrix.pyi | 4 +- .../networkx/networkx/linalg/graphmatrix.pyi | 7 +- .../networkx/linalg/laplacianmatrix.pyi | 16 +---- .../networkx/linalg/modularitymatrix.pyi | 8 +-- stubs/networkx/networkx/readwrite/adjlist.pyi | 4 +- .../networkx/networkx/readwrite/edgelist.pyi | 17 +---- stubs/networkx/networkx/readwrite/gexf.pyi | 29 ++------ stubs/networkx/networkx/readwrite/gml.pyi | 4 +- stubs/networkx/networkx/readwrite/graphml.pyi | 29 ++------ .../readwrite/json_graph/adjacency.pyi | 7 +- .../networkx/readwrite/multiline_adjlist.pyi | 8 +-- stubs/networkx/networkx/readwrite/sparse6.pyi | 4 +- stubs/networkx/networkx/readwrite/text.pyi | 6 +- stubs/networkx/networkx/relabel.pyi | 12 ++-- .../networkx/utils/random_sequence.pyi | 5 +- stubs/networkx/networkx/utils/rcm.pyi | 4 +- 134 files changed, 351 insertions(+), 1324 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi b/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi index 91edbb44c1d0..2884da3b93ef 100644 --- a/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi @@ -2,6 +2,4 @@ from _typeshed import Incomplete def local_node_connectivity(G, source, target, cutoff: Incomplete | None = None): ... def node_connectivity(G, s: Incomplete | None = None, t: Incomplete | None = None): ... -def all_pairs_node_connectivity( - G, nbunch: Incomplete | None = None, cutoff: Incomplete | None = None -): ... +def all_pairs_node_connectivity(G, nbunch: Incomplete | None = None, cutoff: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi b/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi index f1286e8d3c31..170f728531f3 100644 --- a/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi @@ -1,11 +1,4 @@ from _typeshed import Incomplete -def randomized_partitioning( - G, seed: Incomplete | None = None, p: float = 0.5, weight: Incomplete | None = None -): ... -def one_exchange( - G, - initial_cut: Incomplete | None = None, - seed: Incomplete | None = None, - weight: Incomplete | None = None, -): ... +def randomized_partitioning(G, seed: Incomplete | None = None, p: float = 0.5, weight: Incomplete | None = None): ... +def one_exchange(G, initial_cut: Incomplete | None = None, seed: Incomplete | None = None, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi b/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi index a8ef401f5da1..572c0bf5b232 100644 --- a/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi @@ -1,6 +1,4 @@ from _typeshed import Incomplete def metric_closure(G, weight: str = "weight"): ... -def steiner_tree( - G, terminal_nodes, weight: str = "weight", method: Incomplete | None = None -): ... +def steiner_tree(G, terminal_nodes, weight: str = "weight", method: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi index 3bcb15dc8c27..729fe837eca4 100644 --- a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi @@ -2,18 +2,9 @@ from _typeshed import Incomplete def christofides(G, weight: str = "weight", tree: Incomplete | None = None): ... def traveling_salesman_problem( - G, - weight: str = "weight", - nodes: Incomplete | None = None, - cycle: bool = True, - method: Incomplete | None = None, -): ... -def asadpour_atsp( - G, - weight: str = "weight", - seed: Incomplete | None = None, - source: Incomplete | None = None, + G, weight: str = "weight", nodes: Incomplete | None = None, cycle: bool = True, method: Incomplete | None = None ): ... +def asadpour_atsp(G, weight: str = "weight", seed: Incomplete | None = None, source: Incomplete | None = None): ... def greedy_tsp(G, weight: str = "weight", source: Incomplete | None = None): ... def simulated_annealing_tsp( G, diff --git a/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi b/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi index bdce6a47ab6c..e0f8cb99417f 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi @@ -1,9 +1,5 @@ from _typeshed import Incomplete def average_degree_connectivity( - G, - source: str = "in+out", - target: str = "in+out", - nodes: Incomplete | None = None, - weight: Incomplete | None = None, + G, source: str = "in+out", target: str = "in+out", nodes: Incomplete | None = None, weight: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi index ca33e57deb75..300160c7e874 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi @@ -1,22 +1,10 @@ from _typeshed import Incomplete def degree_assortativity_coefficient( - G, - x: str = "out", - y: str = "in", - weight: Incomplete | None = None, - nodes: Incomplete | None = None, + G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None ): ... def degree_pearson_correlation_coefficient( - G, - x: str = "out", - y: str = "in", - weight: Incomplete | None = None, - nodes: Incomplete | None = None, -): ... -def attribute_assortativity_coefficient( - G, attribute, nodes: Incomplete | None = None -): ... -def numeric_assortativity_coefficient( - G, attribute, nodes: Incomplete | None = None + G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None ): ... +def attribute_assortativity_coefficient(G, attribute, nodes: Incomplete | None = None): ... +def numeric_assortativity_coefficient(G, attribute, nodes: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi index 9fb4388ddba0..0801a6719210 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi @@ -1,22 +1,11 @@ from _typeshed import Incomplete -def attribute_mixing_dict( - G, attribute, nodes: Incomplete | None = None, normalized: bool = False -): ... +def attribute_mixing_dict(G, attribute, nodes: Incomplete | None = None, normalized: bool = False): ... def attribute_mixing_matrix( - G, - attribute, - nodes: Incomplete | None = None, - mapping: Incomplete | None = None, - normalized: bool = True, + G, attribute, nodes: Incomplete | None = None, mapping: Incomplete | None = None, normalized: bool = True ): ... def degree_mixing_dict( - G, - x: str = "out", - y: str = "in", - weight: Incomplete | None = None, - nodes: Incomplete | None = None, - normalized: bool = False, + G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None, normalized: bool = False ): ... def degree_mixing_matrix( G, diff --git a/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi b/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi index ed3cf3e787c3..42649c6f6a5f 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi @@ -1,9 +1,5 @@ from _typeshed import Incomplete def average_neighbor_degree( - G, - source: str = "out", - target: str = "out", - nodes: Incomplete | None = None, - weight: Incomplete | None = None, + G, source: str = "out", target: str = "out", nodes: Incomplete | None = None, weight: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi b/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi index cf97e98df58d..dc834ba8164f 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi @@ -1,13 +1,7 @@ from _typeshed import Incomplete from collections.abc import Generator -def node_attribute_xy( - G, attribute, nodes: Incomplete | None = None -) -> Generator[Incomplete, None, None]: ... +def node_attribute_xy(G, attribute, nodes: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... def node_degree_xy( - G, - x: str = "out", - y: str = "in", - weight: Incomplete | None = None, - nodes: Incomplete | None = None, + G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None ) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi b/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi index a36e756a3418..9251989a2d39 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi @@ -1,17 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator -def write_edgelist( - G, - path, - comments: str = "#", - delimiter: str = " ", - data: bool = True, - encoding: str = "utf-8", -) -> None: ... -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, delimiter: str = " ", data: bool = True) -> Generator[Incomplete, None, None]: ... def parse_edgelist( lines, comments: str = "#", diff --git a/stubs/networkx/networkx/algorithms/bipartite/generators.pyi b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi index 908f29d0c687..7c36a00a8751 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/generators.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi @@ -1,18 +1,10 @@ from _typeshed import Incomplete def complete_bipartite_graph(n1, n2, create_using: Incomplete | None = None): ... -def configuration_model( - aseq, bseq, create_using: Incomplete | None = None, seed: Incomplete | None = None -): ... +def configuration_model(aseq, bseq, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... def havel_hakimi_graph(aseq, bseq, create_using: Incomplete | None = None): ... def reverse_havel_hakimi_graph(aseq, bseq, create_using: Incomplete | None = None): ... -def alternating_havel_hakimi_graph( - aseq, bseq, create_using: Incomplete | None = None -): ... -def preferential_attachment_graph( - aseq, p, create_using: Incomplete | None = None, seed: Incomplete | None = None -): ... +def alternating_havel_hakimi_graph(aseq, bseq, create_using: Incomplete | None = None): ... +def preferential_attachment_graph(aseq, p, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... def random_graph(n, m, p, seed: Incomplete | None = None, directed: bool = False): ... -def gnmk_random_graph( - n, m, k, seed: Incomplete | None = None, directed: bool = False -): ... +def gnmk_random_graph(n, m, k, seed: Incomplete | None = None, directed: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi index 106a7dad08d3..de89ed68fdb9 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi @@ -6,6 +6,4 @@ def to_vertex_cover(G, matching, top_nodes: Incomplete | None = None): ... maximum_matching = hopcroft_karp_matching -def minimum_weight_full_matching( - G, top_nodes: Incomplete | None = None, weight: str = "weight" -): ... +def minimum_weight_full_matching(G, top_nodes: Incomplete | None = None, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi index 2230cc6b182b..79f344772f58 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi @@ -8,6 +8,4 @@ def biadjacency_matrix( weight: str = "weight", format: str = "csr", ): ... -def from_biadjacency_matrix( - A, create_using: Incomplete | None = None, edge_attribute: str = "weight" -): ... +def from_biadjacency_matrix(A, create_using: Incomplete | None = None, edge_attribute: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/projection.pyi b/stubs/networkx/networkx/algorithms/bipartite/projection.pyi index 32c60753b0e6..ad7e73bb00e7 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/projection.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/projection.pyi @@ -4,6 +4,4 @@ def projected_graph(B, nodes, multigraph: bool = False): ... def weighted_projected_graph(B, nodes, ratio: bool = False): ... def collaboration_weighted_projected_graph(B, nodes): ... def overlap_weighted_projected_graph(B, nodes, jaccard: bool = True): ... -def generic_weighted_projected_graph( - B, nodes, weight_function: Incomplete | None = None -): ... +def generic_weighted_projected_graph(B, nodes, weight_function: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi b/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi index 9530b35c8906..3ae4c3180793 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi @@ -1,5 +1,3 @@ from _typeshed import Incomplete -def spectral_bipartivity( - G, nodes: Incomplete | None = None, weight: str = "weight" -): ... +def spectral_bipartivity(G, nodes: Incomplete | None = None, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/boundary.pyi b/stubs/networkx/networkx/algorithms/boundary.pyi index f5353289a06f..cfa6b4d28b98 100644 --- a/stubs/networkx/networkx/algorithms/boundary.pyi +++ b/stubs/networkx/networkx/algorithms/boundary.pyi @@ -1,9 +1,9 @@ +from _typeshed import Incomplete from collections.abc import Iterable from typing import TypeVar, overload -from _typeshed import Incomplete +from typing_extensions import Literal from networkx.classes.graph import Graph -from typing_extensions import Literal _T = TypeVar("_T") _U = TypeVar("_U") @@ -62,6 +62,4 @@ def edge_boundary( keys: Literal[True] = ..., default: _U | None = None, ) -> Iterable[tuple[_T, _T, int, dict[str, _U]]]: ... -def node_boundary( - G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None = ... -) -> Iterable[_T]: ... +def node_boundary(G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None = ...) -> Iterable[_T]: ... diff --git a/stubs/networkx/networkx/algorithms/bridges.pyi b/stubs/networkx/networkx/algorithms/bridges.pyi index d51877395c36..0699b7e5ff53 100644 --- a/stubs/networkx/networkx/algorithms/bridges.pyi +++ b/stubs/networkx/networkx/algorithms/bridges.pyi @@ -1,21 +1,17 @@ +from _typeshed import Incomplete from collections.abc import Callable, Iterable from typing import overload -from _typeshed import Incomplete +from typing_extensions import Literal from networkx.classes.graph import Graph, _Node -from typing_extensions import Literal def bridges(G: Graph[_Node], root: _Node | None = ...) -> Iterable[_Node]: ... def has_bridges(G: Graph[_Node], root: Incomplete | None = ...) -> bool: ... @overload def local_bridges( - G: Graph[_Node], - with_span: Literal[False] = ..., - weight: str | Callable[[_Node], float] | None = ..., + G: Graph[_Node], with_span: Literal[False] = ..., weight: str | Callable[[_Node], float] | None = ... ) -> Iterable[tuple[_Node, _Node]]: ... @overload def local_bridges( - G: Graph[_Node], - with_span: Literal[True] = ..., - weight: str | Callable[[_Node], float] | None = ..., + G: Graph[_Node], with_span: Literal[True] = ..., weight: str | Callable[[_Node], float] | None = ... ) -> Iterable[tuple[_Node, _Node, int]]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/betweenness.pyi b/stubs/networkx/networkx/algorithms/centrality/betweenness.pyi index 9b54c2c919bc..38cc77a1af5c 100644 --- a/stubs/networkx/networkx/algorithms/centrality/betweenness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/betweenness.pyi @@ -9,9 +9,5 @@ def betweenness_centrality( seed: Incomplete | None = None, ): ... def edge_betweenness_centrality( - G, - k: Incomplete | None = None, - normalized: bool = True, - weight: Incomplete | None = None, - seed: Incomplete | None = None, + G, k: Incomplete | None = None, normalized: bool = True, weight: Incomplete | None = None, seed: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi b/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi index 572d3ae30f05..a5cdba3b0ace 100644 --- a/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi @@ -1,8 +1,4 @@ from _typeshed import Incomplete -def betweenness_centrality_subset( - G, sources, targets, normalized: bool = False, weight: Incomplete | None = None -): ... -def edge_betweenness_centrality_subset( - G, sources, targets, normalized: bool = False, weight: Incomplete | None = None -): ... +def betweenness_centrality_subset(G, sources, targets, normalized: bool = False, weight: Incomplete | None = None): ... +def edge_betweenness_centrality_subset(G, sources, targets, normalized: bool = False, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi index 74f15d68e839..da0e5ab87eaa 100644 --- a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi @@ -1,15 +1,6 @@ from _typeshed import Incomplete -def closeness_centrality( - G, - u: Incomplete | None = None, - distance: Incomplete | None = None, - wf_improved: bool = True, -): ... +def closeness_centrality(G, u: Incomplete | None = None, distance: Incomplete | None = None, wf_improved: bool = True): ... def incremental_closeness_centrality( - G, - edge, - prev_cc: Incomplete | None = None, - insertion: bool = True, - wf_improved: bool = True, + G, edge, prev_cc: Incomplete | None = None, insertion: bool = True, wf_improved: bool = True ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi index 1916671ee620..c6f6bea33f14 100644 --- a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi @@ -11,16 +11,8 @@ def approximate_current_flow_betweenness_centrality( seed: Incomplete | None = None, ): ... def current_flow_betweenness_centrality( - G, - normalized: bool = True, - weight: Incomplete | None = None, - dtype=..., - solver: str = "full", + G, normalized: bool = True, weight: Incomplete | None = None, dtype=..., solver: str = "full" ): ... def edge_current_flow_betweenness_centrality( - G, - normalized: bool = True, - weight: Incomplete | None = None, - dtype=..., - solver: str = "full", + G, normalized: bool = True, weight: Incomplete | None = None, dtype=..., solver: str = "full" ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi index 99ba44469748..6d760a50153e 100644 --- a/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi @@ -1,20 +1,8 @@ from _typeshed import Incomplete def current_flow_betweenness_centrality_subset( - G, - sources, - targets, - normalized: bool = True, - weight: Incomplete | None = None, - dtype=..., - solver: str = "lu", + G, sources, targets, normalized: bool = True, weight: Incomplete | None = None, dtype=..., solver: str = "lu" ): ... def edge_current_flow_betweenness_centrality_subset( - G, - sources, - targets, - normalized: bool = True, - weight: Incomplete | None = None, - dtype=..., - solver: str = "lu", + G, sources, targets, normalized: bool = True, weight: Incomplete | None = None, dtype=..., solver: str = "lu" ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi b/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi index 361d1f04d03c..202594de0604 100644 --- a/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi @@ -1,7 +1,5 @@ from _typeshed import Incomplete -def current_flow_closeness_centrality( - G, weight: Incomplete | None = None, dtype=..., solver: str = "lu" -): ... +def current_flow_closeness_centrality(G, weight: Incomplete | None = None, dtype=..., solver: str = "lu"): ... information_centrality = current_flow_closeness_centrality diff --git a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi index 8af16a02dd72..bed661c10ab4 100644 --- a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi @@ -1,12 +1,6 @@ from _typeshed import Incomplete def eigenvector_centrality( - G, - max_iter: int = 100, - tol: float = 1e-06, - nstart: Incomplete | None = None, - weight: Incomplete | None = None, -): ... -def eigenvector_centrality_numpy( - G, weight: Incomplete | None = None, max_iter: int = 50, tol: int = 0 + G, max_iter: int = 100, tol: float = 1e-06, nstart: Incomplete | None = None, weight: Incomplete | None = None ): ... +def eigenvector_centrality_numpy(G, weight: Incomplete | None = None, max_iter: int = 50, tol: int = 0): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi b/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi index fafcb009111f..d137dab3d66d 100644 --- a/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi @@ -1,9 +1,7 @@ from _typeshed import Incomplete from collections.abc import Generator -def flow_matrix_row( - G, weight: Incomplete | None = None, dtype=..., solver: str = "lu" -) -> Generator[Incomplete, None, None]: ... +def flow_matrix_row(G, weight: Incomplete | None = None, dtype=..., solver: str = "lu") -> Generator[Incomplete, None, None]: ... class InverseLaplacian: dtype: Incomplete @@ -11,9 +9,7 @@ class InverseLaplacian: w: Incomplete C: Incomplete L1: Incomplete - def __init__( - self, L, width: Incomplete | None = None, dtype: Incomplete | None = None - ) -> None: ... + def __init__(self, L, width: Incomplete | None = None, dtype: Incomplete | None = 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/centrality/group.pyi b/stubs/networkx/networkx/algorithms/centrality/group.pyi index 968b397d0295..0b446f548a6e 100644 --- a/stubs/networkx/networkx/algorithms/centrality/group.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/group.pyi @@ -1,12 +1,6 @@ from _typeshed import Incomplete -def group_betweenness_centrality( - G, - C, - normalized: bool = True, - weight: Incomplete | None = None, - endpoints: bool = False, -): ... +def group_betweenness_centrality(G, C, normalized: bool = True, weight: Incomplete | None = None, endpoints: bool = False): ... def prominent_group( G, k, diff --git a/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi b/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi index bc975c6e7fba..3f518c33c1ac 100644 --- a/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi @@ -1,8 +1,5 @@ from _typeshed import Incomplete def harmonic_centrality( - G, - nbunch: Incomplete | None = None, - distance: Incomplete | None = None, - sources: Incomplete | None = None, + G, nbunch: Incomplete | None = None, distance: Incomplete | None = None, sources: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/katz.pyi b/stubs/networkx/networkx/algorithms/centrality/katz.pyi index b9264e9d108b..a557413285e5 100644 --- a/stubs/networkx/networkx/algorithms/centrality/katz.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/katz.pyi @@ -11,9 +11,5 @@ def katz_centrality( weight: Incomplete | None = None, ): ... def katz_centrality_numpy( - G, - alpha: float = 0.1, - beta: float = 1.0, - normalized: bool = True, - weight: Incomplete | None = None, + G, alpha: float = 0.1, beta: float = 1.0, normalized: bool = True, weight: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/load.pyi b/stubs/networkx/networkx/algorithms/centrality/load.pyi index f02830e63e6a..d466e69dde77 100644 --- a/stubs/networkx/networkx/algorithms/centrality/load.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/load.pyi @@ -1,10 +1,6 @@ from _typeshed import Incomplete def newman_betweenness_centrality( - G, - v: Incomplete | None = None, - cutoff: Incomplete | None = None, - normalized: bool = True, - weight: Incomplete | None = None, + G, v: Incomplete | None = None, cutoff: Incomplete | None = None, normalized: bool = True, weight: Incomplete | None = None ): ... def edge_load_centrality(G, cutoff: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/percolation.pyi b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi index 80291b3b8718..5cccd57e1d68 100644 --- a/stubs/networkx/networkx/algorithms/centrality/percolation.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi @@ -1,8 +1,5 @@ from _typeshed import Incomplete def percolation_centrality( - G, - attribute: str = "percolation", - states: Incomplete | None = None, - weight: Incomplete | None = None, + G, attribute: str = "percolation", states: Incomplete | None = None, weight: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/reaching.pyi b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi index 2f1529d975ec..6dca49336a10 100644 --- a/stubs/networkx/networkx/algorithms/centrality/reaching.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi @@ -1,12 +1,6 @@ from _typeshed import Incomplete -def global_reaching_centrality( - G, weight: Incomplete | None = None, normalized: bool = True -): ... +def global_reaching_centrality(G, weight: Incomplete | None = None, normalized: bool = True): ... def local_reaching_centrality( - G, - v, - paths: Incomplete | None = None, - weight: Incomplete | None = None, - normalized: bool = True, + G, v, paths: Incomplete | None = None, weight: Incomplete | None = None, normalized: bool = True ): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/trophic.pyi b/stubs/networkx/networkx/algorithms/centrality/trophic.pyi index d0861ad4aa00..393b4a4bca13 100644 --- a/stubs/networkx/networkx/algorithms/centrality/trophic.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/trophic.pyi @@ -1,5 +1,3 @@ def trophic_levels(G, weight: str = "weight"): ... def trophic_differences(G, weight: str = "weight"): ... -def trophic_incoherence_parameter( - G, weight: str = "weight", cannibalism: bool = False -): ... +def trophic_incoherence_parameter(G, weight: str = "weight", cannibalism: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/chains.pyi b/stubs/networkx/networkx/algorithms/chains.pyi index e9e77253101e..8fad5f76313d 100644 --- a/stubs/networkx/networkx/algorithms/chains.pyi +++ b/stubs/networkx/networkx/algorithms/chains.pyi @@ -2,6 +2,4 @@ from collections.abc import Iterable from networkx.classes.graph import Graph, _Node -def chain_decomposition( - G: Graph[_Node], root: _Node | None = ... -) -> Iterable[tuple[_Node, _Node]]: ... +def chain_decomposition(G: Graph[_Node], root: _Node | None = ...) -> Iterable[tuple[_Node, _Node]]: ... diff --git a/stubs/networkx/networkx/algorithms/chordal.pyi b/stubs/networkx/networkx/algorithms/chordal.pyi index 4150405e6918..0bb2c451cec6 100644 --- a/stubs/networkx/networkx/algorithms/chordal.pyi +++ b/stubs/networkx/networkx/algorithms/chordal.pyi @@ -7,8 +7,6 @@ from networkx.classes.graph import Graph, _Node class NetworkXTreewidthBoundExceeded(nx.NetworkXException): ... def is_chordal(G: Graph[Any]) -> bool: ... -def find_induced_nodes( - G: Graph[_Node], s: _Node, t: _Node, treewidth_bound: int = ... -) -> set[_Node]: ... +def find_induced_nodes(G: Graph[_Node], s: _Node, t: _Node, treewidth_bound: int = ...) -> set[_Node]: ... def chordal_graph_cliques(G: Graph[_Node]) -> Iterable[frozenset[_Node]]: ... def chordal_graph_treewidth(G: Graph[Any]) -> int: ... diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi index 97c816cd7b04..f26559ef2737 100644 --- a/stubs/networkx/networkx/algorithms/clique.pyi +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -3,37 +3,16 @@ from collections.abc import Iterable from networkx.classes.graph import Graph, _Node def enumerate_all_cliques(G: Graph[_Node]) -> Iterable[list[_Node]]: ... -def find_cliques( - G: Graph[_Node], nodes: list[_Node] | None = ... -) -> Iterable[list[_Node]]: ... -def find_cliques_recursive( - G: Graph[_Node], nodes: list[_Node] | None = ... -) -> Iterable[list[_Node]]: ... -def make_max_clique_graph( - G: Graph[_Node], create_using: type[Graph[_Node]] = ... -) -> Graph[_Node]: ... +def find_cliques(G: Graph[_Node], nodes: list[_Node] | None = ...) -> Iterable[list[_Node]]: ... +def find_cliques_recursive(G: Graph[_Node], nodes: list[_Node] | None = ...) -> Iterable[list[_Node]]: ... +def make_max_clique_graph(G: Graph[_Node], create_using: type[Graph[_Node]] = ...) -> Graph[_Node]: ... def make_clique_bipartite( - G: Graph[_Node], - fpos: None = ..., - create_using: type[Graph[_Node]] = ..., - name: None = ..., + G: Graph[_Node], fpos: None = ..., create_using: type[Graph[_Node]] = ..., name: None = ... ) -> Graph[_Node]: ... def graph_clique_number(G: Graph[_Node], cliques: list[_Node] | None = ...) -> int: ... -def graph_number_of_cliques( - G: Graph[_Node], cliques: list[_Node] | None = ... -) -> int: ... -def node_clique_number( - G: Graph[_Node], - nodes: list[_Node] | None = ..., - cliques: list[list[_Node]] | None = ..., -) -> int: ... -def number_of_cliques( - G: Graph[_Node], - nodes: list[_Node] | None = ..., - cliques: list[list[_Node]] | None = ..., -) -> int: ... +def graph_number_of_cliques(G: Graph[_Node], cliques: list[_Node] | None = ...) -> int: ... +def node_clique_number(G: Graph[_Node], nodes: list[_Node] | None = ..., cliques: list[list[_Node]] | None = ...) -> int: ... +def number_of_cliques(G: Graph[_Node], nodes: list[_Node] | None = ..., cliques: list[list[_Node]] | None = ...) -> int: ... def cliques_containing_node( - G: Graph[_Node], - nodes: list[_Node] | None = ..., - cliques: list[list[_Node]] | None = ..., + G: Graph[_Node], nodes: list[_Node] | None = ..., cliques: list[list[_Node]] | None = ... ) -> Iterable[list[_Node]]: ... diff --git a/stubs/networkx/networkx/algorithms/cluster.pyi b/stubs/networkx/networkx/algorithms/cluster.pyi index c654c7df51e6..9e4b5211eb92 100644 --- a/stubs/networkx/networkx/algorithms/cluster.pyi +++ b/stubs/networkx/networkx/algorithms/cluster.pyi @@ -1,15 +1,8 @@ from _typeshed import Incomplete def triangles(G, nodes: Incomplete | None = None): ... -def average_clustering( - G, - nodes: Incomplete | None = None, - weight: Incomplete | None = None, - count_zeros: bool = True, -): ... -def clustering( - G, nodes: Incomplete | None = None, weight: Incomplete | None = None -): ... +def average_clustering(G, nodes: Incomplete | None = None, weight: Incomplete | None = None, count_zeros: bool = True): ... +def clustering(G, nodes: Incomplete | None = None, weight: Incomplete | None = None): ... def transitivity(G): ... def square_clustering(G, nodes: Incomplete | None = None): ... def generalized_degree(G, nodes: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/coloring/__init__.pyi b/stubs/networkx/networkx/algorithms/coloring/__init__.pyi index b6522e602914..da07bcb03d71 100644 --- a/stubs/networkx/networkx/algorithms/coloring/__init__.pyi +++ b/stubs/networkx/networkx/algorithms/coloring/__init__.pyi @@ -1,6 +1,4 @@ -from networkx.algorithms.coloring.equitable_coloring import ( - equitable_color as equitable_color, -) +from networkx.algorithms.coloring.equitable_coloring import equitable_color as equitable_color from networkx.algorithms.coloring.greedy_coloring import * # Names in __all__ with no definition: diff --git a/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi b/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi index 5aed270b2ff7..3b158d16903b 100644 --- a/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi +++ b/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi @@ -7,12 +7,8 @@ def strategy_smallest_last(G, colors): ... def strategy_independent_set(G, colors) -> Generator[Incomplete, Incomplete, None]: ... def strategy_connected_sequential_bfs(G, colors): ... def strategy_connected_sequential_dfs(G, colors): ... -def strategy_connected_sequential( - G, colors, traversal: str = "bfs" -) -> Generator[Incomplete, None, None]: ... -def strategy_saturation_largest_first( - G, colors -) -> Generator[Incomplete, None, Incomplete]: ... +def strategy_connected_sequential(G, colors, traversal: str = "bfs") -> Generator[Incomplete, None, None]: ... +def strategy_saturation_largest_first(G, colors) -> Generator[Incomplete, None, Incomplete]: ... def greedy_color(G, strategy: str = "largest_first", interchange: bool = False): ... class _Node: diff --git a/stubs/networkx/networkx/algorithms/community/centrality.pyi b/stubs/networkx/networkx/algorithms/community/centrality.pyi index afee1196cba1..b3f0e2a6c685 100644 --- a/stubs/networkx/networkx/algorithms/community/centrality.pyi +++ b/stubs/networkx/networkx/algorithms/community/centrality.pyi @@ -1,6 +1,4 @@ from _typeshed import Incomplete from collections.abc import Generator -def girvan_newman( - G, most_valuable_edge: Incomplete | None = None -) -> Generator[Incomplete, None, Incomplete]: ... +def girvan_newman(G, most_valuable_edge: Incomplete | None = None) -> Generator[Incomplete, None, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/community/kclique.pyi b/stubs/networkx/networkx/algorithms/community/kclique.pyi index 31489f8ed3a5..c614fa487c68 100644 --- a/stubs/networkx/networkx/algorithms/community/kclique.pyi +++ b/stubs/networkx/networkx/algorithms/community/kclique.pyi @@ -1,6 +1,4 @@ from _typeshed import Incomplete from collections.abc import Generator -def k_clique_communities( - G, k, cliques: Incomplete | None = None -) -> Generator[Incomplete, None, None]: ... +def k_clique_communities(G, k, cliques: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi b/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi index c006baf208cc..8063bcdd5340 100644 --- a/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi +++ b/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi @@ -1,9 +1,5 @@ from _typeshed import Incomplete def kernighan_lin_bisection( - G, - partition: Incomplete | None = None, - max_iter: int = 10, - weight: str = "weight", - seed: Incomplete | None = None, + G, partition: Incomplete | None = None, max_iter: int = 10, weight: str = "weight", seed: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/community/louvain.pyi b/stubs/networkx/networkx/algorithms/community/louvain.pyi index 2f66d1206144..81145cbb7cf1 100644 --- a/stubs/networkx/networkx/algorithms/community/louvain.pyi +++ b/stubs/networkx/networkx/algorithms/community/louvain.pyi @@ -2,16 +2,8 @@ from _typeshed import Incomplete from collections.abc import Generator def louvain_communities( - G, - weight: str = "weight", - resolution: int = 1, - threshold: float = 1e-07, - seed: Incomplete | None = None, + G, weight: str = "weight", resolution: int = 1, threshold: float = 1e-07, seed: Incomplete | None = None ): ... def louvain_partitions( - G, - weight: str = "weight", - resolution: int = 1, - threshold: float = 1e-07, - seed: Incomplete | None = None, + G, weight: str = "weight", resolution: int = 1, threshold: float = 1e-07, seed: Incomplete | None = None ) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/community/lukes.pyi b/stubs/networkx/networkx/algorithms/community/lukes.pyi index c04b3b6e25c9..bf281313d5c1 100644 --- a/stubs/networkx/networkx/algorithms/community/lukes.pyi +++ b/stubs/networkx/networkx/algorithms/community/lukes.pyi @@ -1,8 +1,3 @@ from _typeshed import Incomplete -def lukes_partitioning( - G, - max_size, - node_weight: Incomplete | None = None, - edge_weight: Incomplete | None = None, -): ... +def lukes_partitioning(G, max_size, node_weight: Incomplete | None = None, edge_weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/community/modularity_max.pyi b/stubs/networkx/networkx/algorithms/community/modularity_max.pyi index efe754946bea..aacc7ab926fc 100644 --- a/stubs/networkx/networkx/algorithms/community/modularity_max.pyi +++ b/stubs/networkx/networkx/algorithms/community/modularity_max.pyi @@ -1,12 +1,6 @@ from _typeshed import Incomplete def greedy_modularity_communities( - G, - weight: Incomplete | None = None, - resolution: int = 1, - cutoff: int = 1, - best_n: Incomplete | None = None, -): ... -def naive_greedy_modularity_communities( - G, resolution: int = 1, weight: Incomplete | None = None + G, weight: Incomplete | None = None, resolution: int = 1, cutoff: int = 1, best_n: Incomplete | None = None ): ... +def naive_greedy_modularity_communities(G, resolution: int = 1, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi index 90bef6de3585..8452bda21ee0 100644 --- a/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi @@ -7,12 +7,8 @@ from networkx.classes.graph import Graph _N = TypeVar("_N") def strongly_connected_components(G: Graph[_N]) -> Iterable[set[_N]]: ... -def kosaraju_strongly_connected_components( - G: Graph[_N], source: _N | None = ... -) -> Iterable[set[_N]]: ... +def kosaraju_strongly_connected_components(G: Graph[_N], source: _N | None = ...) -> Iterable[set[_N]]: ... def strongly_connected_components_recursive(G: Graph[_N]) -> Iterable[set[_N]]: ... def number_strongly_connected_components(G: Graph[Any]) -> int: ... def is_strongly_connected(G: Graph[Any]) -> bool: ... -def condensation( - G: DiGraph[_N], scc: Iterable[set[_N]] | None = ... -) -> DiGraph[int]: ... +def condensation(G: DiGraph[_N], scc: Iterable[set[_N]] | None = ...) -> DiGraph[int]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/__init__.pyi b/stubs/networkx/networkx/algorithms/connectivity/__init__.pyi index 4c218403f17d..4c3ecc33e72d 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/__init__.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/__init__.pyi @@ -1,8 +1,8 @@ from .connectivity import * from .cuts import * +from .disjoint_paths import * from .edge_augmentation import * from .edge_kcomponents import * -from .disjoint_paths import * from .kcomponents import * from .kcutsets import * from .stoerwagner import * diff --git a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi index 65e22e5b10b3..087f9b729dcf 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi @@ -13,16 +13,9 @@ def local_node_connectivity( residual: Incomplete | None = None, cutoff: Incomplete | None = None, ): ... -def node_connectivity( - G, - s: Incomplete | None = None, - t: Incomplete | None = None, - flow_func: Incomplete | None = None, -): ... +def node_connectivity(G, s: Incomplete | None = None, t: Incomplete | None = None, flow_func: Incomplete | None = None): ... def average_node_connectivity(G, flow_func: Incomplete | None = None): ... -def all_pairs_node_connectivity( - G, nbunch: Incomplete | None = None, flow_func: Incomplete | None = None -): ... +def all_pairs_node_connectivity(G, nbunch: Incomplete | None = None, flow_func: Incomplete | None = None): ... def local_edge_connectivity( G, s, diff --git a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi index fe046e89cbd0..4cbe9b12e0ad 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi @@ -5,30 +5,10 @@ from networkx.algorithms.flow import edmonds_karp default_flow_func = edmonds_karp def minimum_st_edge_cut( - G, - s, - t, - flow_func: Incomplete | None = None, - auxiliary: Incomplete | None = None, - residual: Incomplete | None = None, + G, s, t, flow_func: Incomplete | None = None, auxiliary: Incomplete | None = None, residual: Incomplete | None = None ): ... def minimum_st_node_cut( - G, - s, - t, - flow_func: Incomplete | None = None, - auxiliary: Incomplete | None = None, - residual: Incomplete | None = None, -): ... -def minimum_node_cut( - G, - s: Incomplete | None = None, - t: Incomplete | None = None, - flow_func: Incomplete | None = None, -): ... -def minimum_edge_cut( - G, - s: Incomplete | None = None, - t: Incomplete | None = None, - flow_func: Incomplete | None = None, + G, s, t, flow_func: Incomplete | None = None, auxiliary: Incomplete | None = None, residual: Incomplete | None = None ): ... +def minimum_node_cut(G, s: Incomplete | None = None, t: Incomplete | None = None, flow_func: Incomplete | None = None): ... +def minimum_edge_cut(G, s: Incomplete | None = None, t: Incomplete | None = None, flow_func: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi index aa14bdbbce99..1f0aa18cbe0d 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -1,15 +1,13 @@ +from _typeshed import Incomplete from collections.abc import Iterable from typing import Any, TypeVar -from _typeshed import Incomplete from networkx.classes.graph import Graph _N = TypeVar("_N") def is_k_edge_connected(G: Graph[Any], k: int) -> Incomplete: ... -def is_locally_k_edge_connected( - G: Incomplete, s: Incomplete, t: Incomplete, k: Incomplete -) -> Incomplete: ... +def is_locally_k_edge_connected(G: Incomplete, s: Incomplete, t: Incomplete, k: Incomplete) -> Incomplete: ... def k_edge_augmentation( G: Graph[_N], k: int, diff --git a/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi b/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi index 71f2ab76d70b..75a4dc892d35 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi @@ -5,6 +5,4 @@ from networkx.algorithms.flow import edmonds_karp default_flow_func = edmonds_karp -def all_node_cuts( - G, k: Incomplete | None = None, flow_func: Incomplete | None = None -) -> Generator[Incomplete, None, None]: ... +def all_node_cuts(G, k: Incomplete | None = None, flow_func: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/cuts.pyi b/stubs/networkx/networkx/algorithms/cuts.pyi index 9b5f35853b46..1cbf2030dd6e 100644 --- a/stubs/networkx/networkx/algorithms/cuts.pyi +++ b/stubs/networkx/networkx/algorithms/cuts.pyi @@ -2,17 +2,9 @@ from _typeshed import Incomplete def cut_size(G, S, T: Incomplete | None = None, weight: Incomplete | None = None): ... def volume(G, S, weight: Incomplete | None = None): ... -def normalized_cut_size( - G, S, T: Incomplete | None = None, weight: Incomplete | None = None -): ... -def conductance( - G, S, T: Incomplete | None = None, weight: Incomplete | None = None -): ... -def edge_expansion( - G, S, T: Incomplete | None = None, weight: Incomplete | None = None -): ... -def mixing_expansion( - G, S, T: Incomplete | None = None, weight: Incomplete | None = None -): ... +def normalized_cut_size(G, S, T: Incomplete | None = None, weight: Incomplete | None = None): ... +def conductance(G, S, T: Incomplete | None = None, weight: Incomplete | None = None): ... +def edge_expansion(G, S, T: Incomplete | None = None, weight: Incomplete | None = None): ... +def mixing_expansion(G, S, T: Incomplete | None = None, weight: Incomplete | None = None): ... def node_expansion(G, S): ... def boundary_expansion(G, S): ... diff --git a/stubs/networkx/networkx/algorithms/cycles.pyi b/stubs/networkx/networkx/algorithms/cycles.pyi index c47a0f482819..f637db85b096 100644 --- a/stubs/networkx/networkx/algorithms/cycles.pyi +++ b/stubs/networkx/networkx/algorithms/cycles.pyi @@ -2,20 +2,14 @@ from _typeshed import Incomplete from collections.abc import Generator def cycle_basis(G, root: Incomplete | None = None): ... -def simple_cycles( - G, length_bound: Incomplete | None = None -) -> Generator[Incomplete, Incomplete, None]: ... +def simple_cycles(G, length_bound: Incomplete | None = None) -> Generator[Incomplete, Incomplete, None]: ... class _NeighborhoodCache(dict[Incomplete, Incomplete]): G: Incomplete def __init__(self, G) -> None: ... def __missing__(self, v): ... -def chordless_cycles( - G, length_bound: Incomplete | None = None -) -> Generator[Incomplete, Incomplete, None]: ... +def chordless_cycles(G, length_bound: Incomplete | None = None) -> Generator[Incomplete, Incomplete, None]: ... def recursive_simple_cycles(G): ... -def find_cycle( - G, source: Incomplete | None = None, orientation: Incomplete | None = None -): ... +def find_cycle(G, source: Incomplete | None = None, orientation: Incomplete | None = None): ... def minimum_cycle_basis(G, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/dag.pyi b/stubs/networkx/networkx/algorithms/dag.pyi index 746924c435f0..d56a9f1bf075 100644 --- a/stubs/networkx/networkx/algorithms/dag.pyi +++ b/stubs/networkx/networkx/algorithms/dag.pyi @@ -1,6 +1,6 @@ +from _typeshed import Incomplete from typing import TypeVar -from _typeshed import Incomplete from networkx.classes.graph import Graph _T = TypeVar("_T") @@ -9,18 +9,12 @@ def descendants(G: Graph[_T], source: _T) -> set[_T]: ... def ancestors(G: Graph[_T], source: _T) -> set[_T]: ... def is_directed_acyclic_graph(G: Incomplete) -> Incomplete: ... def topological_sort(G: Incomplete) -> None: ... -def lexicographical_topological_sort( - G: Incomplete, key: Incomplete | None = ... -) -> Incomplete: ... +def lexicographical_topological_sort(G: Incomplete, key: Incomplete | None = ...) -> Incomplete: ... def all_topological_sorts(G: Incomplete) -> None: ... def is_aperiodic(G: Incomplete) -> Incomplete: ... def transitive_closure(G: Incomplete) -> Incomplete: ... def transitive_reduction(G: Incomplete) -> Incomplete: ... def antichains(G: Incomplete) -> None: ... -def dag_longest_path( - G: Incomplete, weight: str = ..., default_weight: int = ... -) -> Incomplete: ... -def dag_longest_path_length( - G: Incomplete, weight: str = ..., default_weight: int = ... -) -> Incomplete: ... +def dag_longest_path(G: Incomplete, weight: str = ..., default_weight: int = ...) -> Incomplete: ... +def dag_longest_path_length(G: Incomplete, weight: str = ..., default_weight: int = ...) -> Incomplete: ... def dag_to_branching(G: Incomplete) -> Incomplete: ... diff --git a/stubs/networkx/networkx/algorithms/distance_measures.pyi b/stubs/networkx/networkx/algorithms/distance_measures.pyi index 29e076eb4b21..0119b424ec61 100644 --- a/stubs/networkx/networkx/algorithms/distance_measures.pyi +++ b/stubs/networkx/networkx/algorithms/distance_measures.pyi @@ -1,41 +1,9 @@ from _typeshed import Incomplete -def eccentricity( - G, - v: Incomplete | None = None, - sp: Incomplete | None = None, - weight: Incomplete | None = None, -): ... -def diameter( - G, - e: Incomplete | None = None, - usebounds: bool = False, - weight: Incomplete | None = None, -): ... -def periphery( - G, - e: Incomplete | None = None, - usebounds: bool = False, - weight: Incomplete | None = None, -): ... -def radius( - G, - e: Incomplete | None = None, - usebounds: bool = False, - weight: Incomplete | None = None, -): ... -def center( - G, - e: Incomplete | None = None, - usebounds: bool = False, - weight: Incomplete | None = None, -): ... -def barycenter( - G, - weight: Incomplete | None = None, - attr: Incomplete | None = None, - sp: Incomplete | None = None, -): ... -def resistance_distance( - G, nodeA, nodeB, weight: Incomplete | None = None, invert_weight: bool = True -): ... +def eccentricity(G, v: Incomplete | None = None, sp: Incomplete | None = None, weight: Incomplete | None = None): ... +def diameter(G, e: Incomplete | None = None, usebounds: bool = False, weight: Incomplete | None = None): ... +def periphery(G, e: Incomplete | None = None, usebounds: bool = False, weight: Incomplete | None = None): ... +def radius(G, e: Incomplete | None = None, usebounds: bool = False, weight: Incomplete | None = None): ... +def center(G, e: Incomplete | None = None, usebounds: bool = False, weight: Incomplete | None = None): ... +def barycenter(G, weight: Incomplete | None = None, attr: Incomplete | None = None, sp: Incomplete | None = None): ... +def resistance_distance(G, nodeA, nodeB, weight: Incomplete | None = None, invert_weight: bool = True): ... diff --git a/stubs/networkx/networkx/algorithms/euler.pyi b/stubs/networkx/networkx/algorithms/euler.pyi index 72b40863e560..73120e1b1ca6 100644 --- a/stubs/networkx/networkx/algorithms/euler.pyi +++ b/stubs/networkx/networkx/algorithms/euler.pyi @@ -3,11 +3,7 @@ from collections.abc import Generator def is_eulerian(G): ... def is_semieulerian(G): ... -def eulerian_circuit( - G, source: Incomplete | None = None, keys: bool = False -) -> Generator[Incomplete, Incomplete, None]: ... +def eulerian_circuit(G, source: Incomplete | None = None, keys: bool = False) -> Generator[Incomplete, Incomplete, None]: ... def has_eulerian_path(G, source: Incomplete | None = None): ... -def eulerian_path( - G, source: Incomplete | None = None, keys: bool = False -) -> Generator[Incomplete, Incomplete, None]: ... +def eulerian_path(G, source: Incomplete | None = None, keys: bool = False) -> Generator[Incomplete, Incomplete, None]: ... def eulerize(G): ... diff --git a/stubs/networkx/networkx/algorithms/flow/__init__.pyi b/stubs/networkx/networkx/algorithms/flow/__init__.pyi index a8659092bfba..a5ac3895e457 100644 --- a/stubs/networkx/networkx/algorithms/flow/__init__.pyi +++ b/stubs/networkx/networkx/algorithms/flow/__init__.pyi @@ -8,7 +8,4 @@ from .mincost import * from .networksimplex import * from .preflowpush import * from .shortestaugmentingpath import * -from .utils import ( - build_flow_dict as build_flow_dict, - build_residual_network as build_residual_network, -) +from .utils import build_flow_dict as build_flow_dict, build_residual_network as build_residual_network diff --git a/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi b/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi index ca489742b135..cffacb633a68 100644 --- a/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi +++ b/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi @@ -1,7 +1 @@ -def capacity_scaling( - G, - demand: str = "demand", - capacity: str = "capacity", - weight: str = "weight", - heap=..., -): ... +def capacity_scaling(G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight", heap=...): ... diff --git a/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi b/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi index c4b78d0b1a5f..15fbf39209fe 100644 --- a/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi +++ b/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi @@ -4,6 +4,4 @@ from .edmondskarp import edmonds_karp default_flow_func = edmonds_karp -def gomory_hu_tree( - G, capacity: str = "capacity", flow_func: Incomplete | None = None -): ... +def gomory_hu_tree(G, capacity: str = "capacity", flow_func: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/flow/maxflow.pyi b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi index 7bcf5ce17aaa..19415fe84718 100644 --- a/stubs/networkx/networkx/algorithms/flow/maxflow.pyi +++ b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi @@ -4,35 +4,7 @@ from .preflowpush import preflow_push default_flow_func = preflow_push -def maximum_flow( - flowG, - _s, - _t, - capacity: str = "capacity", - flow_func: Incomplete | None = None, - **kwargs -): ... -def maximum_flow_value( - flowG, - _s, - _t, - capacity: str = "capacity", - flow_func: Incomplete | None = None, - **kwargs -): ... -def minimum_cut( - flowG, - _s, - _t, - capacity: str = "capacity", - flow_func: Incomplete | None = None, - **kwargs -): ... -def minimum_cut_value( - flowG, - _s, - _t, - capacity: str = "capacity", - flow_func: Incomplete | None = None, - **kwargs -): ... +def maximum_flow(flowG, _s, _t, capacity: str = "capacity", flow_func: Incomplete | None = None, **kwargs): ... +def maximum_flow_value(flowG, _s, _t, capacity: str = "capacity", flow_func: Incomplete | None = None, **kwargs): ... +def minimum_cut(flowG, _s, _t, capacity: str = "capacity", flow_func: Incomplete | None = None, **kwargs): ... +def minimum_cut_value(flowG, _s, _t, capacity: str = "capacity", flow_func: Incomplete | None = None, **kwargs): ... diff --git a/stubs/networkx/networkx/algorithms/flow/mincost.pyi b/stubs/networkx/networkx/algorithms/flow/mincost.pyi index 8a480fb4dd5c..4f441965ae0a 100644 --- a/stubs/networkx/networkx/algorithms/flow/mincost.pyi +++ b/stubs/networkx/networkx/algorithms/flow/mincost.pyi @@ -1,8 +1,4 @@ -def min_cost_flow_cost( - G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight" -): ... -def min_cost_flow( - G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight" -): ... +def min_cost_flow_cost(G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... +def min_cost_flow(G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... def cost_of_flow(G, flowDict, weight: str = "weight"): ... def max_flow_min_cost(G, s, t, capacity: str = "capacity", weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi b/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi index 767d70ba174c..0039ca0ade8c 100644 --- a/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi +++ b/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi @@ -20,14 +20,7 @@ class _DataEssentialsAndFunctions: next_node_dft: Incomplete prev_node_dft: Incomplete last_descendent_dft: Incomplete - def __init__( - self, - G, - multigraph, - demand: str = "demand", - capacity: str = "capacity", - weight: str = "weight", - ) -> None: ... + def __init__(self, G, multigraph, demand: str = "demand", capacity: str = "capacity", weight: str = "weight") -> None: ... def initialize_spanning_tree(self, n, faux_inf) -> None: ... def find_apex(self, p, q): ... def trace_path(self, p, w): ... @@ -43,6 +36,4 @@ class _DataEssentialsAndFunctions: def residual_capacity(self, i, p): ... def find_leaving_edge(self, Wn, We): ... -def network_simplex( - G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight" -): ... +def network_simplex(G, demand: str = "demand", capacity: str = "capacity", weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/graph_hashing.pyi b/stubs/networkx/networkx/algorithms/graph_hashing.pyi index b840beee06ae..e2fd08c037e7 100644 --- a/stubs/networkx/networkx/algorithms/graph_hashing.pyi +++ b/stubs/networkx/networkx/algorithms/graph_hashing.pyi @@ -1,16 +1,8 @@ from _typeshed import Incomplete def weisfeiler_lehman_graph_hash( - G, - edge_attr: Incomplete | None = None, - node_attr: Incomplete | None = None, - iterations: int = 3, - digest_size: int = 16, + G, edge_attr: Incomplete | None = None, node_attr: Incomplete | None = None, iterations: int = 3, digest_size: int = 16 ): ... def weisfeiler_lehman_subgraph_hashes( - G, - edge_attr: Incomplete | None = None, - node_attr: Incomplete | None = None, - iterations: int = 3, - digest_size: int = 16, + G, edge_attr: Incomplete | None = None, node_attr: Incomplete | None = None, iterations: int = 3, digest_size: int = 16 ): ... diff --git a/stubs/networkx/networkx/algorithms/hybrid.pyi b/stubs/networkx/networkx/algorithms/hybrid.pyi index b46e569849ce..df5f4bcd0530 100644 --- a/stubs/networkx/networkx/algorithms/hybrid.pyi +++ b/stubs/networkx/networkx/algorithms/hybrid.pyi @@ -1,4 +1,2 @@ -def kl_connected_subgraph( - G, k, l, low_memory: bool = False, same_as_graph: bool = False -): ... +def kl_connected_subgraph(G, k, l, low_memory: bool = False, same_as_graph: bool = False): ... def is_kl_connected(G, k, l, low_memory: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi index 1f123f1507d9..259d9f7735ce 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi @@ -14,16 +14,10 @@ class ISMAGS: 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 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 isomorphisms_iter( - self, symmetry: bool = True - ) -> Generator[Incomplete, Incomplete, None]: ... + 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/isomorph.pyi b/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi index 32c5b4416295..553f6721c0be 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi @@ -12,6 +12,4 @@ def faster_could_be_isomorphic(G1, G2): ... faster_graph_could_be_isomorphic = faster_could_be_isomorphic -def is_isomorphic( - G1, G2, node_match: Incomplete | None = None, edge_match: Incomplete | None = None -): ... +def is_isomorphic(G1, G2, node_match: Incomplete | None = None, edge_match: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi b/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi index 6c9d612db641..36ac0550fe58 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi @@ -26,9 +26,7 @@ class GraphMatcher: def subgraph_is_isomorphic(self): ... def subgraph_is_monomorphic(self): ... def subgraph_isomorphisms_iter(self) -> Generator[Incomplete, Incomplete, None]: ... - def subgraph_monomorphisms_iter( - self, - ) -> Generator[Incomplete, Incomplete, None]: ... + def subgraph_monomorphisms_iter(self) -> Generator[Incomplete, Incomplete, None]: ... def syntactic_feasibility(self, G1_node, G2_node): ... class DiGraphMatcher(GraphMatcher): @@ -50,9 +48,7 @@ class GMState: G1_node: Incomplete G2_node: Incomplete depth: Incomplete - def __init__( - self, GM, G1_node: Incomplete | None = None, G2_node: Incomplete | None = None - ) -> None: ... + def __init__(self, GM, G1_node: Incomplete | None = None, G2_node: Incomplete | None = None) -> None: ... def restore(self) -> None: ... class DiGMState: @@ -60,7 +56,5 @@ class DiGMState: G1_node: Incomplete G2_node: Incomplete depth: Incomplete - def __init__( - self, GM, G1_node: Incomplete | None = None, G2_node: Incomplete | None = None - ) -> None: ... + def __init__(self, GM, G1_node: Incomplete | None = None, G2_node: Incomplete | None = None) -> None: ... def restore(self) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi b/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi index f65c9817294d..0b525aafef54 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi @@ -9,9 +9,7 @@ def numerical_node_match(attr, default, rtol: float = 1e-05, atol: float = 1e-08 numerical_edge_match: Incomplete -def numerical_multiedge_match( - attr, default, rtol: float = 1e-05, atol: float = 1e-08 -): ... +def numerical_multiedge_match(attr, default, rtol: float = 1e-05, atol: float = 1e-08): ... def generic_node_match(attr, default, op): ... generic_edge_match: Incomplete diff --git a/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi b/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi index 88d3cdb7b9b3..5783920145b6 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi @@ -23,21 +23,8 @@ class _StateParameters(NamedTuple): T2_tilde: Incomplete T2_tilde_in: Incomplete -def vf2pp_isomorphism( - G1, - G2, - node_label: Incomplete | None = None, - default_label: Incomplete | None = None, -): ... -def vf2pp_is_isomorphic( - G1, - G2, - node_label: Incomplete | None = None, - default_label: Incomplete | None = None, -): ... +def vf2pp_isomorphism(G1, G2, node_label: Incomplete | None = None, default_label: Incomplete | None = None): ... +def vf2pp_is_isomorphic(G1, G2, node_label: Incomplete | None = None, default_label: Incomplete | None = None): ... def vf2pp_all_isomorphisms( - G1, - G2, - node_label: Incomplete | None = None, - default_label: Incomplete | None = None, + G1, G2, node_label: Incomplete | None = None, default_label: Incomplete | None = None ) -> Generator[Incomplete, None, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi b/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi index f908ee333979..79cb3ab7a02d 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi @@ -7,13 +7,7 @@ class GraphMatcher(vf2.GraphMatcher): edge_match: Incomplete G1_adj: Incomplete G2_adj: Incomplete - def __init__( - self, - G1, - G2, - node_match: Incomplete | None = None, - edge_match: Incomplete | None = None, - ) -> None: ... + def __init__(self, G1, G2, node_match: Incomplete | None = None, edge_match: Incomplete | None = None) -> None: ... semantic_feasibility: Incomplete class DiGraphMatcher(vf2.DiGraphMatcher): @@ -21,13 +15,7 @@ class DiGraphMatcher(vf2.DiGraphMatcher): edge_match: Incomplete G1_adj: Incomplete G2_adj: Incomplete - def __init__( - self, - G1, - G2, - node_match: Incomplete | None = None, - edge_match: Incomplete | None = None, - ) -> None: ... + def __init__(self, G1, G2, node_match: Incomplete | None = None, edge_match: Incomplete | None = None) -> None: ... def semantic_feasibility(self, G1_node, G2_node): ... class MultiGraphMatcher(GraphMatcher): ... diff --git a/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi b/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi index 96a6270d174a..7eccedf802ce 100644 --- a/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi +++ b/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi @@ -1,9 +1,3 @@ from _typeshed import Incomplete -def hits( - G, - max_iter: int = 100, - tol: float = 1e-08, - nstart: Incomplete | None = None, - normalized: bool = True, -): ... +def hits(G, max_iter: int = 100, tol: float = 1e-08, nstart: Incomplete | None = None, normalized: bool = True): ... diff --git a/stubs/networkx/networkx/algorithms/link_prediction.pyi b/stubs/networkx/networkx/algorithms/link_prediction.pyi index eb831afc69b7..69082e00d8b4 100644 --- a/stubs/networkx/networkx/algorithms/link_prediction.pyi +++ b/stubs/networkx/networkx/algorithms/link_prediction.pyi @@ -3,19 +3,8 @@ from _typeshed import Incomplete def resource_allocation_index(G, ebunch: Incomplete | None = None): ... def jaccard_coefficient(G, ebunch: Incomplete | None = None): ... def adamic_adar_index(G, ebunch: Incomplete | None = None): ... -def common_neighbor_centrality( - G, ebunch: Incomplete | None = None, alpha: float = 0.8 -): ... +def common_neighbor_centrality(G, ebunch: Incomplete | None = None, alpha: float = 0.8): ... def preferential_attachment(G, ebunch: Incomplete | None = None): ... -def cn_soundarajan_hopcroft( - G, ebunch: Incomplete | None = None, community: str = "community" -): ... -def ra_index_soundarajan_hopcroft( - G, ebunch: Incomplete | None = None, community: str = "community" -): ... -def within_inter_cluster( - G, - ebunch: Incomplete | None = None, - delta: float = 0.001, - community: str = "community", -): ... +def cn_soundarajan_hopcroft(G, ebunch: Incomplete | None = None, community: str = "community"): ... +def ra_index_soundarajan_hopcroft(G, ebunch: Incomplete | None = None, community: str = "community"): ... +def within_inter_cluster(G, ebunch: Incomplete | None = None, delta: float = 0.001, community: str = "community"): ... diff --git a/stubs/networkx/networkx/algorithms/mis.pyi b/stubs/networkx/networkx/algorithms/mis.pyi index 9601a5a745ab..e4b46e6c52cf 100644 --- a/stubs/networkx/networkx/algorithms/mis.pyi +++ b/stubs/networkx/networkx/algorithms/mis.pyi @@ -1,5 +1,3 @@ from _typeshed import Incomplete -def maximal_independent_set( - G, nodes: Incomplete | None = None, seed: Incomplete | None = None -): ... +def maximal_independent_set(G, nodes: Incomplete | None = None, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/node_classification.pyi b/stubs/networkx/networkx/algorithms/node_classification.pyi index 312054755f89..14d8a769c21c 100644 --- a/stubs/networkx/networkx/algorithms/node_classification.pyi +++ b/stubs/networkx/networkx/algorithms/node_classification.pyi @@ -1,4 +1,2 @@ def harmonic_function(G, max_iter: int = 30, label_name: str = "label"): ... -def local_and_global_consistency( - G, alpha: float = 0.99, max_iter: int = 30, label_name: str = "label" -): ... +def local_and_global_consistency(G, alpha: float = 0.99, max_iter: int = 30, label_name: str = "label"): ... diff --git a/stubs/networkx/networkx/algorithms/operators/binary.pyi b/stubs/networkx/networkx/algorithms/operators/binary.pyi index 9796f469ad3b..16f99208d387 100644 --- a/stubs/networkx/networkx/algorithms/operators/binary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/binary.pyi @@ -1,6 +1,6 @@ +from _typeshed import Incomplete from typing import TypeVar -from _typeshed import Incomplete from networkx.classes.digraph import DiGraph def disjoint_union(G: Incomplete, H: Incomplete) -> Incomplete: ... @@ -14,9 +14,4 @@ _Y = TypeVar("_Y", covariant=True) # TODO: This does not handle the cases when graphs of different types are passed which is allowed def compose(G: DiGraph[_X], H: DiGraph[_Y]) -> DiGraph[_X | _Y]: ... -def union( - G: DiGraph[_X], - H: DiGraph[_Y], - rename: Incomplete = ..., - name: Incomplete | None = ..., -) -> DiGraph[_X | _Y]: ... +def union(G: DiGraph[_X], H: DiGraph[_Y], rename: Incomplete = ..., name: Incomplete | None = ...) -> DiGraph[_X | _Y]: ... diff --git a/stubs/networkx/networkx/algorithms/operators/unary.pyi b/stubs/networkx/networkx/algorithms/operators/unary.pyi index c255e7205ae3..945866c9320f 100644 --- a/stubs/networkx/networkx/algorithms/operators/unary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/unary.pyi @@ -1,6 +1,6 @@ +from _typeshed import Incomplete from typing import TypeVar -from _typeshed import Incomplete from networkx.classes.digraph import DiGraph _T = TypeVar("_T") diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index d64ed20a65b3..7f1aee2697e3 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -1,8 +1,8 @@ +from _typeshed import Incomplete from collections.abc import Iterable from typing import Generic, TypeVar import networkx as nx -from _typeshed import Incomplete def check_planarity(G: Incomplete, counterexample: bool = ...) -> Incomplete: ... @@ -11,9 +11,7 @@ _N = TypeVar("_N") class Interval: low: Incomplete = ... high: Incomplete = ... - def __init__( - self, low: Incomplete | None = ..., high: Incomplete | None = ... - ) -> None: ... + def __init__(self, low: Incomplete | None = ..., high: Incomplete | None = ...) -> None: ... def empty(self) -> Incomplete: ... def copy(self) -> Incomplete: ... def conflicting(self, b: Incomplete, planarity_state: Incomplete) -> Incomplete: ... @@ -63,16 +61,10 @@ class PlanarEmbedding(Generic[_N], nx.DiGraph[_N]): def set_data(self, data: dict[_N, list[_N]]) -> None: ... def neighbors_cw_order(self, v: _N) -> Iterable[_N]: ... def check_structure(self) -> None: ... - def add_half_edge_ccw( - self, start_node: _N, end_node: _N, reference_neighbor: _N - ) -> None: ... - def add_half_edge_cw( - self, start_node: _N, end_node: _N, reference_neighbor: _N - ) -> None: ... + def add_half_edge_ccw(self, start_node: _N, end_node: _N, reference_neighbor: _N) -> None: ... + def add_half_edge_cw(self, start_node: _N, end_node: _N, reference_neighbor: _N) -> None: ... def connect_components(self, v: _N, w: _N) -> None: ... def add_half_edge_first(self, start_node: _N, end_node: _N) -> None: ... def next_face_half_edge(self, v: _N, w: _N) -> tuple[_N, _N]: ... - def traverse_face( - self, v: _N, w: _N, mark_half_edges: set[tuple[_N, _N]] | None = ... - ) -> list[_N]: ... + def traverse_face(self, v: _N, w: _N, mark_half_edges: set[tuple[_N, _N]] | None = ...) -> list[_N]: ... def is_directed(self) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/richclub.pyi b/stubs/networkx/networkx/algorithms/richclub.pyi index 528d42cb3c3c..0e5093a45278 100644 --- a/stubs/networkx/networkx/algorithms/richclub.pyi +++ b/stubs/networkx/networkx/algorithms/richclub.pyi @@ -1,5 +1,3 @@ from _typeshed import Incomplete -def rich_club_coefficient( - G, normalized: bool = True, Q: int = 100, seed: Incomplete | None = None -): ... +def rich_club_coefficient(G, normalized: bool = True, Q: int = 100, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi index fd118e3836ce..4394432a7645 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi @@ -1,8 +1,4 @@ from _typeshed import Incomplete -def astar_path( - G, source, target, heuristic: Incomplete | None = None, weight: str = "weight" -): ... -def astar_path_length( - G, source, target, heuristic: Incomplete | None = None, weight: str = "weight" -): ... +def astar_path(G, source, target, heuristic: Incomplete | None = None, weight: str = "weight"): ... +def astar_path_length(G, source, target, heuristic: Incomplete | None = None, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi index 3c8b52392e85..a931da0ec84e 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi @@ -1,8 +1,6 @@ from _typeshed import Incomplete -def floyd_warshall_numpy( - G, nodelist: Incomplete | None = None, weight: str = "weight" -): ... +def floyd_warshall_numpy(G, nodelist: Incomplete | None = None, weight: str = "weight"): ... def floyd_warshall_predecessor_and_distance(G, weight: str = "weight"): ... def reconstruct_path(source, target, predecessors): ... def floyd_warshall(G, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi index ac0bc9abfa93..56cda1d10ecb 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi @@ -1,28 +1,18 @@ +from _typeshed import Incomplete from collections.abc import Iterable from typing import TypeVar, overload -from _typeshed import Incomplete from networkx.classes.graph import Graph _T = TypeVar("_T") def has_path(G: Incomplete, source: Incomplete, target: Incomplete) -> Incomplete: ... @overload -def shortest_path( - G: Graph[_T], - source: _T, - target: _T, - weight: Incomplete | None = ..., - method: str = ..., -) -> list[_T]: ... +def shortest_path(G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = ..., method: str = ...) -> list[_T]: ... @overload -def shortest_path( - G: Graph[_T], target: _T, method: str = ... -) -> dict[_T, list[_T]]: ... +def shortest_path(G: Graph[_T], target: _T, method: str = ...) -> dict[_T, list[_T]]: ... @overload -def shortest_path( - G: Graph[_T], source: _T, method: str = ... -) -> dict[_T, list[_T]]: ... +def shortest_path(G: Graph[_T], source: _T, method: str = ...) -> dict[_T, list[_T]]: ... def shortest_path_length( G: Incomplete, source: Incomplete | None = ..., @@ -30,13 +20,7 @@ def shortest_path_length( weight: Incomplete | None = ..., method: str = ..., ) -> Incomplete: ... -def average_shortest_path_length( - G: Incomplete, weight: Incomplete | None = ..., method: str = ... -) -> Incomplete: ... +def average_shortest_path_length(G: Incomplete, weight: Incomplete | None = ..., method: str = ...) -> Incomplete: ... def all_shortest_paths( - G: Graph[_T], - source: _T, - target: _T, - weight: Incomplete | None = ..., - method: str = ..., + G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = ..., method: str = ... ) -> Iterable[list[_T]]: ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi index 76eb9e9df3dc..706c04a6d62f 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi @@ -3,19 +3,11 @@ from collections.abc import Generator def single_source_shortest_path_length(G, source, cutoff: Incomplete | None = None): ... def single_target_shortest_path_length(G, target, cutoff: Incomplete | None = None): ... -def all_pairs_shortest_path_length( - G, cutoff: Incomplete | None = None -) -> Generator[Incomplete, None, None]: ... +def all_pairs_shortest_path_length(G, cutoff: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... def bidirectional_shortest_path(G, source, target): ... def single_source_shortest_path(G, source, cutoff: Incomplete | None = None): ... def single_target_shortest_path(G, target, cutoff: Incomplete | None = None): ... -def all_pairs_shortest_path( - G, cutoff: Incomplete | None = None -) -> Generator[Incomplete, None, None]: ... +def all_pairs_shortest_path(G, cutoff: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... def predecessor( - G, - source, - target: Incomplete | None = None, - cutoff: Incomplete | None = None, - return_seen: Incomplete | None = None, + G, source, target: Incomplete | None = None, cutoff: Incomplete | None = None, return_seen: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi index c67772b42a4f..43bcb9a502db 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi @@ -3,64 +3,32 @@ from collections.abc import Generator def dijkstra_path(G, source, target, weight: str = "weight"): ... def dijkstra_path_length(G, source, target, weight: str = "weight"): ... -def single_source_dijkstra_path( - G, source, cutoff: Incomplete | None = None, weight: str = "weight" -): ... -def single_source_dijkstra_path_length( - G, source, cutoff: Incomplete | None = None, weight: str = "weight" -): ... +def single_source_dijkstra_path(G, source, cutoff: Incomplete | None = None, weight: str = "weight"): ... +def single_source_dijkstra_path_length(G, source, cutoff: Incomplete | None = None, weight: str = "weight"): ... def single_source_dijkstra( - G, - source, - target: Incomplete | None = None, - cutoff: Incomplete | None = None, - weight: str = "weight", -): ... -def multi_source_dijkstra_path( - G, sources, cutoff: Incomplete | None = None, weight: str = "weight" -): ... -def multi_source_dijkstra_path_length( - G, sources, cutoff: Incomplete | None = None, weight: str = "weight" + G, source, target: Incomplete | None = None, cutoff: Incomplete | None = None, weight: str = "weight" ): ... +def multi_source_dijkstra_path(G, sources, cutoff: Incomplete | None = None, weight: str = "weight"): ... +def multi_source_dijkstra_path_length(G, sources, cutoff: Incomplete | None = None, weight: str = "weight"): ... def multi_source_dijkstra( - G, - sources, - target: Incomplete | None = None, - cutoff: Incomplete | None = None, - weight: str = "weight", -): ... -def dijkstra_predecessor_and_distance( - G, source, cutoff: Incomplete | None = None, weight: str = "weight" + G, sources, target: Incomplete | None = None, cutoff: Incomplete | None = None, weight: str = "weight" ): ... -def all_pairs_dijkstra( - G, cutoff: Incomplete | None = None, weight: str = "weight" -) -> Generator[Incomplete, None, None]: ... +def dijkstra_predecessor_and_distance(G, source, cutoff: Incomplete | None = None, weight: str = "weight"): ... +def all_pairs_dijkstra(G, cutoff: Incomplete | None = None, weight: str = "weight") -> Generator[Incomplete, None, None]: ... def all_pairs_dijkstra_path_length( G, cutoff: Incomplete | None = None, weight: str = "weight" ) -> Generator[Incomplete, None, None]: ... -def all_pairs_dijkstra_path( - G, cutoff: Incomplete | None = None, weight: str = "weight" -) -> Generator[Incomplete, None, None]: ... +def all_pairs_dijkstra_path(G, cutoff: Incomplete | None = None, weight: str = "weight") -> Generator[Incomplete, None, None]: ... def bellman_ford_predecessor_and_distance( - G, - source, - target: Incomplete | None = None, - weight: str = "weight", - heuristic: bool = False, + G, source, target: Incomplete | None = None, weight: str = "weight", heuristic: bool = False ): ... def bellman_ford_path(G, source, target, weight: str = "weight"): ... def bellman_ford_path_length(G, source, target, weight: str = "weight"): ... def single_source_bellman_ford_path(G, source, weight: str = "weight"): ... def single_source_bellman_ford_path_length(G, source, weight: str = "weight"): ... -def single_source_bellman_ford( - G, source, target: Incomplete | None = None, weight: str = "weight" -): ... -def all_pairs_bellman_ford_path_length( - G, weight: str = "weight" -) -> Generator[Incomplete, None, None]: ... -def all_pairs_bellman_ford_path( - G, weight: str = "weight" -) -> Generator[Incomplete, None, None]: ... +def single_source_bellman_ford(G, source, target: Incomplete | None = None, weight: str = "weight"): ... +def all_pairs_bellman_ford_path_length(G, weight: str = "weight") -> Generator[Incomplete, None, None]: ... +def all_pairs_bellman_ford_path(G, weight: str = "weight") -> Generator[Incomplete, None, None]: ... def goldberg_radzik(G, source, weight: str = "weight"): ... def negative_edge_cycle(G, weight: str = "weight", heuristic: bool = True): ... def find_negative_cycle(G, source, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/algorithms/similarity.pyi b/stubs/networkx/networkx/algorithms/similarity.pyi index d1a6f6a5a2fe..f18150d09052 100644 --- a/stubs/networkx/networkx/algorithms/similarity.pyi +++ b/stubs/networkx/networkx/algorithms/similarity.pyi @@ -67,13 +67,7 @@ def simrank_similarity( tolerance: float = 0.0001, ): ... def panther_similarity( - G, - source, - k: int = 5, - path_length: int = 5, - c: float = 0.5, - delta: float = 0.1, - eps: Incomplete | None = None, + G, source, k: int = 5, path_length: int = 5, c: float = 0.5, delta: float = 0.1, eps: Incomplete | None = None ): ... def generate_random_paths( G, sample_size, path_length: int = 5, index_map: Incomplete | None = None diff --git a/stubs/networkx/networkx/algorithms/simple_paths.pyi b/stubs/networkx/networkx/algorithms/simple_paths.pyi index 16c63db76606..622ad547fb62 100644 --- a/stubs/networkx/networkx/algorithms/simple_paths.pyi +++ b/stubs/networkx/networkx/algorithms/simple_paths.pyi @@ -1,18 +1,14 @@ +from _typeshed import Incomplete from collections.abc import Iterator from typing import TypeVar -from _typeshed import Incomplete from networkx.classes.graph import Graph _T = TypeVar("_T") def is_simple_path(G: Graph[_T], nodes: list[_T]) -> Incomplete: ... -def all_simple_paths( - G: Graph[_T], source: _T, target: _T, cutoff: Incomplete | None = ... -) -> Iterator[list[_T]]: ... -def shortest_simple_paths( - G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = ... -) -> Iterator[list[_T]]: ... +def all_simple_paths(G: Graph[_T], source: _T, target: _T, cutoff: Incomplete | None = ...) -> Iterator[list[_T]]: ... +def shortest_simple_paths(G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = ...) -> Iterator[list[_T]]: ... class PathBuffer: paths: Incomplete = ... diff --git a/stubs/networkx/networkx/algorithms/smallworld.pyi b/stubs/networkx/networkx/algorithms/smallworld.pyi index f4525c0550ac..baa6acb25a4a 100644 --- a/stubs/networkx/networkx/algorithms/smallworld.pyi +++ b/stubs/networkx/networkx/algorithms/smallworld.pyi @@ -1,14 +1,8 @@ from _typeshed import Incomplete -def random_reference( - G, niter: int = 1, connectivity: bool = True, seed: Incomplete | None = None -): ... +def random_reference(G, niter: int = 1, connectivity: bool = True, seed: Incomplete | None = None): ... def lattice_reference( - G, - niter: int = 5, - D: Incomplete | None = None, - connectivity: bool = True, - seed: Incomplete | None = None, + G, niter: int = 5, D: Incomplete | None = None, connectivity: bool = True, seed: Incomplete | None = None ): ... def sigma(G, niter: int = 100, nrand: int = 10, seed: Incomplete | None = None): ... def omega(G, niter: int = 5, nrand: int = 10, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/sparsifiers.pyi b/stubs/networkx/networkx/algorithms/sparsifiers.pyi index 0d17140307a7..6c37f812509f 100644 --- a/stubs/networkx/networkx/algorithms/sparsifiers.pyi +++ b/stubs/networkx/networkx/algorithms/sparsifiers.pyi @@ -1,5 +1,3 @@ from _typeshed import Incomplete -def spanner( - G, stretch, weight: Incomplete | None = None, seed: Incomplete | None = None -): ... +def spanner(G, stretch, weight: Incomplete | None = None, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/structuralholes.pyi b/stubs/networkx/networkx/algorithms/structuralholes.pyi index 48023e121730..c1f587134fdd 100644 --- a/stubs/networkx/networkx/algorithms/structuralholes.pyi +++ b/stubs/networkx/networkx/algorithms/structuralholes.pyi @@ -1,9 +1,5 @@ from _typeshed import Incomplete -def effective_size( - G, nodes: Incomplete | None = None, weight: Incomplete | None = None -): ... -def constraint( - G, nodes: Incomplete | None = None, weight: Incomplete | None = None -): ... +def effective_size(G, nodes: Incomplete | None = None, weight: Incomplete | None = None): ... +def constraint(G, nodes: Incomplete | None = None, weight: Incomplete | None = None): ... def local_constraint(G, u, v, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/swap.pyi b/stubs/networkx/networkx/algorithms/swap.pyi index 098234460e21..1c640e4067b0 100644 --- a/stubs/networkx/networkx/algorithms/swap.pyi +++ b/stubs/networkx/networkx/algorithms/swap.pyi @@ -1,11 +1,5 @@ from _typeshed import Incomplete -def directed_edge_swap( - G, *, nswap: int = 1, max_tries: int = 100, seed: Incomplete | None = None -): ... -def double_edge_swap( - G, nswap: int = 1, max_tries: int = 100, seed: Incomplete | None = None -): ... -def connected_double_edge_swap( - G, nswap: int = 1, _window_threshold: int = 3, seed: Incomplete | None = None -): ... +def directed_edge_swap(G, *, nswap: int = 1, max_tries: int = 100, seed: Incomplete | None = None): ... +def double_edge_swap(G, nswap: int = 1, max_tries: int = 100, seed: Incomplete | None = None): ... +def connected_double_edge_swap(G, nswap: int = 1, _window_threshold: int = 3, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi b/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi index 7c4a07b7255c..caad5b0b1b8a 100644 --- a/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi @@ -1,6 +1,4 @@ from _typeshed import Incomplete from collections.abc import Generator -def bfs_beam_edges( - G, source, value, width: Incomplete | None = None -) -> Generator[Incomplete, Incomplete, Incomplete]: ... +def bfs_beam_edges(G, source, value, width: Incomplete | None = None) -> Generator[Incomplete, Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi b/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi index b659f030723c..731b1b5c18ce 100644 --- a/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi @@ -2,30 +2,16 @@ from _typeshed import Incomplete from collections.abc import Generator def bfs_edges( - G, - source, - reverse: bool = False, - depth_limit: Incomplete | None = None, - sort_neighbors: Incomplete | None = None, + G, source, reverse: bool = False, depth_limit: Incomplete | None = None, sort_neighbors: Incomplete | None = None ) -> Generator[Incomplete, Incomplete, None]: ... def bfs_tree( - G, - source, - reverse: bool = False, - depth_limit: Incomplete | None = None, - sort_neighbors: Incomplete | None = None, + G, source, reverse: bool = False, depth_limit: Incomplete | None = None, sort_neighbors: Incomplete | None = None ): ... def bfs_predecessors( - G, - source, - depth_limit: Incomplete | None = None, - sort_neighbors: Incomplete | None = None, + G, source, depth_limit: Incomplete | None = None, sort_neighbors: Incomplete | None = None ) -> Generator[Incomplete, None, None]: ... def bfs_successors( - G, - source, - depth_limit: Incomplete | None = None, - sort_neighbors: Incomplete | None = None, + G, source, depth_limit: Incomplete | None = None, sort_neighbors: Incomplete | None = None ) -> Generator[Incomplete, None, None]: ... def bfs_layers(G, sources) -> Generator[Incomplete, None, None]: ... def descendants_at_distance(G, source, distance): ... diff --git a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi index 7427ca5e9131..9aff3e8030a9 100644 --- a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi @@ -1,29 +1,15 @@ +from _typeshed import Incomplete from collections.abc import Iterator from typing import TypeVar -from _typeshed import Incomplete from networkx.classes.graph import Graph _T = TypeVar("_T") -def dfs_edges( - G: Graph[_T], source: _T | None = ..., depth_limit: int | None = ... -) -> Iterator[tuple[_T, _T]]: ... -def dfs_tree( - G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ... -) -> Incomplete: ... -def dfs_predecessors( - G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ... -) -> Incomplete: ... -def dfs_successors( - G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ... -) -> Incomplete: ... -def dfs_postorder_nodes( - G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ... -) -> Incomplete: ... -def dfs_preorder_nodes( - G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ... -) -> Incomplete: ... -def dfs_labeled_edges( - G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ... -) -> None: ... +def dfs_edges(G: Graph[_T], source: _T | None = ..., depth_limit: int | None = ...) -> Iterator[tuple[_T, _T]]: ... +def dfs_tree(G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...) -> Incomplete: ... +def dfs_predecessors(G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...) -> Incomplete: ... +def dfs_successors(G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...) -> Incomplete: ... +def dfs_postorder_nodes(G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...) -> Incomplete: ... +def dfs_preorder_nodes(G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...) -> Incomplete: ... +def dfs_labeled_edges(G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi index b1e1d182260a..42b7d55690d8 100644 --- a/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -1,22 +1,14 @@ -from typing import Generic from _typeshed import Incomplete +from typing import Generic from networkx.classes.multidigraph import MultiDiGraph, _Node def branching_weight(G, attr: str = "weight", default: int = 1): ... -def greedy_branching( - G, - attr: str = "weight", - default: int = 1, - kind: str = "max", - seed: Incomplete | None = None, -): ... +def greedy_branching(G, attr: str = "weight", default: int = 1, kind: str = "max", seed: Incomplete | None = None): ... class MultiDiGraph_EdgeKey(MultiDiGraph[_Node], Generic[_Node]): edge_index: Incomplete - def __init__( - self, incoming_graph_data: Incomplete | None = None, **attr - ) -> None: ... + def __init__(self, incoming_graph_data: Incomplete | None = None, **attr) -> None: ... def remove_node(self, n) -> None: ... def remove_nodes_from(self, nbunch) -> None: ... def add_edge(self, u_for_edge, v_for_edge, key_for_edge, **attr) -> None: ... @@ -42,32 +34,16 @@ class Edmonds: ): ... def maximum_branching( - G, - attr: str = "weight", - default: int = 1, - preserve_attrs: bool = False, - partition: Incomplete | None = None, + G, attr: str = "weight", default: int = 1, preserve_attrs: bool = False, partition: Incomplete | None = None ): ... def minimum_branching( - G, - attr: str = "weight", - default: int = 1, - preserve_attrs: bool = False, - partition: Incomplete | None = None, + G, attr: str = "weight", default: int = 1, preserve_attrs: bool = False, partition: Incomplete | None = None ): ... def maximum_spanning_arborescence( - G, - attr: str = "weight", - default: int = 1, - preserve_attrs: bool = False, - partition: Incomplete | None = None, + G, attr: str = "weight", default: int = 1, preserve_attrs: bool = False, partition: Incomplete | None = None ): ... def minimum_spanning_arborescence( - G, - attr: str = "weight", - default: int = 1, - preserve_attrs: bool = False, - partition: Incomplete | None = None, + G, attr: str = "weight", default: int = 1, preserve_attrs: bool = False, partition: Incomplete | None = None ): ... class ArborescenceIterator: @@ -86,13 +62,7 @@ class ArborescenceIterator: method: Incomplete partition_key: str init_partition: Incomplete - def __init__( - self, - G, - weight: str = "weight", - minimum: bool = True, - init_partition: Incomplete | None = None, - ) -> None: ... + def __init__(self, G, weight: str = "weight", minimum: bool = True, init_partition: Incomplete | None = None) -> None: ... partition_queue: Incomplete def __iter__(self): ... def __next__(self): ... diff --git a/stubs/networkx/networkx/algorithms/tree/mst.pyi b/stubs/networkx/networkx/algorithms/tree/mst.pyi index 38256c06012f..17f1a09e08d8 100644 --- a/stubs/networkx/networkx/algorithms/tree/mst.pyi +++ b/stubs/networkx/networkx/algorithms/tree/mst.pyi @@ -7,41 +7,17 @@ class EdgePartition(Enum): EXCLUDED: int def minimum_spanning_edges( - G, - algorithm: str = "kruskal", - weight: str = "weight", - keys: bool = True, - data: bool = True, - ignore_nan: bool = False, + G, algorithm: str = "kruskal", weight: str = "weight", keys: bool = True, data: bool = True, ignore_nan: bool = False ): ... def maximum_spanning_edges( - G, - algorithm: str = "kruskal", - weight: str = "weight", - keys: bool = True, - data: bool = True, - ignore_nan: bool = False, -): ... -def minimum_spanning_tree( - G, weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False + G, algorithm: str = "kruskal", weight: str = "weight", keys: bool = True, data: bool = True, ignore_nan: bool = False ): ... +def minimum_spanning_tree(G, weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False): ... def partition_spanning_tree( - G, - minimum: bool = True, - weight: str = "weight", - partition: str = "partition", - ignore_nan: bool = False, -): ... -def maximum_spanning_tree( - G, weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False -): ... -def random_spanning_tree( - G, - weight: Incomplete | None = None, - *, - multiplicative: bool = True, - seed: Incomplete | None = None + G, minimum: bool = True, weight: str = "weight", partition: str = "partition", ignore_nan: bool = False ): ... +def maximum_spanning_tree(G, weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False): ... +def random_spanning_tree(G, weight: Incomplete | None = None, *, multiplicative: bool = True, seed: Incomplete | None = None): ... class SpanningTreeIterator: class Partition: @@ -58,9 +34,7 @@ class SpanningTreeIterator: minimum: Incomplete ignore_nan: Incomplete partition_key: str - def __init__( - self, G, weight: str = "weight", minimum: bool = True, ignore_nan: bool = False - ) -> None: ... + def __init__(self, G, weight: str = "weight", minimum: bool = True, ignore_nan: bool = False) -> None: ... partition_queue: Incomplete def __iter__(self): ... def __next__(self): ... diff --git a/stubs/networkx/networkx/algorithms/vitality.pyi b/stubs/networkx/networkx/algorithms/vitality.pyi index 001a49a491ba..348555a0ad48 100644 --- a/stubs/networkx/networkx/algorithms/vitality.pyi +++ b/stubs/networkx/networkx/algorithms/vitality.pyi @@ -1,8 +1,5 @@ from _typeshed import Incomplete def closeness_vitality( - G, - node: Incomplete | None = None, - weight: Incomplete | None = None, - wiener_index: Incomplete | None = None, + G, node: Incomplete | None = None, weight: Incomplete | None = None, wiener_index: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/classes/coreviews.pyi b/stubs/networkx/networkx/classes/coreviews.pyi index e5184561753f..581a615feb48 100644 --- a/stubs/networkx/networkx/classes/coreviews.pyi +++ b/stubs/networkx/networkx/classes/coreviews.pyi @@ -1,8 +1,7 @@ +from _typeshed import Incomplete, Self from collections.abc import Callable, Iterator, Mapping from typing import Generic, TypeVar -from _typeshed import Incomplete, Self - _T = TypeVar("_T") _U = TypeVar("_U") _V = TypeVar("_V") @@ -18,18 +17,14 @@ class AdjacencyView(AtlasView[_T, _U, _V], Generic[_T, _U, _V]): ... class MultiAdjacencyView(AdjacencyView[_T, _U, _V], Generic[_T, _U, _V]): ... class UnionAtlas(Mapping[_T, dict[_U, _V]], Generic[_T, _U, _V]): - def __init__( - self, succ: AtlasView[_T, _U, _V], pred: AtlasView[_T, _U, _V] - ) -> None: ... + def __init__(self, succ: AtlasView[_T, _U, _V], pred: AtlasView[_T, _U, _V]) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_T]: ... def __getitem__(self, key: _T) -> dict[_U, _V]: ... def copy(self: Self) -> Self: ... class UnionAdjacency(Mapping[_T, dict[_U, _V]], Generic[_T, _U, _V]): - def __init__( - self, succ: AdjacencyView[_T, _U, _V], pred: AdjacencyView[_T, _U, _V] - ) -> None: ... + def __init__(self, succ: AdjacencyView[_T, _U, _V], pred: AdjacencyView[_T, _U, _V]) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_T]: ... def __getitem__(self, key: _T) -> dict[_U, _V]: ... @@ -50,10 +45,7 @@ class FilterAdjacency(Mapping[_T, Mapping[_U, _V]], Generic[_T, _U, _V]): NODE_OK: Callable[[_T], bool] EDGE_OK: Callable[[_T, _T], bool] def __init__( - self, - d: Mapping[_T, Mapping[_U, _V]], - NODE_OK: Callable[[_T], bool], - EDGE_OK: Callable[[_T, _T], bool], + self, d: Mapping[_T, Mapping[_U, _V]], NODE_OK: Callable[[_T], bool], EDGE_OK: Callable[[_T, _T], bool] ) -> None: ... def __len__(self) -> Incomplete: ... def __iter__(self) -> Incomplete: ... diff --git a/stubs/networkx/networkx/classes/digraph.pyi b/stubs/networkx/networkx/classes/digraph.pyi index abae4f946bc0..fbd2374047a1 100644 --- a/stubs/networkx/networkx/classes/digraph.pyi +++ b/stubs/networkx/networkx/classes/digraph.pyi @@ -1,6 +1,6 @@ +from _typeshed import Incomplete from collections.abc import Iterator from typing import Generic -from _typeshed import Incomplete from networkx.classes.coreviews import AdjacencyView from networkx.classes.graph import Graph, _Node @@ -21,12 +21,8 @@ class DiGraph(Graph[_Node], Generic[_Node]): def successors(self, n: _Node) -> Iterator[_Node]: ... def predecessors(self, n: _Node) -> Iterator[_Node]: ... in_edges: InEdgeView[_Node] - in_degree: InDegreeView[_Node] | InMultiDegreeView[ - _Node - ] # ugly hack to make MultiDiGraph work + in_degree: InDegreeView[_Node] | InMultiDegreeView[_Node] # ugly hack to make MultiDiGraph work out_edges: OutEdgeView[_Node] - out_degree: OutDegreeView[_Node] | OutMultiDegreeView[ - _Node - ] # ugly hack to make MultiDiGraph work + out_degree: OutDegreeView[_Node] | OutMultiDegreeView[_Node] # ugly hack to make MultiDiGraph work def reverse(self, copy: bool = ...) -> DiGraph[_Node]: ... def copy(self, as_view: bool = ...) -> DiGraph[_Node]: ... diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index 3c99e00aa420..2b71bbcf19d2 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -1,18 +1,16 @@ +from _typeshed import Incomplete from collections.abc import Iterable from typing import Any, TypeVar, overload +from typing_extensions import Literal -from _typeshed import Incomplete from networkx.classes.graph import Graph -from typing_extensions import Literal _T = TypeVar("_T") _U = TypeVar("_U") def nodes(G: Incomplete) -> Incomplete: ... def edges(G: Incomplete, nbunch: Incomplete | None = ...) -> Incomplete: ... -def degree( - G: Incomplete, nbunch: Incomplete | None = ..., weight: Incomplete | None = ... -) -> Incomplete: ... +def degree(G: Incomplete, nbunch: Incomplete | None = ..., weight: Incomplete | None = ...) -> Incomplete: ... def neighbors(G: Incomplete, n: Incomplete) -> Incomplete: ... def number_of_nodes(G: Incomplete) -> Incomplete: ... def number_of_edges(G: Incomplete) -> Incomplete: ... @@ -21,73 +19,47 @@ def degree_histogram(G: Incomplete) -> Incomplete: ... def is_directed(G: Incomplete) -> Incomplete: ... def freeze(G: Incomplete) -> Incomplete: ... def is_frozen(G: Incomplete) -> Incomplete: ... -def add_star( - G_to_add_to: Incomplete, nodes_for_star: Incomplete, **attr: Incomplete -) -> None: ... -def add_path( - G_to_add_to: Incomplete, nodes_for_path: Incomplete, **attr: Incomplete -) -> None: ... -def add_cycle( - G_to_add_to: Incomplete, nodes_for_cycle: Incomplete, **attr: Incomplete -) -> None: ... +def add_star(G_to_add_to: Incomplete, nodes_for_star: Incomplete, **attr: Incomplete) -> None: ... +def add_path(G_to_add_to: Incomplete, nodes_for_path: Incomplete, **attr: Incomplete) -> None: ... +def add_cycle(G_to_add_to: Incomplete, nodes_for_cycle: Incomplete, **attr: Incomplete) -> None: ... def subgraph(G: Incomplete, nbunch: Incomplete) -> Incomplete: ... def induced_subgraph(G: Graph[_T], nbunch: _T | Iterable[_T] | None) -> Graph[_T]: ... def edge_subgraph(G: Incomplete, edges: Incomplete) -> Incomplete: ... -def restricted_view( - G: Incomplete, nodes: Incomplete, edges: Incomplete -) -> Incomplete: ... +def restricted_view(G: Incomplete, nodes: Incomplete, edges: Incomplete) -> Incomplete: ... def reverse_view(digraph: Incomplete) -> Incomplete: ... def to_directed(graph: Incomplete) -> Incomplete: ... def to_undirected(graph: Incomplete) -> Incomplete: ... def create_empty_copy(G: Incomplete, with_data: bool = ...) -> Incomplete: ... def info(G: Incomplete, n: Incomplete | None = ...) -> Incomplete: ... @overload -def set_node_attributes( - G: Graph[_T], values: dict[_T, Incomplete], name: str = ... -) -> None: ... +def set_node_attributes(G: Graph[_T], values: dict[_T, Incomplete], name: str = ...) -> None: ... # Can "Any scalar value" be enforced? @overload def set_node_attributes(G: Graph[Any], values: Incomplete, name: str = ...) -> None: ... @overload -def set_node_attributes( - G: Graph[_T], values: dict[_T, dict[Incomplete, Incomplete]], name: None = ... -) -> None: ... +def set_node_attributes(G: Graph[_T], values: dict[_T, dict[Incomplete, Incomplete]], name: None = ...) -> None: ... def get_node_attributes(G: Graph[_T], name: str) -> dict[_T, Incomplete]: ... @overload -def set_edge_attributes( - G: Graph[_T], values: dict[tuple[_T, _T], Incomplete], name: str = ... -) -> None: ... +def set_edge_attributes(G: Graph[_T], values: dict[tuple[_T, _T], Incomplete], name: str = ...) -> None: ... @overload -def set_edge_attributes( - G: Graph[Any], values: Incomplete, name: None = ... -) -> None: ... +def set_edge_attributes(G: Graph[Any], values: Incomplete, name: None = ...) -> None: ... def get_edge_attributes(G: Graph[_T], name: str) -> dict[tuple[_T, _T], Incomplete]: ... def all_neighbors(graph: Graph[_T], node: _T) -> Iterable[_T]: ... def non_neighbors(graph: Graph[_T], node: _T) -> Iterable[_T]: ... def non_edges(graph: Graph[_T]) -> Iterable[tuple[_T, _T]]: ... def common_neighbors(G: Graph[_T], u: _T, v: _T) -> Iterable[_T]: ... -def is_weighted( - G: Graph[_T], edge: tuple[_T, _T] | None = ..., weight: str | None = ... -) -> bool: ... -def is_negatively_weighted( - G: Graph[_T], edge: tuple[_T, _T] | None = ..., weight: str | None = ... -) -> Incomplete: ... +def is_weighted(G: Graph[_T], edge: tuple[_T, _T] | None = ..., weight: str | None = ...) -> bool: ... +def is_negatively_weighted(G: Graph[_T], edge: tuple[_T, _T] | None = ..., weight: str | None = ...) -> Incomplete: ... def is_empty(G: Graph[Any]) -> bool: ... def nodes_with_selfloops(G: Graph[_T]) -> Iterable[_T]: ... @overload def selfloop_edges( - G: Graph[_T], - data: Literal[False] = ..., - keys: Literal[False] = ..., - default: Incomplete = ..., + G: Graph[_T], data: Literal[False] = ..., keys: Literal[False] = ..., default: Incomplete = ... ) -> Iterable[tuple[_T, _T]]: ... @overload def selfloop_edges( - G: Graph[_T], - data: Literal[True] = ..., - keys: Literal[False] = ..., - default: Incomplete = ..., + G: Graph[_T], data: Literal[True] = ..., keys: Literal[False] = ..., default: Incomplete = ... ) -> Iterable[tuple[_T, _T, dict[str, Incomplete]]]: ... @overload def selfloop_edges( @@ -95,17 +67,11 @@ def selfloop_edges( ) -> Iterable[tuple[_T, _T, _U]]: ... @overload def selfloop_edges( - G: Graph[_T], - data: Literal[False] = ..., - keys: Literal[True] = ..., - default: Incomplete = ..., + G: Graph[_T], data: Literal[False] = ..., keys: Literal[True] = ..., default: Incomplete = ... ) -> Iterable[tuple[_T, _T, int]]: ... @overload def selfloop_edges( - G: Graph[_T], - data: Literal[True] = ..., - keys: Literal[True] = ..., - default: Incomplete = ..., + G: Graph[_T], data: Literal[True] = ..., keys: Literal[True] = ..., default: Incomplete = ... ) -> Iterable[tuple[_T, _T, int, dict[str, Incomplete]]]: ... @overload def selfloop_edges( diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi index e09ead48a71a..63dee6b6c7fa 100644 --- a/stubs/networkx/networkx/classes/graph.pyi +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -1,20 +1,12 @@ -from collections.abc import ( - Callable, - Collection, - Hashable, - Iterable, - Iterator, - Mapping, - MutableMapping, -) +from _typeshed import Incomplete, Self +from collections.abc import Callable, Collection, Hashable, Iterable, Iterator, Mapping, MutableMapping from typing import ClassVar, Generic, TypeVar, overload +from typing_extensions import TypeAlias -from _typeshed import Self, Incomplete from networkx.classes.coreviews import AdjacencyView from networkx.classes.digraph import DiGraph from networkx.classes.reportviews import DiDegreeView, NodeView, OutEdgeView from networkx.convert import _Data -from typing_extensions import TypeAlias _Node = TypeVar("_Node", bound=Hashable) Edge: TypeAlias = tuple[_Node, _Node] @@ -32,9 +24,7 @@ class Graph(Collection[_Node], Generic[_Node]): def to_directed_class(self) -> type[DiGraph[_Node]]: ... def to_undirected_class(self) -> type[Graph[_Node]]: ... - def __init__( - self, incoming_graph_data: _Data[_Node] | None = None, **attr: Incomplete - ) -> None: ... + def __init__(self, incoming_graph_data: _Data[_Node] | None = None, **attr: Incomplete) -> None: ... adj: AdjacencyView[_Node, _Node, dict[str, Incomplete]] name: str @@ -45,9 +35,7 @@ class Graph(Collection[_Node], Generic[_Node]): def __len__(self) -> int: ... def add_node(self, node_for_adding: _Node, **attr: Incomplete) -> None: ... def add_nodes_from( - self, - nodes_for_adding: Iterable[_Node | tuple[_Node, dict[str, Incomplete]]], - **attr: Incomplete + self, nodes_for_adding: Iterable[_Node | tuple[_Node, dict[str, Incomplete]]], **attr: Incomplete ) -> None: ... def remove_node(self, n: _Node) -> None: ... def remove_nodes_from(self, nodes: Iterable[_Node]) -> None: ... @@ -55,17 +43,10 @@ class Graph(Collection[_Node], Generic[_Node]): def number_of_nodes(self) -> int: ... def order(self) -> int: ... def has_node(self, n: _Node) -> bool: ... - def add_edge( - self, u_of_edge: _Node, v_of_edge: _Node, **attr: Incomplete - ) -> None: ... - def add_edges_from( - self, ebunch_to_add: Iterable[EdgePlus[_Node]], **attr: Incomplete - ) -> None: ... + def add_edge(self, u_of_edge: _Node, v_of_edge: _Node, **attr: Incomplete) -> None: ... + def add_edges_from(self, ebunch_to_add: Iterable[EdgePlus[_Node]], **attr: Incomplete) -> None: ... def add_weighted_edges_from( - self, - ebunch_to_add: Iterable[tuple[_Node, _Node, Incomplete]], - weight: str = ..., - **attr: Incomplete + self, ebunch_to_add: Iterable[tuple[_Node, _Node, Incomplete]], weight: str = ..., **attr: Incomplete ) -> None: ... def remove_edge(self, u: _Node, v: _Node) -> None: ... def remove_edges_from(self, ebunch: Iterable[EdgePlus[_Node]]) -> None: ... @@ -73,19 +54,13 @@ class Graph(Collection[_Node], Generic[_Node]): def update(self, edges: Graph[_Node], nodes: None = None) -> None: ... @overload def update( - self, - edges: Graph[_Node] | Iterable[EdgePlus[_Node]] | None = ..., - nodes: Iterable[_Node] | None = ..., + self, edges: Graph[_Node] | Iterable[EdgePlus[_Node]] | None = ..., nodes: Iterable[_Node] | None = ... ) -> None: ... def has_edge(self, u: _Node, v: _Node) -> bool: ... def neighbors(self, n: _Node) -> Iterable[_Node]: ... edges: OutEdgeView[_Node] - def get_edge_data( - self, u: _Node, v: _Node, default: Incomplete = ... - ) -> Mapping[str, Incomplete]: ... - def adjacency( - self, - ) -> Iterable[tuple[_Node, Mapping[_Node, Mapping[str, Incomplete]]]]: ... + def get_edge_data(self, u: _Node, v: _Node, default: Incomplete = ...) -> Mapping[str, Incomplete]: ... + def adjacency(self) -> Iterable[tuple[_Node, Mapping[_Node, Mapping[str, Incomplete]]]]: ... degree: DiDegreeView[_Node] diff --git a/stubs/networkx/networkx/classes/multidigraph.pyi b/stubs/networkx/networkx/classes/multidigraph.pyi index 1b15ec408150..d20eb4732ce7 100644 --- a/stubs/networkx/networkx/classes/multidigraph.pyi +++ b/stubs/networkx/networkx/classes/multidigraph.pyi @@ -1,11 +1,7 @@ from networkx.classes.digraph import DiGraph from networkx.classes.graph import _Node from networkx.classes.multigraph import MultiGraph -from networkx.classes.reportviews import ( - InMultiDegreeView, - MultiDegreeView, - OutMultiDegreeView, -) +from networkx.classes.reportviews import InMultiDegreeView, MultiDegreeView, OutMultiDegreeView class MultiDiGraph(MultiGraph[_Node], DiGraph[_Node]): degree: MultiDegreeView[_Node] diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index 44548196b080..b5c71c0f498e 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -1,9 +1,9 @@ +from _typeshed import Incomplete from collections.abc import Iterator from typing import Generic, TypeVar, overload +from typing_extensions import Literal -from _typeshed import Incomplete from networkx.classes.graph import Edge, Graph, NBunch, _Node -from typing_extensions import Literal _D = TypeVar("_D") _U = TypeVar("_U") @@ -15,39 +15,21 @@ class NodeView(Generic[_Node]): def __getitem__(self, n: _Node) -> _Node: ... def __contains__(self, n: object) -> bool: ... @overload - def __call__( - self, data: Literal[False] = ..., default: Incomplete = ... - ) -> NodeView[_Node]: ... + def __call__(self, data: Literal[False] = ..., default: Incomplete = ...) -> NodeView[_Node]: ... @overload - def __call__( - self, data: Literal[True] | str, default: Incomplete = ... - ) -> NodeDataView[_Node]: ... - def data( - self, data: bool | str = ..., default: Incomplete = ... - ) -> NodeDataView[_Node]: ... + def __call__(self, data: Literal[True] | str, default: Incomplete = ...) -> NodeDataView[_Node]: ... + def data(self, data: bool | str = ..., default: Incomplete = ...) -> NodeDataView[_Node]: ... class NodeDataView(Generic[_Node]): - def __init__( - self, - nodedict: dict[str, Incomplete], - data: bool | str = ..., - default: Incomplete = ..., - ) -> None: ... + def __init__(self, nodedict: dict[str, Incomplete], data: bool | str = ..., default: Incomplete = ...) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[tuple[_Node, Incomplete]]: ... def __contains__(self, n: _Node) -> bool: ... def __getitem__(self, n: _Node) -> Incomplete: ... class DiDegreeView(Generic[_Node]): - def __init__( - self, - G: Graph[_Node], - nbunch: NBunch[_Node] = ..., - weight: None | bool | str = ..., - ) -> None: ... - def __call__( - self, nbunch: NBunch[_Node] = ..., weight: None | bool | str = ... - ) -> DiDegreeView[_Node]: ... + def __init__(self, G: Graph[_Node], nbunch: NBunch[_Node] = ..., weight: None | bool | str = ...) -> None: ... + def __call__(self, nbunch: NBunch[_Node] = ..., weight: None | bool | str = ...) -> DiDegreeView[_Node]: ... def __getitem__(self, n: _Node) -> float: ... def __iter__(self) -> Iterator[tuple[_Node, float]]: ... def __len__(self) -> int: ... @@ -79,35 +61,21 @@ class OutEdgeView(Generic[_Node]): def __getitem__(self, e: Edge[_Node]) -> dict[str, Incomplete]: ... @overload def __call__( - self, - nbunch: NBunch[_Node] = ..., - data: Literal[False] = ..., - default: Incomplete = ..., + self, nbunch: NBunch[_Node] = ..., data: Literal[False] = ..., default: Incomplete = ... ) -> OutEdgeView[_Node]: ... @overload def __call__( - self, - nbunch: NBunch[_Node] = ..., - data: Literal[True] = ..., - default: Incomplete = ..., + self, nbunch: NBunch[_Node] = ..., data: Literal[True] = ..., default: Incomplete = ... ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... @overload def __call__( self, nbunch: NBunch[_Node] = ..., data: str = ..., default: _U | None = None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... @overload - def data( - self, - data: Literal[False] = ..., - default: Incomplete = ..., - nbunch: NBunch[_Node] = ..., - ) -> OutEdgeView[_Node]: ... + def data(self, data: Literal[False] = ..., default: Incomplete = ..., nbunch: NBunch[_Node] = ...) -> OutEdgeView[_Node]: ... @overload def data( - self, - data: Literal[True] = ..., - default: Incomplete = ..., - nbunch: NBunch[_Node] = ..., + self, data: Literal[True] = ..., default: Incomplete = ..., nbunch: NBunch[_Node] = ... ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... @overload def data( diff --git a/stubs/networkx/networkx/convert.pyi b/stubs/networkx/networkx/convert.pyi index 7acd905eaee7..6d9191096b31 100644 --- a/stubs/networkx/networkx/convert.pyi +++ b/stubs/networkx/networkx/convert.pyi @@ -1,11 +1,11 @@ +from _typeshed import Incomplete from collections.abc import Iterable +from typing_extensions import TypeAlias import numpy -from _typeshed import Incomplete # import scipy from networkx.classes.graph import EdgePlus, Graph, _Node -from typing_extensions import TypeAlias # this is imported from other stub files _Data: TypeAlias = ( # noqa: Y047 diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index 773a726efaff..e6225ff3bfff 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -1,11 +1,11 @@ -from collections.abc import Callable, Iterable from _typeshed import Incomplete +from collections.abc import Callable, Iterable +from typing_extensions import Literal import numpy from networkx.classes.graph import Graph, _Node from pandas import DataFrame from pandas.core.dtypes.base import ExtensionDtype -from typing_extensions import Literal def to_pandas_adjacency( G: Graph[_Node], @@ -16,9 +16,7 @@ def to_pandas_adjacency( weight: str = ..., nonedge: float = ..., ) -> DataFrame: ... -def from_pandas_adjacency( - df: DataFrame, create_using: type[Graph[Incomplete]] = ... -) -> Graph[Incomplete]: ... +def from_pandas_adjacency(df: DataFrame, create_using: type[Graph[Incomplete]] = ...) -> Graph[Incomplete]: ... def to_pandas_edgelist( G: Graph[_Node], source: str | int = ..., @@ -44,7 +42,5 @@ def to_numpy_array( nonedge: float = ..., ) -> numpy.ndarray[Incomplete, numpy.dtype[Incomplete]]: ... def from_numpy_array( - A: numpy.ndarray[Incomplete, Incomplete], - parallel_edges: bool = ..., - create_using: type[Graph[Incomplete]] = ..., + A: numpy.ndarray[Incomplete, Incomplete], parallel_edges: bool = ..., create_using: type[Graph[Incomplete]] = ... ) -> Graph[Incomplete]: ... diff --git a/stubs/networkx/networkx/drawing/layout.pyi b/stubs/networkx/networkx/drawing/layout.pyi index 3786ad937ad6..41a69a12f607 100644 --- a/stubs/networkx/networkx/drawing/layout.pyi +++ b/stubs/networkx/networkx/drawing/layout.pyi @@ -1,11 +1,7 @@ from _typeshed import Incomplete -def random_layout( - G, center: Incomplete | None = None, dim: int = 2, seed: Incomplete | None = None -): ... -def circular_layout( - G, scale: int = 1, center: Incomplete | None = None, dim: int = 2 -): ... +def random_layout(G, center: Incomplete | None = None, dim: int = 2, seed: Incomplete | None = None): ... +def circular_layout(G, scale: int = 1, center: Incomplete | None = None, dim: int = 2): ... def shell_layout( G, nlist: Incomplete | None = None, @@ -15,12 +11,7 @@ def shell_layout( dim: int = 2, ): ... def bipartite_layout( - G, - nodes, - align: str = "vertical", - scale: int = 1, - center: Incomplete | None = None, - aspect_ratio: float = ..., + G, nodes, align: str = "vertical", scale: int = 1, center: Incomplete | None = None, aspect_ratio: float = ... ): ... def spring_layout( G, @@ -47,30 +38,13 @@ def kamada_kawai_layout( center: Incomplete | None = None, dim: int = 2, ): ... -def spectral_layout( - G, - weight: str = "weight", - scale: int = 1, - center: Incomplete | None = None, - dim: int = 2, -): ... -def planar_layout( - G, scale: int = 1, center: Incomplete | None = None, dim: int = 2 -): ... +def spectral_layout(G, weight: str = "weight", scale: int = 1, center: Incomplete | None = None, dim: int = 2): ... +def planar_layout(G, scale: int = 1, center: Incomplete | None = None, dim: int = 2): ... def spiral_layout( - G, - scale: int = 1, - center: Incomplete | None = None, - dim: int = 2, - resolution: float = 0.35, - equidistant: bool = False, + G, scale: int = 1, center: Incomplete | None = None, dim: int = 2, resolution: float = 0.35, equidistant: bool = False ): ... def multipartite_layout( - G, - subset_key: str = "subset", - align: str = "vertical", - scale: int = 1, - center: Incomplete | None = None, + G, subset_key: str = "subset", align: str = "vertical", scale: int = 1, center: Incomplete | None = None ): ... def arf_layout( G, diff --git a/stubs/networkx/networkx/drawing/nx_agraph.pyi b/stubs/networkx/networkx/drawing/nx_agraph.pyi index 7738d069a41e..a173f9814b0c 100644 --- a/stubs/networkx/networkx/drawing/nx_agraph.pyi +++ b/stubs/networkx/networkx/drawing/nx_agraph.pyi @@ -1,8 +1,7 @@ +from _typeshed import Incomplete from collections.abc import Callable from io import TextIOBase from typing import Any, TypeVar - -from _typeshed import Incomplete from typing_extensions import TypeAlias from networkx.classes.graph import Graph @@ -12,15 +11,11 @@ from networkx.classes.graph import Graph _AGraph: TypeAlias = Incomplete _T = TypeVar("_T") -def from_agraph( - A: Incomplete, create_using: Incomplete | None = ... -) -> Graph[Incomplete]: ... +def from_agraph(A: Incomplete, create_using: Incomplete | None = ...) -> Graph[Incomplete]: ... def to_agraph(N: Graph[Any]) -> _AGraph: ... def write_dot(G: Graph[Any], path: str | TextIOBase) -> None: ... def read_dot(path: str | TextIOBase) -> Graph[Incomplete]: ... -def graphviz_layout( - G: Graph[_T], prog: str = ..., root: str | None = ..., args: str = ... -) -> dict[_T, tuple[float, float]]: ... +def graphviz_layout(G: Graph[_T], prog: str = ..., root: str | None = ..., args: str = ...) -> dict[_T, tuple[float, float]]: ... pygraphviz_layout = graphviz_layout diff --git a/stubs/networkx/networkx/drawing/nx_pylab.pyi b/stubs/networkx/networkx/drawing/nx_pylab.pyi index 3c7e74b2c74f..d01a088a71fb 100644 --- a/stubs/networkx/networkx/drawing/nx_pylab.pyi +++ b/stubs/networkx/networkx/drawing/nx_pylab.pyi @@ -1,14 +1,8 @@ from _typeshed import Incomplete -def draw( - G, pos: Incomplete | None = None, ax: Incomplete | None = None, **kwds -) -> None: ... +def draw(G, 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, pos: Incomplete | None = None, arrows: Incomplete | None = None, with_labels: bool = True, **kwds ) -> None: ... def draw_networkx_nodes( G, diff --git a/stubs/networkx/networkx/generators/community.pyi b/stubs/networkx/networkx/generators/community.pyi index 76fa14c13561..870f9627c372 100644 --- a/stubs/networkx/networkx/generators/community.pyi +++ b/stubs/networkx/networkx/generators/community.pyi @@ -3,15 +3,9 @@ from _typeshed import Incomplete def caveman_graph(l, k): ... def connected_caveman_graph(l, k): ... def relaxed_caveman_graph(l, k, p, seed: Incomplete | None = None): ... -def random_partition_graph( - sizes, p_in, p_out, seed: Incomplete | None = None, directed: bool = False -): ... -def planted_partition_graph( - l, k, p_in, p_out, seed: Incomplete | None = None, directed: bool = False -): ... -def gaussian_random_partition_graph( - n, s, v, p_in, p_out, directed: bool = False, seed: Incomplete | None = None -): ... +def random_partition_graph(sizes, p_in, p_out, seed: Incomplete | None = None, directed: bool = False): ... +def planted_partition_graph(l, k, p_in, p_out, seed: Incomplete | None = None, directed: bool = False): ... +def gaussian_random_partition_graph(n, s, v, p_in, p_out, directed: bool = False, seed: Incomplete | None = None): ... def ring_of_cliques(num_cliques, clique_size): ... def windmill_graph(n, k): ... def stochastic_block_model( diff --git a/stubs/networkx/networkx/generators/degree_seq.pyi b/stubs/networkx/networkx/generators/degree_seq.pyi index a5e6e73f71a3..639b1b837537 100644 --- a/stubs/networkx/networkx/generators/degree_seq.pyi +++ b/stubs/networkx/networkx/generators/degree_seq.pyi @@ -1,25 +1,14 @@ from _typeshed import Incomplete -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): ... def directed_configuration_model( - in_degree_sequence, - out_degree_sequence, - create_using: Incomplete | None = None, - seed: Incomplete | None = None, -): ... -def expected_degree_graph( - w, seed: Incomplete | None = None, selfloops: bool = True + in_degree_sequence, out_degree_sequence, create_using: Incomplete | None = None, seed: Incomplete | None = None ): ... +def expected_degree_graph(w, seed: Incomplete | None = None, selfloops: bool = True): ... def havel_hakimi_graph(deg_sequence, create_using: Incomplete | None = None): ... -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): ... def degree_sequence_tree(deg_sequence, create_using: Incomplete | None = None): ... -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): ... class DegreeSequenceRandomGraph: rng: Incomplete diff --git a/stubs/networkx/networkx/generators/directed.pyi b/stubs/networkx/networkx/generators/directed.pyi index a8413aedf934..bed206dbbad2 100644 --- a/stubs/networkx/networkx/generators/directed.pyi +++ b/stubs/networkx/networkx/generators/directed.pyi @@ -1,17 +1,8 @@ from _typeshed import Incomplete -def gn_graph( - n, - kernel: Incomplete | None = None, - create_using: Incomplete | None = None, - seed: Incomplete | None = None, -): ... -def gnr_graph( - n, p, create_using: Incomplete | None = None, seed: Incomplete | None = None -): ... -def gnc_graph( - n, create_using: Incomplete | None = None, seed: Incomplete | None = None -): ... +def gn_graph(n, kernel: Incomplete | None = None, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... +def gnr_graph(n, p, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... +def gnc_graph(n, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... def scale_free_graph( n, alpha: float = 0.41, @@ -23,6 +14,4 @@ def scale_free_graph( seed: Incomplete | None = None, initial_graph: Incomplete | None = None, ): ... -def random_k_out_graph( - n, k, alpha, self_loops: bool = True, seed: Incomplete | None = None -): ... +def random_k_out_graph(n, k, alpha, self_loops: bool = True, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/ego.pyi b/stubs/networkx/networkx/generators/ego.pyi index cd26c4ca9ff3..1ce413e52d5c 100644 --- a/stubs/networkx/networkx/generators/ego.pyi +++ b/stubs/networkx/networkx/generators/ego.pyi @@ -1,10 +1,3 @@ from _typeshed import Incomplete -def ego_graph( - G, - n, - radius: int = 1, - center: bool = True, - undirected: bool = False, - distance: Incomplete | None = None, -): ... +def ego_graph(G, n, radius: int = 1, center: bool = True, undirected: bool = False, distance: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/geometric.pyi b/stubs/networkx/networkx/generators/geometric.pyi index 601bfe8ccafe..a9270d2fec64 100644 --- a/stubs/networkx/networkx/generators/geometric.pyi +++ b/stubs/networkx/networkx/generators/geometric.pyi @@ -2,12 +2,7 @@ from _typeshed import Incomplete def geometric_edges(G, radius, p: int = 2): ... def random_geometric_graph( - n, - radius, - dim: int = 2, - pos: Incomplete | None = None, - p: int = 2, - seed: Incomplete | None = None, + n, radius, dim: int = 2, pos: Incomplete | None = None, p: int = 2, seed: Incomplete | None = None ): ... def soft_random_geometric_graph( n, @@ -37,9 +32,7 @@ def waxman_graph( metric: Incomplete | None = None, seed: Incomplete | None = None, ): ... -def navigable_small_world_graph( - n, p: int = 1, q: int = 1, r: int = 2, dim: int = 2, seed: Incomplete | None = None -): ... +def navigable_small_world_graph(n, p: int = 1, q: int = 1, r: int = 2, dim: int = 2, seed: Incomplete | None = None): ... def thresholded_random_geometric_graph( n, radius, diff --git a/stubs/networkx/networkx/generators/joint_degree_seq.pyi b/stubs/networkx/networkx/generators/joint_degree_seq.pyi index 226d2c2e0e5e..38ee477ceb6a 100644 --- a/stubs/networkx/networkx/generators/joint_degree_seq.pyi +++ b/stubs/networkx/networkx/generators/joint_degree_seq.pyi @@ -3,6 +3,4 @@ from _typeshed import Incomplete def is_valid_joint_degree(joint_degrees): ... def joint_degree_graph(joint_degrees, seed: Incomplete | None = None): ... def is_valid_directed_joint_degree(in_degrees, out_degrees, nkk): ... -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): ... diff --git a/stubs/networkx/networkx/generators/lattice.pyi b/stubs/networkx/networkx/generators/lattice.pyi index 0e7190616714..98fa1110c65d 100644 --- a/stubs/networkx/networkx/generators/lattice.pyi +++ b/stubs/networkx/networkx/generators/lattice.pyi @@ -1,21 +1,11 @@ from _typeshed import Incomplete -def grid_2d_graph( - m, n, periodic: bool = False, create_using: Incomplete | None = None -): ... +def grid_2d_graph(m, n, periodic: bool = False, create_using: Incomplete | None = None): ... def grid_graph(dim, periodic: bool = False): ... def hypercube_graph(n): ... def triangular_lattice_graph( - m, - n, - periodic: bool = False, - with_positions: bool = True, - create_using: Incomplete | None = None, + m, n, periodic: bool = False, with_positions: bool = True, create_using: Incomplete | None = None ): ... def hexagonal_lattice_graph( - m, - n, - periodic: bool = False, - with_positions: bool = True, - create_using: Incomplete | None = None, + m, n, periodic: bool = False, with_positions: bool = True, create_using: Incomplete | None = None ): ... diff --git a/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi b/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi index 6c4ed0391b2c..4ef477bbc991 100644 --- a/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi +++ b/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi @@ -1,7 +1,5 @@ from _typeshed import Incomplete from collections.abc import Generator -def nonisomorphic_trees( - order, create: str = "graph" -) -> Generator[Incomplete, None, None]: ... +def nonisomorphic_trees(order, create: str = "graph") -> Generator[Incomplete, None, None]: ... def number_of_nonisomorphic_trees(order): ... diff --git a/stubs/networkx/networkx/generators/random_clustered.pyi b/stubs/networkx/networkx/generators/random_clustered.pyi index 002067467452..3aaaa7445e16 100644 --- a/stubs/networkx/networkx/generators/random_clustered.pyi +++ b/stubs/networkx/networkx/generators/random_clustered.pyi @@ -1,7 +1,3 @@ from _typeshed import Incomplete -def random_clustered_graph( - joint_degree_sequence, - create_using: Incomplete | None = None, - seed: Incomplete | None = None, -): ... +def random_clustered_graph(joint_degree_sequence, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/random_graphs.pyi b/stubs/networkx/networkx/generators/random_graphs.pyi index bfc26206914b..036b1f9a50b5 100644 --- a/stubs/networkx/networkx/generators/random_graphs.pyi +++ b/stubs/networkx/networkx/generators/random_graphs.pyi @@ -1,8 +1,6 @@ from _typeshed import Incomplete -def fast_gnp_random_graph( - n, p, seed: Incomplete | None = None, directed: bool = False -): ... +def fast_gnp_random_graph(n, p, seed: Incomplete | None = None, directed: bool = False): ... def gnp_random_graph(n, p, seed: Incomplete | None = None, directed: bool = False): ... binomial_graph = gnp_random_graph @@ -12,34 +10,14 @@ def dense_gnm_random_graph(n, m, seed: Incomplete | None = None): ... def gnm_random_graph(n, m, seed: Incomplete | None = None, directed: bool = False): ... def newman_watts_strogatz_graph(n, k, p, seed: Incomplete | None = None): ... def watts_strogatz_graph(n, k, p, seed: Incomplete | None = None): ... -def connected_watts_strogatz_graph( - n, k, p, tries: int = 100, seed: Incomplete | None = None -): ... +def connected_watts_strogatz_graph(n, k, p, tries: int = 100, seed: Incomplete | None = None): ... def random_regular_graph(d, n, seed: Incomplete | None = None): ... -def barabasi_albert_graph( - n, m, seed: Incomplete | None = None, initial_graph: Incomplete | None = None -): ... -def dual_barabasi_albert_graph( - n, - m1, - m2, - p, - seed: Incomplete | None = None, - initial_graph: Incomplete | None = None, -): ... +def barabasi_albert_graph(n, m, seed: Incomplete | None = None, initial_graph: Incomplete | None = None): ... +def dual_barabasi_albert_graph(n, m1, m2, p, seed: Incomplete | None = None, initial_graph: Incomplete | None = None): ... def extended_barabasi_albert_graph(n, m, p, q, seed: Incomplete | None = None): ... def powerlaw_cluster_graph(n, m, p, seed: Incomplete | None = None): ... def random_lobster(n, p1, p2, seed: Incomplete | None = None): ... def random_shell_graph(constructor, seed: Incomplete | None = None): ... -def random_powerlaw_tree( - n, gamma: int = 3, seed: Incomplete | None = None, tries: int = 100 -): ... -def random_powerlaw_tree_sequence( - n, gamma: int = 3, seed: Incomplete | None = None, tries: int = 100 -): ... -def random_kernel_graph( - n, - kernel_integral, - kernel_root: Incomplete | None = None, - seed: Incomplete | None = None, -): ... +def random_powerlaw_tree(n, gamma: int = 3, seed: Incomplete | None = None, tries: int = 100): ... +def random_powerlaw_tree_sequence(n, gamma: int = 3, seed: Incomplete | None = None, tries: int = 100): ... +def random_kernel_graph(n, 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 9c9bbd16eaf7..e9e6c5618191 100644 --- a/stubs/networkx/networkx/generators/spectral_graph_forge.pyi +++ b/stubs/networkx/networkx/generators/spectral_graph_forge.pyi @@ -1,5 +1,3 @@ from _typeshed import Incomplete -def spectral_graph_forge( - G, alpha, transformation: str = "identity", seed: Incomplete | None = None -): ... +def spectral_graph_forge(G, alpha, transformation: str = "identity", seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/trees.pyi b/stubs/networkx/networkx/generators/trees.pyi index 052151909840..584dd3221a00 100644 --- a/stubs/networkx/networkx/generators/trees.pyi +++ b/stubs/networkx/networkx/generators/trees.pyi @@ -2,6 +2,4 @@ from _typeshed import Incomplete def prefix_tree(paths): ... def prefix_tree_recursive(paths): ... -def random_tree( - n, seed: Incomplete | None = None, create_using: Incomplete | None = None -): ... +def random_tree(n, seed: Incomplete | None = None, create_using: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/lazy_imports.pyi b/stubs/networkx/networkx/lazy_imports.pyi index 7ba1f79daff8..019a4b4f71eb 100644 --- a/stubs/networkx/networkx/lazy_imports.pyi +++ b/stubs/networkx/networkx/lazy_imports.pyi @@ -1,11 +1,7 @@ import types from _typeshed import Incomplete -def attach( - module_name, - submodules: Incomplete | None = None, - submod_attrs: Incomplete | None = None, -): ... +def attach(module_name, submodules: Incomplete | None = None, submod_attrs: Incomplete | None = None): ... class DelayedImportErrorModule(types.ModuleType): def __init__(self, frame_data, *args, **kwargs) -> None: ... diff --git a/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi b/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi index 9c74a0bcab7f..14ae63154460 100644 --- a/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi +++ b/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi @@ -1,5 +1,3 @@ from _typeshed import Incomplete -def bethe_hessian_matrix( - G, r: Incomplete | None = None, nodelist: Incomplete | None = None -): ... +def bethe_hessian_matrix(G, r: Incomplete | None = None, nodelist: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/linalg/graphmatrix.pyi b/stubs/networkx/networkx/linalg/graphmatrix.pyi index 8338bc38cd4d..b8aabe9df5ef 100644 --- a/stubs/networkx/networkx/linalg/graphmatrix.pyi +++ b/stubs/networkx/networkx/linalg/graphmatrix.pyi @@ -7,9 +7,4 @@ def incidence_matrix( oriented: bool = False, weight: Incomplete | None = None, ): ... -def adjacency_matrix( - G, - nodelist: Incomplete | None = None, - dtype: Incomplete | None = None, - weight: str = "weight", -): ... +def adjacency_matrix(G, nodelist: Incomplete | None = None, dtype: Incomplete | None = None, weight: str = "weight"): ... diff --git a/stubs/networkx/networkx/linalg/laplacianmatrix.pyi b/stubs/networkx/networkx/linalg/laplacianmatrix.pyi index 7ce9e72d541b..6f89c4d43507 100644 --- a/stubs/networkx/networkx/linalg/laplacianmatrix.pyi +++ b/stubs/networkx/networkx/linalg/laplacianmatrix.pyi @@ -1,21 +1,11 @@ from _typeshed import Incomplete def laplacian_matrix(G, nodelist: Incomplete | None = None, weight: str = "weight"): ... -def normalized_laplacian_matrix( - G, nodelist: Incomplete | None = None, weight: str = "weight" -): ... +def normalized_laplacian_matrix(G, nodelist: Incomplete | None = None, weight: str = "weight"): ... def total_spanning_tree_weight(G, weight: Incomplete | None = None): ... def directed_laplacian_matrix( - G, - nodelist: Incomplete | None = None, - weight: str = "weight", - walk_type: Incomplete | None = None, - alpha: float = 0.95, + G, nodelist: Incomplete | None = None, weight: str = "weight", walk_type: Incomplete | None = None, alpha: float = 0.95 ): ... def directed_combinatorial_laplacian_matrix( - G, - nodelist: Incomplete | None = None, - weight: str = "weight", - walk_type: Incomplete | None = None, - alpha: float = 0.95, + G, nodelist: Incomplete | None = None, weight: str = "weight", walk_type: Incomplete | None = None, alpha: float = 0.95 ): ... diff --git a/stubs/networkx/networkx/linalg/modularitymatrix.pyi b/stubs/networkx/networkx/linalg/modularitymatrix.pyi index 84f7c22d3c92..5f4e32f967a7 100644 --- a/stubs/networkx/networkx/linalg/modularitymatrix.pyi +++ b/stubs/networkx/networkx/linalg/modularitymatrix.pyi @@ -1,8 +1,4 @@ from _typeshed import Incomplete -def modularity_matrix( - G, nodelist: Incomplete | None = None, weight: Incomplete | None = None -): ... -def directed_modularity_matrix( - G, nodelist: Incomplete | None = None, weight: Incomplete | None = None -): ... +def modularity_matrix(G, nodelist: Incomplete | None = None, weight: Incomplete | None = None): ... +def directed_modularity_matrix(G, nodelist: Incomplete | None = None, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/readwrite/adjlist.pyi b/stubs/networkx/networkx/readwrite/adjlist.pyi index aa0b881f155b..901ddbce6728 100644 --- a/stubs/networkx/networkx/readwrite/adjlist.pyi +++ b/stubs/networkx/networkx/readwrite/adjlist.pyi @@ -2,9 +2,7 @@ from _typeshed import Incomplete from collections.abc import Generator 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 write_adjlist(G, path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8") -> None: ... def parse_adjlist( lines, comments: str = "#", diff --git a/stubs/networkx/networkx/readwrite/edgelist.pyi b/stubs/networkx/networkx/readwrite/edgelist.pyi index 5388f5e8f6b0..c2345c2ca88d 100644 --- a/stubs/networkx/networkx/readwrite/edgelist.pyi +++ b/stubs/networkx/networkx/readwrite/edgelist.pyi @@ -1,17 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator -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, 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 parse_edgelist( lines, comments: str = "#", @@ -30,9 +21,7 @@ def read_edgelist( 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, path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8") -> None: ... def read_weighted_edgelist( path, comments: str = "#", diff --git a/stubs/networkx/networkx/readwrite/gexf.pyi b/stubs/networkx/networkx/readwrite/gexf.pyi index 5ae5fbc7e967..4cbc852f3f1b 100644 --- a/stubs/networkx/networkx/readwrite/gexf.pyi +++ b/stubs/networkx/networkx/readwrite/gexf.pyi @@ -1,22 +1,11 @@ from _typeshed import Incomplete from collections.abc import Generator -def write_gexf( - G, - path, - encoding: str = "utf-8", - prettyprint: bool = True, - version: str = "1.2draft", -) -> None: ... +def write_gexf(G, path, encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft") -> None: ... def generate_gexf( G, encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft" ) -> Generator[Incomplete, Incomplete, None]: ... -def read_gexf( - path, - node_type: Incomplete | None = None, - relabel: bool = False, - version: str = "1.2draft", -): ... +def read_gexf(path, node_type: Incomplete | None = None, relabel: bool = False, version: str = "1.2draft"): ... class GEXF: versions: Incomplete @@ -41,11 +30,7 @@ class GEXFWriter(GEXF): all_edge_ids: Incomplete attr: Incomplete def __init__( - self, - graph: Incomplete | None = None, - encoding: str = "utf-8", - prettyprint: bool = True, - version: str = "1.2draft", + self, graph: Incomplete | None = None, encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft" ) -> None: ... graph_element: Incomplete def add_graph(self, G) -> None: ... @@ -64,16 +49,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: Incomplete | None = 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, node_xml, node_attr, node_pid: Incomplete | None = None - ) -> None: ... + def add_node(self, G, 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): ... diff --git a/stubs/networkx/networkx/readwrite/gml.pyi b/stubs/networkx/networkx/readwrite/gml.pyi index 5d0c93e20c67..a30afd0afb13 100644 --- a/stubs/networkx/networkx/readwrite/gml.pyi +++ b/stubs/networkx/networkx/readwrite/gml.pyi @@ -21,7 +21,5 @@ class Token(NamedTuple): line: int position: int -def generate_gml( - G, stringizer: Incomplete | None = None -) -> Generator[Incomplete, Incomplete, None]: ... +def generate_gml(G, stringizer: Incomplete | None = None) -> Generator[Incomplete, Incomplete, None]: ... def write_gml(G, path, stringizer: Incomplete | None = None) -> None: ... diff --git a/stubs/networkx/networkx/readwrite/graphml.pyi b/stubs/networkx/networkx/readwrite/graphml.pyi index 29626940d732..67406f755789 100644 --- a/stubs/networkx/networkx/readwrite/graphml.pyi +++ b/stubs/networkx/networkx/readwrite/graphml.pyi @@ -26,12 +26,8 @@ def generate_graphml( named_key_ids: bool = False, edge_id_from_attribute: Incomplete | None = None, ) -> Generator[Incomplete, Incomplete, None]: ... -def read_graphml( - path, node_type=..., edge_key_type=..., force_multigraph: bool = False -): ... -def parse_graphml( - graphml_string, node_type=..., edge_key_type=..., force_multigraph: bool = False -): ... +def read_graphml(path, node_type=..., edge_key_type=..., force_multigraph: bool = False): ... +def parse_graphml(graphml_string, node_type=..., edge_key_type=..., force_multigraph: bool = False): ... class GraphML: NS_GRAPHML: str @@ -66,14 +62,7 @@ class GraphMLWriter(GraphML): ) -> 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: 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: ... @@ -117,16 +106,10 @@ class GraphMLReader(GraphML): edge_key_type: Incomplete multigraph: Incomplete edge_ids: Incomplete - def __init__( - self, node_type=..., edge_key_type=..., force_multigraph: bool = False - ) -> None: ... + 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: 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 decode_data_elements(self, graphml_keys, obj_xml): ... diff --git a/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi b/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi index 9dae24dd81f3..1bf7db87a68e 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi @@ -1,7 +1,2 @@ def adjacency_data(G, attrs={"id": "id", "key": "key"}): ... -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={"id": "id", "key": "key"}): ... diff --git a/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi b/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi index ae5f3f92525a..f09488bb692f 100644 --- a/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi +++ b/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi @@ -1,12 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator -def generate_multiline_adjlist( - G, delimiter: str = " " -) -> Generator[Incomplete, None, None]: ... -def write_multiline_adjlist( - G, path, delimiter: str = " ", comments: str = "#", encoding: str = "utf-8" -) -> None: ... +def generate_multiline_adjlist(G, delimiter: str = " ") -> Generator[Incomplete, None, None]: ... +def write_multiline_adjlist(G, path, delimiter: str = " ", comments: str = "#", encoding: str = "utf-8") -> None: ... def parse_multiline_adjlist( lines, comments: str = "#", diff --git a/stubs/networkx/networkx/readwrite/sparse6.pyi b/stubs/networkx/networkx/readwrite/sparse6.pyi index 75cb5b58d7b9..9336e6f5e6ef 100644 --- a/stubs/networkx/networkx/readwrite/sparse6.pyi +++ b/stubs/networkx/networkx/readwrite/sparse6.pyi @@ -3,6 +3,4 @@ from _typeshed import Incomplete def from_sparse6_bytes(string): ... def to_sparse6_bytes(G, nodes: Incomplete | None = None, header: bool = True): ... def read_sparse6(path): ... -def write_sparse6( - G, path, nodes: Incomplete | None = None, header: bool = True -) -> None: ... +def write_sparse6(G, path, nodes: Incomplete | None = None, header: bool = True) -> None: ... diff --git a/stubs/networkx/networkx/readwrite/text.pyi b/stubs/networkx/networkx/readwrite/text.pyi index b718cb604062..d14a181376c6 100644 --- a/stubs/networkx/networkx/readwrite/text.pyi +++ b/stubs/networkx/networkx/readwrite/text.pyi @@ -54,9 +54,5 @@ def write_network_text( end: str = "\n", ) -> None: ... def forest_str( - graph, - with_labels: bool = True, - sources: Incomplete | None = None, - write: Incomplete | None = None, - ascii_only: bool = False, + graph, with_labels: bool = True, sources: Incomplete | None = None, write: Incomplete | None = None, ascii_only: bool = False ): ... diff --git a/stubs/networkx/networkx/relabel.pyi b/stubs/networkx/networkx/relabel.pyi index 708b59f9ea94..19f090d1e812 100644 --- a/stubs/networkx/networkx/relabel.pyi +++ b/stubs/networkx/networkx/relabel.pyi @@ -1,21 +1,17 @@ +from _typeshed import Incomplete from collections.abc import Mapping from typing import Any, TypeVar -from _typeshed import Incomplete +from typing_extensions import Literal from networkx.classes.graph import Graph -from typing_extensions import Literal _X = TypeVar("_X") _Y = TypeVar("_Y") -def relabel_nodes( - G: Graph[_X], mapping: Mapping[_X, _Y], copy: bool = ... -) -> Graph[_X | _Y]: ... +def relabel_nodes(G: Graph[_X], mapping: Mapping[_X, _Y], copy: bool = ...) -> Graph[_X | _Y]: ... def convert_node_labels_to_integers( G: Graph[Any], first_label: int = ..., - ordering: Literal[ - "default", "sorted", "increasing degree", "decreasing degree" - ] = ..., + ordering: Literal["default", "sorted", "increasing degree", "decreasing degree"] = ..., label_attribute: Incomplete | None = ..., ) -> Graph[int]: ... diff --git a/stubs/networkx/networkx/utils/random_sequence.pyi b/stubs/networkx/networkx/utils/random_sequence.pyi index 94d6b544a1fe..921b79a04079 100644 --- a/stubs/networkx/networkx/utils/random_sequence.pyi +++ b/stubs/networkx/networkx/utils/random_sequence.pyi @@ -4,10 +4,7 @@ def powerlaw_sequence(n, exponent: float = 2.0, seed: Incomplete | None = None): def zipf_rv(alpha, xmin: int = 1, seed: Incomplete | None = None): ... def cumulative_distribution(distribution): ... def discrete_sequence( - n, - distribution: Incomplete | None = None, - cdistribution: Incomplete | None = None, - seed: Incomplete | None = None, + 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): ... diff --git a/stubs/networkx/networkx/utils/rcm.pyi b/stubs/networkx/networkx/utils/rcm.pyi index dc63681426f3..35ff04993603 100644 --- a/stubs/networkx/networkx/utils/rcm.pyi +++ b/stubs/networkx/networkx/utils/rcm.pyi @@ -1,7 +1,5 @@ from _typeshed import Incomplete from collections.abc import Generator -def cuthill_mckee_ordering( - G, heuristic: Incomplete | None = None -) -> Generator[Incomplete, Incomplete, None]: ... +def cuthill_mckee_ordering(G, heuristic: Incomplete | None = None) -> Generator[Incomplete, Incomplete, None]: ... def reverse_cuthill_mckee_ordering(G, heuristic: Incomplete | None = None): ... From adfc9f9065c840876c6aed4e0620dcc349bad7a7 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Sun, 22 Oct 2023 14:43:09 -0700 Subject: [PATCH 03/37] Update stubs/networkx/networkx/readwrite/graphml.pyi Co-authored-by: Avasam --- stubs/networkx/networkx/readwrite/graphml.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/networkx/networkx/readwrite/graphml.pyi b/stubs/networkx/networkx/readwrite/graphml.pyi index 67406f755789..069ca96a0d47 100644 --- a/stubs/networkx/networkx/readwrite/graphml.pyi +++ b/stubs/networkx/networkx/readwrite/graphml.pyi @@ -97,7 +97,7 @@ class GraphMLWriterLxml(GraphMLWriter): ) -> None: ... def add_graph_element(self, G) -> None: ... def add_attributes(self, scope, xml_obj, data, default) -> None: ... - def dump(self) -> None: ... + def dump(self) -> None: ... # type: ignore[override] # This incompatible signature is an actual issue in networkx write_graphml = write_graphml_lxml From 7173ae0cb4c3a41f4fb8bef6ccca5ab410977902 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Sun, 22 Oct 2023 14:43:22 -0700 Subject: [PATCH 04/37] Update stubs/networkx/networkx/algorithms/flow/maxflow.pyi Co-authored-by: Avasam --- stubs/networkx/networkx/algorithms/flow/maxflow.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stubs/networkx/networkx/algorithms/flow/maxflow.pyi b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi index 19415fe84718..fa98e32cf756 100644 --- a/stubs/networkx/networkx/algorithms/flow/maxflow.pyi +++ b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi @@ -2,6 +2,8 @@ from _typeshed import Incomplete from .preflowpush import preflow_push +__all__ = ["maximum_flow", "maximum_flow_value", "minimum_cut", "minimum_cut_value"] + default_flow_func = preflow_push def maximum_flow(flowG, _s, _t, capacity: str = "capacity", flow_func: Incomplete | None = None, **kwargs): ... From cf6dad57212633d769bb176a63b2add6012b4268 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Sun, 22 Oct 2023 14:44:08 -0700 Subject: [PATCH 05/37] Update stubs/networkx/networkx/algorithms/boundary.pyi Co-authored-by: Avasam --- .../networkx/networkx/algorithms/boundary.pyi | 79 +++++++++++++------ 1 file changed, 57 insertions(+), 22 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/boundary.pyi b/stubs/networkx/networkx/algorithms/boundary.pyi index cfa6b4d28b98..b484d0183c96 100644 --- a/stubs/networkx/networkx/algorithms/boundary.pyi +++ b/stubs/networkx/networkx/algorithms/boundary.pyi @@ -12,54 +12,89 @@ _U = TypeVar("_U") def edge_boundary( G: Graph[_T], nbunch1: Iterable[_T], - nbunch2: Iterable[_T] | None = ..., - data: Literal[False] = ..., - keys: Literal[False] = ..., - default: Incomplete = ..., + nbunch2: Iterable[_T] | None = None, + data: Literal[False] = False, + keys: Literal[False] = False, + default=None, ) -> Iterable[tuple[_T, _T]]: ... @overload def edge_boundary( G: Graph[_T], nbunch1: Iterable[_T], - nbunch2: Iterable[_T] | None = ..., - data: Literal[True] = ..., - keys: Literal[False] = ..., - default: Incomplete = ..., + nbunch2: Iterable[_T] | None, + data: Literal[True], + keys: Literal[False] = False, + default=None, ) -> Iterable[tuple[_T, _T, dict[str, Incomplete]]]: ... @overload def edge_boundary( G: Graph[_T], nbunch1: Iterable[_T], - nbunch2: Iterable[_T] | None = ..., - data: str = ..., - keys: Literal[False] = ..., + nbunch2: Iterable[_T] | None = None, + *, + data: Literal[True], + keys: Literal[False] = False, + default=None, +) -> Iterable[tuple[_T, _T, dict[str, Incomplete]]]: ... +@overload +def edge_boundary( + G: Graph[_T], + nbunch1: Iterable[_T], + nbunch2: Iterable[_T] | None, + data: str, + keys: Literal[False] = False, + default: _U | None = None, +) -> Iterable[tuple[_T, _T, dict[str, _U]]]: ... +@overload +def edge_boundary( + G: Graph[_T], + nbunch1: Iterable[_T], + nbunch2: Iterable[_T] | None = None, + *, + data: str, + keys: Literal[False] = False, default: _U | None = None, ) -> Iterable[tuple[_T, _T, dict[str, _U]]]: ... @overload +def edge_boundary( + G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None, data: Literal[False], keys: Literal[True], default=None +) -> Iterable[tuple[_T, _T, int]]: ... +@overload def edge_boundary( G: Graph[_T], nbunch1: Iterable[_T], - nbunch2: Iterable[_T] | None = ..., - data: Literal[False] = ..., - keys: Literal[True] = ..., - default: Incomplete = ..., + nbunch2: Iterable[_T] | None = None, + data: Literal[False] = False, + *, + keys: Literal[True], + default=None, ) -> Iterable[tuple[_T, _T, int]]: ... @overload +def edge_boundary( + G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None, data: Literal[True], keys: Literal[True], default=None +) -> Iterable[tuple[_T, _T, int, dict[str, Incomplete]]]: ... +@overload def edge_boundary( G: Graph[_T], nbunch1: Iterable[_T], - nbunch2: Iterable[_T] | None = ..., - data: Literal[True] = ..., - keys: Literal[True] = ..., - default: Incomplete = ..., + nbunch2: Iterable[_T] | None = None, + *, + data: Literal[True], + keys: Literal[True], + default=None, ) -> Iterable[tuple[_T, _T, int, dict[str, Incomplete]]]: ... @overload +def edge_boundary( + G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None, data: str, keys: Literal[True], default: _U | None = None +) -> Iterable[tuple[_T, _T, int, dict[str, _U]]]: ... +@overload def edge_boundary( G: Graph[_T], nbunch1: Iterable[_T], - nbunch2: Iterable[_T] | None = ..., - data: str = ..., - keys: Literal[True] = ..., + nbunch2: Iterable[_T] | None = None, + *, + data: str, + keys: Literal[True], default: _U | None = None, ) -> Iterable[tuple[_T, _T, int, dict[str, _U]]]: ... def node_boundary(G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None = ...) -> Iterable[_T]: ... From 3884ce6a46db77b0e82984100b2593867fae4061 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Sun, 22 Oct 2023 14:44:19 -0700 Subject: [PATCH 06/37] Update stubs/networkx/networkx/classes/function.pyi Co-authored-by: Avasam --- stubs/networkx/networkx/classes/function.pyi | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index 2b71bbcf19d2..163e6c8af4f9 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -55,26 +55,28 @@ def is_empty(G: Graph[Any]) -> bool: ... def nodes_with_selfloops(G: Graph[_T]) -> Iterable[_T]: ... @overload def selfloop_edges( - G: Graph[_T], data: Literal[False] = ..., keys: Literal[False] = ..., default: Incomplete = ... + G: Graph[_T], data: Literal[False] = False, keys: Literal[False] = False, default=None ) -> Iterable[tuple[_T, _T]]: ... @overload def selfloop_edges( - G: Graph[_T], data: Literal[True] = ..., keys: Literal[False] = ..., default: Incomplete = ... + G: Graph[_T], data: Literal[True], keys: Literal[False] = False, default=None ) -> Iterable[tuple[_T, _T, dict[str, Incomplete]]]: ... @overload def selfloop_edges( - G: Graph[_T], data: str = ..., keys: Literal[False] = ..., default: _U | None = None + G: Graph[_T], data: str, keys: Literal[False] = False, default: _U | None = None ) -> Iterable[tuple[_T, _T, _U]]: ... @overload +def selfloop_edges(G: Graph[_T], data: Literal[False], keys: Literal[True], default=None) -> Iterable[tuple[_T, _T, int]]: ... +@overload def selfloop_edges( - G: Graph[_T], data: Literal[False] = ..., keys: Literal[True] = ..., default: Incomplete = ... + G: Graph[_T], data: Literal[False] = False, *, keys: Literal[True], default=None ) -> Iterable[tuple[_T, _T, int]]: ... @overload def selfloop_edges( - G: Graph[_T], data: Literal[True] = ..., keys: Literal[True] = ..., default: Incomplete = ... + G: Graph[_T], data: Literal[True], keys: Literal[True], default=None ) -> Iterable[tuple[_T, _T, int, dict[str, Incomplete]]]: ... @overload def selfloop_edges( - G: Graph[_T], data: str = ..., keys: Literal[True] = ..., default: _U | None = None + G: Graph[_T], data: str, keys: Literal[True], default: _U | None = None ) -> Iterable[tuple[_T, _T, int, _U]]: ... def number_of_selfloops(G: Graph[Any]) -> int: ... From 3d116d93bd0d4441f82109847cb2f5db5bf9fd80 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Sun, 22 Oct 2023 14:44:27 -0700 Subject: [PATCH 07/37] Update stubs/networkx/networkx/classes/reportviews.pyi Co-authored-by: Avasam --- .../networkx/networkx/classes/reportviews.pyi | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index b5c71c0f498e..a0f47720b126 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -60,26 +60,32 @@ class OutEdgeView(Generic[_Node]): def __contains__(self, e: Edge[_Node]) -> bool: ... def __getitem__(self, e: Edge[_Node]) -> dict[str, Incomplete]: ... @overload + def __call__(self, nbunch: NBunch[_Node] = None, data: Literal[False] = False, default=None) -> OutEdgeView[_Node]: ... + @overload def __call__( - self, nbunch: NBunch[_Node] = ..., data: Literal[False] = ..., default: Incomplete = ... - ) -> OutEdgeView[_Node]: ... + self, nbunch: NBunch[_Node], data: Literal[True], default=None + ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... @overload def __call__( - self, nbunch: NBunch[_Node] = ..., data: Literal[True] = ..., default: Incomplete = ... + self, nbunch: NBunch[_Node] = None, *, data: Literal[True], default=None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... @overload def __call__( - self, nbunch: NBunch[_Node] = ..., data: str = ..., default: _U | None = None + self, nbunch: NBunch[_Node], data: str, default: _U | None = None + ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... + @overload + def __call__( + self, nbunch: NBunch[_Node] = None, *, data: str, default: _U | None = None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... @overload - def data(self, data: Literal[False] = ..., default: Incomplete = ..., nbunch: NBunch[_Node] = ...) -> OutEdgeView[_Node]: ... + def data(self, data: Literal[False], default=None, nbunch: NBunch[_Node] = None) -> OutEdgeView[_Node]: ... @overload def data( - self, data: Literal[True] = ..., default: Incomplete = ..., nbunch: NBunch[_Node] = ... + self, data: Literal[True] = True, default=None, nbunch: NBunch[_Node] = None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... @overload def data( - self, data: str = ..., default: _U | None = None, nbunch: NBunch[_Node] = ... + self, data: str, default: _U | None = None, nbunch: NBunch[_Node] = None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... class EdgeView(OutEdgeView[_Node], Generic[_Node]): ... From d84fba03312af9217b1a6df0c5061c7ab82ba0ad Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Sun, 22 Oct 2023 14:44:38 -0700 Subject: [PATCH 08/37] Update stubs/networkx/networkx/classes/graph.pyi Co-authored-by: Avasam --- stubs/networkx/networkx/classes/graph.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi index 63dee6b6c7fa..5a0005f81bd9 100644 --- a/stubs/networkx/networkx/classes/graph.pyi +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -9,10 +9,10 @@ from networkx.classes.reportviews import DiDegreeView, NodeView, OutEdgeView from networkx.convert import _Data _Node = TypeVar("_Node", bound=Hashable) -Edge: TypeAlias = tuple[_Node, _Node] -EdgePlus: TypeAlias = Edge[_Node] | tuple[_Node, _Node, dict[str, Incomplete]] -MapFactory: TypeAlias = Callable[[], MutableMapping[str, Incomplete]] -NBunch: TypeAlias = None | _Node | Iterable[_Node] +_Edge: TypeAlias = tuple[_Node, _Node] +_EdgePlus: TypeAlias = _Edge[_Node] | tuple[_Node, _Node, dict[str, Incomplete]] +_MapFactory: TypeAlias = Callable[[], MutableMapping[str, Incomplete]] +_NBunch: TypeAlias = _Node | Iterable[_Node] | None class Graph(Collection[_Node], Generic[_Node]): node_dict_factory: ClassVar[MapFactory] = ... From b79c5919173c4269d7d91c22c9bc43f6738b5327 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Sun, 22 Oct 2023 14:44:48 -0700 Subject: [PATCH 09/37] Update stubs/networkx/networkx/algorithms/bridges.pyi Co-authored-by: Avasam --- stubs/networkx/networkx/algorithms/bridges.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/bridges.pyi b/stubs/networkx/networkx/algorithms/bridges.pyi index 0699b7e5ff53..5f25533f2cb9 100644 --- a/stubs/networkx/networkx/algorithms/bridges.pyi +++ b/stubs/networkx/networkx/algorithms/bridges.pyi @@ -9,9 +9,9 @@ def bridges(G: Graph[_Node], root: _Node | None = ...) -> Iterable[_Node]: ... def has_bridges(G: Graph[_Node], root: Incomplete | None = ...) -> bool: ... @overload def local_bridges( - G: Graph[_Node], with_span: Literal[False] = ..., weight: str | Callable[[_Node], float] | None = ... + G: Graph[_Node], with_span: Literal[False], weight: str | Callable[[_Node], float] | None = None ) -> Iterable[tuple[_Node, _Node]]: ... @overload def local_bridges( - G: Graph[_Node], with_span: Literal[True] = ..., weight: str | Callable[[_Node], float] | None = ... + G: Graph[_Node], with_span: Literal[True] = True, weight: str | Callable[[_Node], float] | None = None ) -> Iterable[tuple[_Node, _Node, int]]: ... From 423a35ebcd8b0ecbf738bee4b7e23add109c3e9c Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Sun, 22 Oct 2023 14:44:58 -0700 Subject: [PATCH 10/37] Update stubs/networkx/METADATA.toml Co-authored-by: Avasam --- stubs/networkx/METADATA.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stubs/networkx/METADATA.toml b/stubs/networkx/METADATA.toml index 68aab1119e28..a2961ec2118c 100644 --- a/stubs/networkx/METADATA.toml +++ b/stubs/networkx/METADATA.toml @@ -2,3 +2,6 @@ version = "3.1" upstream_repository = "https://github.com/networkx/networkx" requires = ["pandas-stubs", "numpy"] partial_stub = true + +[tool.stubtest] +ignore_missing_stub = true From 76d4b6fc040940f8c0e71db71a46aff69cda364e Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Sun, 22 Oct 2023 14:45:07 -0700 Subject: [PATCH 11/37] Update stubs/networkx/networkx/algorithms/tree/branchings.pyi Co-authored-by: Avasam --- stubs/networkx/networkx/algorithms/tree/branchings.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi index 42b7d55690d8..053ae313eb68 100644 --- a/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -1,7 +1,8 @@ from _typeshed import Incomplete from typing import Generic -from networkx.classes.multidigraph import MultiDiGraph, _Node +from networkx.classes.graph import _Node +from networkx.classes.multidigraph import MultiDiGraph def branching_weight(G, attr: str = "weight", default: int = 1): ... def greedy_branching(G, attr: str = "weight", default: int = 1, kind: str = "max", seed: Incomplete | None = None): ... From 90c991f32172edce0a3444175d5f1cc3293b9f90 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Sun, 22 Oct 2023 14:45:18 -0700 Subject: [PATCH 12/37] Update stubs/networkx/networkx/algorithms/tree/branchings.pyi Co-authored-by: Avasam --- stubs/networkx/networkx/algorithms/tree/branchings.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi index 053ae313eb68..67eab51e9062 100644 --- a/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -12,7 +12,7 @@ class MultiDiGraph_EdgeKey(MultiDiGraph[_Node], Generic[_Node]): def __init__(self, incoming_graph_data: Incomplete | None = None, **attr) -> None: ... def remove_node(self, n) -> None: ... def remove_nodes_from(self, nbunch) -> None: ... - def add_edge(self, u_for_edge, v_for_edge, key_for_edge, **attr) -> None: ... + def add_edge(self, u_for_edge, v_for_edge, key_for_edge, **attr) -> None: ... # type: ignore[override] # Graph.add_edge won't accept a `key_for_edge` keyword argument. def add_edges_from(self, ebunch_to_add, **attr) -> None: ... def remove_edge_with_key(self, key) -> None: ... def remove_edges_from(self, ebunch) -> None: ... From cb02f2c1b365339a52ebf407c835f6f66fc2f7c2 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Sun, 22 Oct 2023 15:02:09 -0700 Subject: [PATCH 13/37] Fix typevar names --- stubs/networkx/networkx/classes/graph.pyi | 22 +++++++-------- .../networkx/networkx/classes/reportviews.pyi | 28 +++++++++---------- stubs/networkx/networkx/convert.pyi | 4 +-- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi index 5a0005f81bd9..53c027f029c3 100644 --- a/stubs/networkx/networkx/classes/graph.pyi +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -15,12 +15,12 @@ _MapFactory: TypeAlias = Callable[[], MutableMapping[str, Incomplete]] _NBunch: TypeAlias = _Node | Iterable[_Node] | None class Graph(Collection[_Node], Generic[_Node]): - node_dict_factory: ClassVar[MapFactory] = ... - node_attr_dict_factory: ClassVar[MapFactory] = ... - adjlist_outer_dict_factory: ClassVar[MapFactory] = ... - adjlist_inner_dict_factory: ClassVar[MapFactory] = ... - edge_attr_dict_factory: ClassVar[MapFactory] = ... - graph_attr_dict_factory: ClassVar[MapFactory] = ... + node_dict_factory: ClassVar[_MapFactory] = ... + node_attr_dict_factory: ClassVar[_MapFactory] = ... + adjlist_outer_dict_factory: ClassVar[_MapFactory] = ... + adjlist_inner_dict_factory: ClassVar[_MapFactory] = ... + edge_attr_dict_factory: ClassVar[_MapFactory] = ... + graph_attr_dict_factory: ClassVar[_MapFactory] = ... def to_directed_class(self) -> type[DiGraph[_Node]]: ... def to_undirected_class(self) -> type[Graph[_Node]]: ... @@ -44,17 +44,17 @@ class Graph(Collection[_Node], Generic[_Node]): def order(self) -> int: ... def has_node(self, n: _Node) -> bool: ... def add_edge(self, u_of_edge: _Node, v_of_edge: _Node, **attr: Incomplete) -> None: ... - def add_edges_from(self, ebunch_to_add: Iterable[EdgePlus[_Node]], **attr: Incomplete) -> None: ... + def add_edges_from(self, ebunch_to_add: Iterable[_EdgePlus[_Node]], **attr: Incomplete) -> None: ... def add_weighted_edges_from( self, ebunch_to_add: Iterable[tuple[_Node, _Node, Incomplete]], weight: str = ..., **attr: Incomplete ) -> None: ... def remove_edge(self, u: _Node, v: _Node) -> None: ... - def remove_edges_from(self, ebunch: Iterable[EdgePlus[_Node]]) -> None: ... + def remove_edges_from(self, ebunch: Iterable[_EdgePlus[_Node]]) -> None: ... @overload def update(self, edges: Graph[_Node], nodes: None = None) -> None: ... @overload def update( - self, edges: Graph[_Node] | Iterable[EdgePlus[_Node]] | None = ..., nodes: Iterable[_Node] | None = ... + self, edges: Graph[_Node] | Iterable[_EdgePlus[_Node]] | None = ..., nodes: Iterable[_Node] | None = ... ) -> None: ... def has_edge(self, u: _Node, v: _Node) -> bool: ... def neighbors(self, n: _Node) -> Iterable[_Node]: ... @@ -72,10 +72,10 @@ class Graph(Collection[_Node], Generic[_Node]): def to_directed(self, as_view: bool = ...) -> DiGraph[_Node]: ... def to_undirected(self, as_view: bool = ...) -> Graph[_Node]: ... def subgraph(self, nodes: Iterable[_Node]) -> Graph[_Node]: ... - def edge_subgraph(self, edges: Iterable[Edge[_Node]]) -> Graph[_Node]: ... + def edge_subgraph(self, edges: Iterable[_Edge[_Node]]) -> Graph[_Node]: ... @overload def size(self, weight: None = ...) -> int: ... @overload def size(self, weight: str) -> float: ... def number_of_edges(self, u: _Node | None = ..., v: _Node | None = ...) -> int: ... - def nbunch_iter(self, nbunch: NBunch[_Node] = ...) -> Iterable[_Node]: ... + def nbunch_iter(self, nbunch: _NBunch[_Node] = ...) -> Iterable[_Node]: ... diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index a0f47720b126..b42caa76ce4a 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -3,7 +3,7 @@ from collections.abc import Iterator from typing import Generic, TypeVar, overload from typing_extensions import Literal -from networkx.classes.graph import Edge, Graph, NBunch, _Node +from networkx.classes.graph import _Edge, Graph, _NBunch, _Node _D = TypeVar("_D") _U = TypeVar("_U") @@ -28,8 +28,8 @@ class NodeDataView(Generic[_Node]): def __getitem__(self, n: _Node) -> Incomplete: ... class DiDegreeView(Generic[_Node]): - def __init__(self, G: Graph[_Node], nbunch: NBunch[_Node] = ..., weight: None | bool | str = ...) -> None: ... - def __call__(self, nbunch: NBunch[_Node] = ..., weight: None | bool | str = ...) -> DiDegreeView[_Node]: ... + def __init__(self, G: Graph[_Node], nbunch: _NBunch[_Node] = ..., weight: None | bool | str = ...) -> None: ... + def __call__(self, nbunch: _NBunch[_Node] = ..., weight: None | bool | str = ...) -> DiDegreeView[_Node]: ... def __getitem__(self, n: _Node) -> float: ... def __iter__(self) -> Iterator[tuple[_Node, float]]: ... def __len__(self) -> int: ... @@ -45,7 +45,7 @@ class OutMultiDegreeView(DiDegreeView[_Node], Generic[_Node]): ... class OutEdgeDataView(Generic[_Node, _D]): def __len__(self) -> int: ... def __iter__(self) -> Iterator[_D]: ... - def __contains__(self, e: Edge[_Node]) -> bool: ... + def __contains__(self, e: _Edge[_Node]) -> bool: ... class EdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): ... class InEdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): ... @@ -57,35 +57,35 @@ class OutEdgeView(Generic[_Node]): def __init__(self, graph: Graph[_Node]) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[tuple[_Node, _Node]]: ... - def __contains__(self, e: Edge[_Node]) -> bool: ... - def __getitem__(self, e: Edge[_Node]) -> dict[str, Incomplete]: ... + def __contains__(self, e: _Edge[_Node]) -> bool: ... + def __getitem__(self, e: _Edge[_Node]) -> dict[str, Incomplete]: ... @overload - def __call__(self, nbunch: NBunch[_Node] = None, data: Literal[False] = False, default=None) -> OutEdgeView[_Node]: ... + def __call__(self, nbunch: _NBunch[_Node] = None, data: Literal[False] = False, default=None) -> OutEdgeView[_Node]: ... @overload def __call__( - self, nbunch: NBunch[_Node], data: Literal[True], default=None + self, nbunch: _NBunch[_Node], data: Literal[True], default=None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... @overload def __call__( - self, nbunch: NBunch[_Node] = None, *, data: Literal[True], default=None + self, nbunch: _NBunch[_Node] = None, *, data: Literal[True], default=None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... @overload def __call__( - self, nbunch: NBunch[_Node], data: str, default: _U | None = None + self, nbunch: _NBunch[_Node], data: str, default: _U | None = None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... @overload def __call__( - self, nbunch: NBunch[_Node] = None, *, data: str, default: _U | None = None + self, nbunch: _NBunch[_Node] = None, *, data: str, default: _U | None = None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... @overload - def data(self, data: Literal[False], default=None, nbunch: NBunch[_Node] = None) -> OutEdgeView[_Node]: ... + def data(self, data: Literal[False], default=None, nbunch: _NBunch[_Node] = None) -> OutEdgeView[_Node]: ... @overload def data( - self, data: Literal[True] = True, default=None, nbunch: NBunch[_Node] = None + self, data: Literal[True] = True, default=None, nbunch: _NBunch[_Node] = None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... @overload def data( - self, data: str, default: _U | None = None, nbunch: NBunch[_Node] = None + self, data: str, default: _U | None = None, nbunch: _NBunch[_Node] = None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... class EdgeView(OutEdgeView[_Node], Generic[_Node]): ... diff --git a/stubs/networkx/networkx/convert.pyi b/stubs/networkx/networkx/convert.pyi index 6d9191096b31..b30400a7b9a9 100644 --- a/stubs/networkx/networkx/convert.pyi +++ b/stubs/networkx/networkx/convert.pyi @@ -5,14 +5,14 @@ from typing_extensions import TypeAlias import numpy # import scipy -from networkx.classes.graph import EdgePlus, Graph, _Node +from networkx.classes.graph import _EdgePlus, Graph, _Node # this is imported from other stub files _Data: TypeAlias = ( # noqa: Y047 Graph[_Node] | dict[_Node, dict[_Node, dict[str, Incomplete]]] | dict[_Node, Iterable[_Node]] - | Iterable[EdgePlus[_Node]] + | Iterable[_EdgePlus[_Node]] | numpy.ndarray[_Node, Incomplete] # | scipy.sparse.base.spmatrix ) From 83e90771852debd0a7d44aa4ad08d67d79042f1c Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Sun, 22 Oct 2023 15:10:25 -0700 Subject: [PATCH 14/37] Nuke extra incompletes --- .../algorithms/approximation/kcomponents.pyi | 2 +- .../connectivity/edge_augmentation.pyi | 4 +- stubs/networkx/networkx/algorithms/dag.pyi | 22 ++++---- .../networkx/algorithms/operators/binary.pyi | 8 +-- .../networkx/algorithms/operators/unary.pyi | 2 +- .../networkx/algorithms/planarity.pyi | 36 ++++++------- .../algorithms/shortest_paths/generic.pyi | 12 ++--- .../networkx/algorithms/simple_paths.pyi | 8 +-- .../traversal/depth_first_search.pyi | 12 ++--- stubs/networkx/networkx/classes/coreviews.pyi | 4 +- stubs/networkx/networkx/classes/function.pyi | 50 +++++++++---------- stubs/networkx/networkx/classes/graph.pyi | 8 +-- .../networkx/networkx/classes/reportviews.pyi | 2 +- stubs/networkx/networkx/drawing/nx_agraph.pyi | 4 +- 14 files changed, 85 insertions(+), 89 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi index abc93b71315f..446e474f8a87 100644 --- a/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi @@ -1,3 +1,3 @@ from _typeshed import Incomplete -def k_components(G: Incomplete, min_density: float = ...) -> Incomplete: ... +def k_components(G, min_density: float = ...): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi index 1f0aa18cbe0d..6109c1767b1d 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -6,8 +6,8 @@ from networkx.classes.graph import Graph _N = TypeVar("_N") -def is_k_edge_connected(G: Graph[Any], k: int) -> Incomplete: ... -def is_locally_k_edge_connected(G: Incomplete, s: Incomplete, t: Incomplete, k: Incomplete) -> Incomplete: ... +def is_k_edge_connected(G: Graph[Any], k: int): ... +def is_locally_k_edge_connected(G, s, t, k): ... def k_edge_augmentation( G: Graph[_N], k: int, diff --git a/stubs/networkx/networkx/algorithms/dag.pyi b/stubs/networkx/networkx/algorithms/dag.pyi index d56a9f1bf075..2ec0c68e484d 100644 --- a/stubs/networkx/networkx/algorithms/dag.pyi +++ b/stubs/networkx/networkx/algorithms/dag.pyi @@ -7,14 +7,14 @@ _T = TypeVar("_T") def descendants(G: Graph[_T], source: _T) -> set[_T]: ... def ancestors(G: Graph[_T], source: _T) -> set[_T]: ... -def is_directed_acyclic_graph(G: Incomplete) -> Incomplete: ... -def topological_sort(G: Incomplete) -> None: ... -def lexicographical_topological_sort(G: Incomplete, key: Incomplete | None = ...) -> Incomplete: ... -def all_topological_sorts(G: Incomplete) -> None: ... -def is_aperiodic(G: Incomplete) -> Incomplete: ... -def transitive_closure(G: Incomplete) -> Incomplete: ... -def transitive_reduction(G: Incomplete) -> Incomplete: ... -def antichains(G: Incomplete) -> None: ... -def dag_longest_path(G: Incomplete, weight: str = ..., default_weight: int = ...) -> Incomplete: ... -def dag_longest_path_length(G: Incomplete, weight: str = ..., default_weight: int = ...) -> Incomplete: ... -def dag_to_branching(G: Incomplete) -> Incomplete: ... +def is_directed_acyclic_graph(G): ... +def topological_sort(G) -> None: ... +def lexicographical_topological_sort(G, key: Incomplete | None = ...): ... +def all_topological_sorts(G) -> None: ... +def is_aperiodic(G): ... +def transitive_closure(G): ... +def transitive_reduction(G): ... +def antichains(G) -> None: ... +def dag_longest_path(G, weight: str = ..., default_weight: int = ...): ... +def dag_longest_path_length(G, weight: str = ..., default_weight: int = ...): ... +def dag_to_branching(G): ... diff --git a/stubs/networkx/networkx/algorithms/operators/binary.pyi b/stubs/networkx/networkx/algorithms/operators/binary.pyi index 16f99208d387..322f96187565 100644 --- a/stubs/networkx/networkx/algorithms/operators/binary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/binary.pyi @@ -3,10 +3,10 @@ from typing import TypeVar from networkx.classes.digraph import DiGraph -def disjoint_union(G: Incomplete, H: Incomplete) -> Incomplete: ... -def intersection(G: Incomplete, H: Incomplete) -> Incomplete: ... -def difference(G: Incomplete, H: Incomplete) -> Incomplete: ... -def symmetric_difference(G: Incomplete, H: Incomplete) -> Incomplete: ... +def disjoint_union(G, H): ... +def intersection(G, H): ... +def difference(G, H): ... +def symmetric_difference(G, H): ... _X = TypeVar("_X", covariant=True) _Y = TypeVar("_Y", covariant=True) diff --git a/stubs/networkx/networkx/algorithms/operators/unary.pyi b/stubs/networkx/networkx/algorithms/operators/unary.pyi index 945866c9320f..99d11041dd4e 100644 --- a/stubs/networkx/networkx/algorithms/operators/unary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/unary.pyi @@ -5,5 +5,5 @@ from networkx.classes.digraph import DiGraph _T = TypeVar("_T") -def complement(G: Incomplete) -> Incomplete: ... +def complement(G): ... def reverse(G: DiGraph[_T], copy: bool = ...) -> DiGraph[_T]: ... diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index 7f1aee2697e3..5a9a58bb9136 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -4,7 +4,7 @@ from typing import Generic, TypeVar import networkx as nx -def check_planarity(G: Incomplete, counterexample: bool = ...) -> Incomplete: ... +def check_planarity(G, counterexample: bool = ...): ... _N = TypeVar("_N") @@ -12,16 +12,16 @@ class Interval: low: Incomplete = ... high: Incomplete = ... def __init__(self, low: Incomplete | None = ..., high: Incomplete | None = ...) -> None: ... - def empty(self) -> Incomplete: ... - def copy(self) -> Incomplete: ... - def conflicting(self, b: Incomplete, planarity_state: Incomplete) -> Incomplete: ... + def empty(self): ... + def copy(self): ... + def conflicting(self, b, planarity_state): ... class ConflictPair: left: Incomplete = ... right: Incomplete = ... def __init__(self, left: Incomplete = ..., right: Incomplete = ...) -> None: ... def swap(self) -> None: ... - def lowest(self, planarity_state: Incomplete) -> Incomplete: ... + def lowest(self, planarity_state): ... class LRPlanarity: G: Incomplete = ... @@ -42,19 +42,19 @@ class LRPlanarity: left_ref: Incomplete = ... right_ref: Incomplete = ... embedding: Incomplete = ... - def __init__(self, G: Incomplete) -> None: ... - def lr_planarity(self) -> Incomplete: ... - def lr_planarity_recursive(self) -> Incomplete: ... - def dfs_orientation(self, v: Incomplete) -> Incomplete: ... - def dfs_orientation_recursive(self, v: Incomplete) -> None: ... - def dfs_testing(self, v: Incomplete) -> Incomplete: ... - def dfs_testing_recursive(self, v: Incomplete) -> Incomplete: ... - def add_constraints(self, ei: Incomplete, e: Incomplete) -> Incomplete: ... - def remove_back_edges(self, e: Incomplete) -> None: ... - def dfs_embedding(self, v: Incomplete) -> Incomplete: ... - def dfs_embedding_recursive(self, v: Incomplete) -> None: ... - def sign(self, e: Incomplete) -> Incomplete: ... - def sign_recursive(self, e: Incomplete) -> Incomplete: ... + def __init__(self, G) -> None: ... + def lr_planarity(self): ... + def lr_planarity_recursive(self): ... + def dfs_orientation(self, v): ... + def dfs_orientation_recursive(self, v) -> None: ... + def dfs_testing(self, v): ... + def dfs_testing_recursive(self, v): ... + def add_constraints(self, ei, e): ... + def remove_back_edges(self, e) -> None: ... + def dfs_embedding(self, v): ... + def dfs_embedding_recursive(self, v) -> None: ... + def sign(self, e): ... + def sign_recursive(self, e): ... class PlanarEmbedding(Generic[_N], nx.DiGraph[_N]): def get_data(self) -> dict[_N, list[_N]]: ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi index 56cda1d10ecb..0cd81b3f4e6f 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi @@ -6,7 +6,7 @@ from networkx.classes.graph import Graph _T = TypeVar("_T") -def has_path(G: Incomplete, source: Incomplete, target: Incomplete) -> Incomplete: ... +def has_path(G, source, target): ... @overload def shortest_path(G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = ..., method: str = ...) -> list[_T]: ... @overload @@ -14,13 +14,9 @@ def shortest_path(G: Graph[_T], target: _T, method: str = ...) -> dict[_T, list[ @overload def shortest_path(G: Graph[_T], source: _T, method: str = ...) -> dict[_T, list[_T]]: ... def shortest_path_length( - G: Incomplete, - source: Incomplete | None = ..., - target: Incomplete | None = ..., - weight: Incomplete | None = ..., - method: str = ..., -) -> Incomplete: ... -def average_shortest_path_length(G: Incomplete, weight: Incomplete | None = ..., method: str = ...) -> Incomplete: ... + G, source: Incomplete | None = ..., target: Incomplete | None = ..., weight: Incomplete | None = ..., method: str = ... +): ... +def average_shortest_path_length(G, weight: Incomplete | None = ..., method: str = ...): ... def all_shortest_paths( G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = ..., method: str = ... ) -> Iterable[list[_T]]: ... diff --git a/stubs/networkx/networkx/algorithms/simple_paths.pyi b/stubs/networkx/networkx/algorithms/simple_paths.pyi index 622ad547fb62..c2453650343c 100644 --- a/stubs/networkx/networkx/algorithms/simple_paths.pyi +++ b/stubs/networkx/networkx/algorithms/simple_paths.pyi @@ -6,7 +6,7 @@ from networkx.classes.graph import Graph _T = TypeVar("_T") -def is_simple_path(G: Graph[_T], nodes: list[_T]) -> Incomplete: ... +def is_simple_path(G: Graph[_T], nodes: list[_T]): ... def all_simple_paths(G: Graph[_T], source: _T, target: _T, cutoff: Incomplete | None = ...) -> Iterator[list[_T]]: ... def shortest_simple_paths(G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = ...) -> Iterator[list[_T]]: ... @@ -15,6 +15,6 @@ class PathBuffer: sortedpaths: Incomplete = ... counter: Incomplete = ... def __init__(self) -> None: ... - def __len__(self) -> Incomplete: ... - def push(self, cost: Incomplete, path: Incomplete) -> None: ... - def pop(self) -> Incomplete: ... + def __len__(self): ... + def push(self, cost, path) -> None: ... + def pop(self): ... diff --git a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi index 9aff3e8030a9..032f90b44250 100644 --- a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi @@ -7,9 +7,9 @@ from networkx.classes.graph import Graph _T = TypeVar("_T") def dfs_edges(G: Graph[_T], source: _T | None = ..., depth_limit: int | None = ...) -> Iterator[tuple[_T, _T]]: ... -def dfs_tree(G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...) -> Incomplete: ... -def dfs_predecessors(G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...) -> Incomplete: ... -def dfs_successors(G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...) -> Incomplete: ... -def dfs_postorder_nodes(G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...) -> Incomplete: ... -def dfs_preorder_nodes(G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...) -> Incomplete: ... -def dfs_labeled_edges(G: Incomplete, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...) -> None: ... +def dfs_tree(G, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...): ... +def dfs_predecessors(G, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...): ... +def dfs_successors(G, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...): ... +def dfs_postorder_nodes(G, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...): ... +def dfs_preorder_nodes(G, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...): ... +def dfs_labeled_edges(G, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...) -> None: ... diff --git a/stubs/networkx/networkx/classes/coreviews.pyi b/stubs/networkx/networkx/classes/coreviews.pyi index 581a615feb48..af4ff7ca0c4d 100644 --- a/stubs/networkx/networkx/classes/coreviews.pyi +++ b/stubs/networkx/networkx/classes/coreviews.pyi @@ -47,8 +47,8 @@ class FilterAdjacency(Mapping[_T, Mapping[_U, _V]], Generic[_T, _U, _V]): def __init__( self, d: Mapping[_T, Mapping[_U, _V]], NODE_OK: Callable[[_T], bool], EDGE_OK: Callable[[_T, _T], bool] ) -> None: ... - def __len__(self) -> Incomplete: ... - def __iter__(self) -> Incomplete: ... + def __len__(self): ... + def __iter__(self): ... def __getitem__(self, node: _T) -> FilterAtlas[_U, _V]: ... def copy(self: Self) -> Self: ... diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index 163e6c8af4f9..9b8a0a037ab6 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -8,49 +8,49 @@ from networkx.classes.graph import Graph _T = TypeVar("_T") _U = TypeVar("_U") -def nodes(G: Incomplete) -> Incomplete: ... -def edges(G: Incomplete, nbunch: Incomplete | None = ...) -> Incomplete: ... -def degree(G: Incomplete, nbunch: Incomplete | None = ..., weight: Incomplete | None = ...) -> Incomplete: ... -def neighbors(G: Incomplete, n: Incomplete) -> Incomplete: ... -def number_of_nodes(G: Incomplete) -> Incomplete: ... -def number_of_edges(G: Incomplete) -> Incomplete: ... -def density(G: Incomplete) -> Incomplete: ... -def degree_histogram(G: Incomplete) -> Incomplete: ... -def is_directed(G: Incomplete) -> Incomplete: ... -def freeze(G: Incomplete) -> Incomplete: ... -def is_frozen(G: Incomplete) -> Incomplete: ... -def add_star(G_to_add_to: Incomplete, nodes_for_star: Incomplete, **attr: Incomplete) -> None: ... -def add_path(G_to_add_to: Incomplete, nodes_for_path: Incomplete, **attr: Incomplete) -> None: ... -def add_cycle(G_to_add_to: Incomplete, nodes_for_cycle: Incomplete, **attr: Incomplete) -> None: ... -def subgraph(G: Incomplete, nbunch: Incomplete) -> Incomplete: ... +def nodes(G): ... +def edges(G, nbunch: Incomplete | None = ...): ... +def degree(G, nbunch: Incomplete | None = ..., weight: Incomplete | None = ...): ... +def neighbors(G, n): ... +def number_of_nodes(G): ... +def number_of_edges(G): ... +def density(G): ... +def degree_histogram(G): ... +def is_directed(G): ... +def freeze(G): ... +def is_frozen(G): ... +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 induced_subgraph(G: Graph[_T], nbunch: _T | Iterable[_T] | None) -> Graph[_T]: ... -def edge_subgraph(G: Incomplete, edges: Incomplete) -> Incomplete: ... -def restricted_view(G: Incomplete, nodes: Incomplete, edges: Incomplete) -> Incomplete: ... -def reverse_view(digraph: Incomplete) -> Incomplete: ... -def to_directed(graph: Incomplete) -> Incomplete: ... -def to_undirected(graph: Incomplete) -> Incomplete: ... -def create_empty_copy(G: Incomplete, with_data: bool = ...) -> Incomplete: ... -def info(G: Incomplete, n: Incomplete | None = ...) -> Incomplete: ... +def edge_subgraph(G, edges): ... +def restricted_view(G, nodes, edges): ... +def reverse_view(digraph): ... +def to_directed(graph): ... +def to_undirected(graph): ... +def create_empty_copy(G, with_data: bool = ...): ... +def info(G, n: Incomplete | None = ...): ... @overload def set_node_attributes(G: Graph[_T], values: dict[_T, Incomplete], name: str = ...) -> None: ... # Can "Any scalar value" be enforced? @overload -def set_node_attributes(G: Graph[Any], values: Incomplete, name: str = ...) -> None: ... +def set_node_attributes(G: Graph[Any], values, name: str = ...) -> None: ... @overload def set_node_attributes(G: Graph[_T], values: dict[_T, dict[Incomplete, Incomplete]], name: None = ...) -> None: ... def get_node_attributes(G: Graph[_T], name: str) -> dict[_T, Incomplete]: ... @overload def set_edge_attributes(G: Graph[_T], values: dict[tuple[_T, _T], Incomplete], name: str = ...) -> None: ... @overload -def set_edge_attributes(G: Graph[Any], values: Incomplete, name: None = ...) -> None: ... +def set_edge_attributes(G: Graph[Any], values, name: None = ...) -> None: ... def get_edge_attributes(G: Graph[_T], name: str) -> dict[tuple[_T, _T], Incomplete]: ... def all_neighbors(graph: Graph[_T], node: _T) -> Iterable[_T]: ... def non_neighbors(graph: Graph[_T], node: _T) -> Iterable[_T]: ... def non_edges(graph: Graph[_T]) -> Iterable[tuple[_T, _T]]: ... def common_neighbors(G: Graph[_T], u: _T, v: _T) -> Iterable[_T]: ... def is_weighted(G: Graph[_T], edge: tuple[_T, _T] | None = ..., weight: str | None = ...) -> bool: ... -def is_negatively_weighted(G: Graph[_T], edge: tuple[_T, _T] | None = ..., weight: str | None = ...) -> Incomplete: ... +def is_negatively_weighted(G: Graph[_T], edge: tuple[_T, _T] | None = ..., weight: str | None = ...): ... def is_empty(G: Graph[Any]) -> bool: ... def nodes_with_selfloops(G: Graph[_T]) -> Iterable[_T]: ... @overload diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi index 53c027f029c3..b3b49bc2cc1a 100644 --- a/stubs/networkx/networkx/classes/graph.pyi +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -24,7 +24,7 @@ class Graph(Collection[_Node], Generic[_Node]): def to_directed_class(self) -> type[DiGraph[_Node]]: ... def to_undirected_class(self) -> type[Graph[_Node]]: ... - def __init__(self, incoming_graph_data: _Data[_Node] | None = None, **attr: Incomplete) -> None: ... + def __init__(self, incoming_graph_data: _Data[_Node] | None = None, **attr) -> None: ... adj: AdjacencyView[_Node, _Node, dict[str, Incomplete]] name: str @@ -33,7 +33,7 @@ class Graph(Collection[_Node], Generic[_Node]): def __iter__(self) -> Iterator[_Node]: ... def __contains__(self, n: object) -> bool: ... def __len__(self) -> int: ... - def add_node(self, node_for_adding: _Node, **attr: Incomplete) -> None: ... + def add_node(self, node_for_adding: _Node, **attr) -> None: ... def add_nodes_from( self, nodes_for_adding: Iterable[_Node | tuple[_Node, dict[str, Incomplete]]], **attr: Incomplete ) -> None: ... @@ -43,8 +43,8 @@ class Graph(Collection[_Node], Generic[_Node]): def number_of_nodes(self) -> int: ... def order(self) -> int: ... def has_node(self, n: _Node) -> bool: ... - def add_edge(self, u_of_edge: _Node, v_of_edge: _Node, **attr: Incomplete) -> None: ... - def add_edges_from(self, ebunch_to_add: Iterable[_EdgePlus[_Node]], **attr: Incomplete) -> None: ... + def add_edge(self, u_of_edge: _Node, v_of_edge: _Node, **attr) -> None: ... + def add_edges_from(self, ebunch_to_add: Iterable[_EdgePlus[_Node]], **attr) -> None: ... def add_weighted_edges_from( self, ebunch_to_add: Iterable[tuple[_Node, _Node, Incomplete]], weight: str = ..., **attr: Incomplete ) -> None: ... diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index b42caa76ce4a..88888fd35eee 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -25,7 +25,7 @@ class NodeDataView(Generic[_Node]): def __len__(self) -> int: ... def __iter__(self) -> Iterator[tuple[_Node, Incomplete]]: ... def __contains__(self, n: _Node) -> bool: ... - def __getitem__(self, n: _Node) -> Incomplete: ... + def __getitem__(self, n: _Node): ... class DiDegreeView(Generic[_Node]): def __init__(self, G: Graph[_Node], nbunch: _NBunch[_Node] = ..., weight: None | bool | str = ...) -> None: ... diff --git a/stubs/networkx/networkx/drawing/nx_agraph.pyi b/stubs/networkx/networkx/drawing/nx_agraph.pyi index a173f9814b0c..d67dbe819cac 100644 --- a/stubs/networkx/networkx/drawing/nx_agraph.pyi +++ b/stubs/networkx/networkx/drawing/nx_agraph.pyi @@ -11,7 +11,7 @@ from networkx.classes.graph import Graph _AGraph: TypeAlias = Incomplete _T = TypeVar("_T") -def from_agraph(A: Incomplete, create_using: Incomplete | None = ...) -> Graph[Incomplete]: ... +def from_agraph(A, create_using: Incomplete | None = ...) -> Graph[Incomplete]: ... def to_agraph(N: Graph[Any]) -> _AGraph: ... def write_dot(G: Graph[Any], path: str | TextIOBase) -> None: ... def read_dot(path: str | TextIOBase) -> Graph[Incomplete]: ... @@ -26,4 +26,4 @@ def view_pygraphviz( args: str = ..., suffix: str = ..., path: str | None = ..., -) -> Incomplete: ... +): ... From 05daed043e11ed9f594f0d89883f886ce2d0cb73 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 22 Oct 2023 22:11:12 +0000 Subject: [PATCH 15/37] [pre-commit.ci] auto fixes from pre-commit.com hooks --- .../networkx/networkx/algorithms/approximation/kcomponents.pyi | 1 - .../networkx/algorithms/connectivity/edge_augmentation.pyi | 1 - stubs/networkx/networkx/algorithms/operators/unary.pyi | 1 - stubs/networkx/networkx/classes/coreviews.pyi | 2 +- stubs/networkx/networkx/classes/reportviews.pyi | 2 +- stubs/networkx/networkx/convert.pyi | 2 +- 6 files changed, 3 insertions(+), 6 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi index 446e474f8a87..d02ef3c24eae 100644 --- a/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi @@ -1,3 +1,2 @@ -from _typeshed import Incomplete def k_components(G, min_density: float = ...): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi index 6109c1767b1d..4e93393691b5 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -1,4 +1,3 @@ -from _typeshed import Incomplete from collections.abc import Iterable from typing import Any, TypeVar diff --git a/stubs/networkx/networkx/algorithms/operators/unary.pyi b/stubs/networkx/networkx/algorithms/operators/unary.pyi index 99d11041dd4e..6393b74a6a02 100644 --- a/stubs/networkx/networkx/algorithms/operators/unary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/unary.pyi @@ -1,4 +1,3 @@ -from _typeshed import Incomplete from typing import TypeVar from networkx.classes.digraph import DiGraph diff --git a/stubs/networkx/networkx/classes/coreviews.pyi b/stubs/networkx/networkx/classes/coreviews.pyi index af4ff7ca0c4d..2701232e3a1d 100644 --- a/stubs/networkx/networkx/classes/coreviews.pyi +++ b/stubs/networkx/networkx/classes/coreviews.pyi @@ -1,4 +1,4 @@ -from _typeshed import Incomplete, Self +from _typeshed import Self from collections.abc import Callable, Iterator, Mapping from typing import Generic, TypeVar diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index 88888fd35eee..988f7cd53525 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -3,7 +3,7 @@ from collections.abc import Iterator from typing import Generic, TypeVar, overload from typing_extensions import Literal -from networkx.classes.graph import _Edge, Graph, _NBunch, _Node +from networkx.classes.graph import Graph, _Edge, _NBunch, _Node _D = TypeVar("_D") _U = TypeVar("_U") diff --git a/stubs/networkx/networkx/convert.pyi b/stubs/networkx/networkx/convert.pyi index b30400a7b9a9..3da459bf1745 100644 --- a/stubs/networkx/networkx/convert.pyi +++ b/stubs/networkx/networkx/convert.pyi @@ -5,7 +5,7 @@ from typing_extensions import TypeAlias import numpy # import scipy -from networkx.classes.graph import _EdgePlus, Graph, _Node +from networkx.classes.graph import Graph, _EdgePlus, _Node # this is imported from other stub files _Data: TypeAlias = ( # noqa: Y047 From 9c6f2eee63971802a0a1cf05bffd622052a030d5 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 23 Oct 2023 17:59:36 -0400 Subject: [PATCH 16/37] Remove redundant Incomplete and ellipses (#2) --- .../algorithms/approximation/kcomponents.pyi | 1 - .../networkx/algorithms/planarity.pyi | 44 +++++++++---------- .../networkx/algorithms/simple_paths.pyi | 6 +-- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi index d02ef3c24eae..8a5c024a99e7 100644 --- a/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi @@ -1,2 +1 @@ - def k_components(G, min_density: float = ...): ... diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index 5a9a58bb9136..18bbad3ce85f 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -9,39 +9,39 @@ def check_planarity(G, counterexample: bool = ...): ... _N = TypeVar("_N") class Interval: - low: Incomplete = ... - high: Incomplete = ... + low: Incomplete + high: Incomplete def __init__(self, low: Incomplete | None = ..., high: Incomplete | None = ...) -> None: ... def empty(self): ... def copy(self): ... def conflicting(self, b, planarity_state): ... class ConflictPair: - left: Incomplete = ... - right: Incomplete = ... + left: Incomplete + right: Incomplete def __init__(self, left: Incomplete = ..., right: Incomplete = ...) -> None: ... def swap(self) -> None: ... def lowest(self, planarity_state): ... class LRPlanarity: - G: Incomplete = ... - roots: Incomplete = ... - height: Incomplete = ... - lowpt: Incomplete = ... - lowpt2: Incomplete = ... - nesting_depth: Incomplete = ... - parent_edge: Incomplete = ... - DG: Incomplete = ... - adjs: Incomplete = ... - ordered_adjs: Incomplete = ... - ref: Incomplete = ... - side: Incomplete = ... - S: Incomplete = ... - stack_bottom: Incomplete = ... - lowpt_edge: Incomplete = ... - left_ref: Incomplete = ... - right_ref: Incomplete = ... - embedding: Incomplete = ... + G: Incomplete + roots: Incomplete + height: Incomplete + lowpt: Incomplete + lowpt2: Incomplete + nesting_depth: Incomplete + parent_edge: Incomplete + DG: Incomplete + adjs: Incomplete + ordered_adjs: Incomplete + ref: Incomplete + side: Incomplete + S: Incomplete + stack_bottom: Incomplete + lowpt_edge: Incomplete + left_ref: Incomplete + right_ref: Incomplete + embedding: Incomplete def __init__(self, G) -> None: ... def lr_planarity(self): ... def lr_planarity_recursive(self): ... diff --git a/stubs/networkx/networkx/algorithms/simple_paths.pyi b/stubs/networkx/networkx/algorithms/simple_paths.pyi index c2453650343c..3744d7c2aa1f 100644 --- a/stubs/networkx/networkx/algorithms/simple_paths.pyi +++ b/stubs/networkx/networkx/algorithms/simple_paths.pyi @@ -11,9 +11,9 @@ def all_simple_paths(G: Graph[_T], source: _T, target: _T, cutoff: Incomplete | def shortest_simple_paths(G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = ...) -> Iterator[list[_T]]: ... class PathBuffer: - paths: Incomplete = ... - sortedpaths: Incomplete = ... - counter: Incomplete = ... + paths: Incomplete + sortedpaths: Incomplete + counter: Incomplete def __init__(self) -> None: ... def __len__(self): ... def push(self, cost, path) -> None: ... From 8a17cca4f8aa59d78ef009f9726e1214cdad1f01 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 23 Oct 2023 18:00:35 -0400 Subject: [PATCH 17/37] Adress PR comments, fix mypy and pyright issues (#3) --- stubs/networkx/METADATA.toml | 2 +- stubs/networkx/networkx/algorithms/chordal.pyi | 7 +++---- .../algorithms/components/strongly_connected.pyi | 8 ++++---- .../algorithms/components/weakly_connected.pyi | 8 ++++---- .../algorithms/connectivity/edge_augmentation.pyi | 6 +++--- .../networkx/networkx/algorithms/tree/branchings.pyi | 3 ++- stubs/networkx/networkx/algorithms/tree/mst.pyi | 3 ++- stubs/networkx/networkx/classes/coreviews.pyi | 10 ++++------ stubs/networkx/networkx/classes/function.pyi | 12 ++++++------ stubs/networkx/networkx/classes/graph.pyi | 6 +++--- stubs/networkx/networkx/drawing/nx_agraph.pyi | 8 ++++---- stubs/networkx/networkx/readwrite/gml.pyi | 8 +++++--- stubs/networkx/networkx/relabel.pyi | 6 +++--- stubs/networkx/networkx/utils/mapped_queue.pyi | 3 ++- stubs/networkx/networkx/utils/union_find.pyi | 4 ++-- 15 files changed, 48 insertions(+), 46 deletions(-) diff --git a/stubs/networkx/METADATA.toml b/stubs/networkx/METADATA.toml index a2961ec2118c..a0148a6e86c8 100644 --- a/stubs/networkx/METADATA.toml +++ b/stubs/networkx/METADATA.toml @@ -1,6 +1,6 @@ version = "3.1" upstream_repository = "https://github.com/networkx/networkx" -requires = ["pandas-stubs", "numpy"] +requires = ["numpy", "pandas-stubs"] partial_stub = true [tool.stubtest] diff --git a/stubs/networkx/networkx/algorithms/chordal.pyi b/stubs/networkx/networkx/algorithms/chordal.pyi index 0bb2c451cec6..ba71d048d620 100644 --- a/stubs/networkx/networkx/algorithms/chordal.pyi +++ b/stubs/networkx/networkx/algorithms/chordal.pyi @@ -1,12 +1,11 @@ -from collections.abc import Iterable -from typing import Any +from collections.abc import Hashable, Iterable import networkx as nx from networkx.classes.graph import Graph, _Node class NetworkXTreewidthBoundExceeded(nx.NetworkXException): ... -def is_chordal(G: Graph[Any]) -> bool: ... +def is_chordal(G: Graph[Hashable]) -> bool: ... def find_induced_nodes(G: Graph[_Node], s: _Node, t: _Node, treewidth_bound: int = ...) -> set[_Node]: ... def chordal_graph_cliques(G: Graph[_Node]) -> Iterable[frozenset[_Node]]: ... -def chordal_graph_treewidth(G: Graph[Any]) -> int: ... +def chordal_graph_treewidth(G: Graph[Hashable]) -> int: ... diff --git a/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi index 8452bda21ee0..f0bcfd8f8b21 100644 --- a/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi @@ -1,5 +1,5 @@ -from collections.abc import Iterable -from typing import Any, TypeVar +from collections.abc import Hashable, Iterable +from typing import TypeVar from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph @@ -9,6 +9,6 @@ _N = TypeVar("_N") def strongly_connected_components(G: Graph[_N]) -> Iterable[set[_N]]: ... def kosaraju_strongly_connected_components(G: Graph[_N], source: _N | None = ...) -> Iterable[set[_N]]: ... def strongly_connected_components_recursive(G: Graph[_N]) -> Iterable[set[_N]]: ... -def number_strongly_connected_components(G: Graph[Any]) -> int: ... -def is_strongly_connected(G: Graph[Any]) -> bool: ... +def number_strongly_connected_components(G: Graph[Hashable]) -> int: ... +def is_strongly_connected(G: Graph[Hashable]) -> bool: ... def condensation(G: DiGraph[_N], scc: Iterable[set[_N]] | None = ...) -> DiGraph[int]: ... diff --git a/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi b/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi index cd851dc9bb5b..7a49e5d583c8 100644 --- a/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi @@ -1,10 +1,10 @@ -from collections.abc import Iterable -from typing import Any, TypeVar +from collections.abc import Hashable, Iterable +from typing import TypeVar from networkx.classes.graph import Graph _N = TypeVar("_N") def weakly_connected_components(G: Graph[_N]) -> Iterable[set[_N]]: ... -def number_weakly_connected_components(G: Graph[Any]) -> int: ... -def is_weakly_connected(G: Graph[Any]) -> bool: ... +def number_weakly_connected_components(G: Graph[Hashable]) -> int: ... +def is_weakly_connected(G: Graph[Hashable]) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi index 4e93393691b5..1fedb4a4a11a 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -1,11 +1,11 @@ -from collections.abc import Iterable -from typing import Any, TypeVar +from collections.abc import Hashable, Iterable +from typing import TypeVar from networkx.classes.graph import Graph _N = TypeVar("_N") -def is_k_edge_connected(G: Graph[Any], k: int): ... +def is_k_edge_connected(G: Graph[Hashable], k: int): ... def is_locally_k_edge_connected(G, s, t, k): ... def k_edge_augmentation( G: Graph[_N], diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi index 67eab51e9062..b1f5239bae00 100644 --- a/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Iterator from typing import Generic from networkx.classes.graph import _Node @@ -65,5 +66,5 @@ class ArborescenceIterator: init_partition: Incomplete def __init__(self, G, weight: str = "weight", minimum: bool = True, init_partition: Incomplete | None = None) -> None: ... partition_queue: Incomplete - def __iter__(self): ... + def __iter__(self) -> Iterator[Incomplete]: ... def __next__(self): ... diff --git a/stubs/networkx/networkx/algorithms/tree/mst.pyi b/stubs/networkx/networkx/algorithms/tree/mst.pyi index 17f1a09e08d8..5aaf111b9d43 100644 --- a/stubs/networkx/networkx/algorithms/tree/mst.pyi +++ b/stubs/networkx/networkx/algorithms/tree/mst.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Iterator from enum import Enum class EdgePartition(Enum): @@ -36,5 +37,5 @@ class SpanningTreeIterator: partition_key: str def __init__(self, G, weight: str = "weight", minimum: bool = True, ignore_nan: bool = False) -> None: ... partition_queue: Incomplete - def __iter__(self): ... + def __iter__(self) -> Iterator[Incomplete]: ... def __next__(self): ... diff --git a/stubs/networkx/networkx/classes/coreviews.pyi b/stubs/networkx/networkx/classes/coreviews.pyi index 2701232e3a1d..61fc4a6e941f 100644 --- a/stubs/networkx/networkx/classes/coreviews.pyi +++ b/stubs/networkx/networkx/classes/coreviews.pyi @@ -1,6 +1,6 @@ -from _typeshed import Self from collections.abc import Callable, Iterator, Mapping from typing import Generic, TypeVar +from typing_extensions import Self _T = TypeVar("_T") _U = TypeVar("_U") @@ -11,7 +11,7 @@ class AtlasView(Mapping[_T, dict[_U, _V]], Generic[_T, _U, _V]): def __len__(self) -> int: ... def __iter__(self) -> Iterator[_T]: ... def __getitem__(self, key: _T) -> dict[_U, _V]: ... - def copy(self: Self) -> Self: ... + def copy(self) -> Self: ... class AdjacencyView(AtlasView[_T, _U, _V], Generic[_T, _U, _V]): ... class MultiAdjacencyView(AdjacencyView[_T, _U, _V], Generic[_T, _U, _V]): ... @@ -21,14 +21,14 @@ class UnionAtlas(Mapping[_T, dict[_U, _V]], Generic[_T, _U, _V]): def __len__(self) -> int: ... def __iter__(self) -> Iterator[_T]: ... def __getitem__(self, key: _T) -> dict[_U, _V]: ... - def copy(self: Self) -> Self: ... + def copy(self) -> Self: ... class UnionAdjacency(Mapping[_T, dict[_U, _V]], Generic[_T, _U, _V]): def __init__(self, succ: AdjacencyView[_T, _U, _V], pred: AdjacencyView[_T, _U, _V]) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_T]: ... def __getitem__(self, key: _T) -> dict[_U, _V]: ... - def copy(self: Self) -> Self: ... + def copy(self) -> Self: ... class UnionMultiInner(UnionAtlas[_T, _U, _V], Generic[_T, _U, _V]): ... class UnionMultiAdjacency(UnionAdjacency[_T, _U, _V], Generic[_T, _U, _V]): ... @@ -39,7 +39,6 @@ class FilterAtlas(Mapping[_T, _U], Generic[_T, _U]): def __len__(self) -> int: ... def __iter__(self) -> Iterator[_T]: ... def __getitem__(self, key: _T) -> _U: ... - def copy(self: Self) -> Self: ... class FilterAdjacency(Mapping[_T, Mapping[_U, _V]], Generic[_T, _U, _V]): NODE_OK: Callable[[_T], bool] @@ -50,7 +49,6 @@ class FilterAdjacency(Mapping[_T, Mapping[_U, _V]], Generic[_T, _U, _V]): def __len__(self): ... def __iter__(self): ... def __getitem__(self, node: _T) -> FilterAtlas[_U, _V]: ... - def copy(self: Self) -> Self: ... class FilterMultiInner(FilterAdjacency[_T, _U, _V], Generic[_T, _U, _V]): ... class FilterMultiAdjacency(FilterAdjacency[_T, _U, _V], Generic[_T, _U, _V]): ... diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index 9b8a0a037ab6..ae0c360417dd 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from collections.abc import Iterable -from typing import Any, TypeVar, overload +from collections.abc import Hashable, Iterable +from typing import TypeVar, overload from typing_extensions import Literal from networkx.classes.graph import Graph @@ -36,14 +36,14 @@ def set_node_attributes(G: Graph[_T], values: dict[_T, Incomplete], name: str = # Can "Any scalar value" be enforced? @overload -def set_node_attributes(G: Graph[Any], values, name: str = ...) -> None: ... +def set_node_attributes(G: Graph[Hashable], values, name: str = ...) -> None: ... @overload def set_node_attributes(G: Graph[_T], values: dict[_T, dict[Incomplete, Incomplete]], name: None = ...) -> None: ... def get_node_attributes(G: Graph[_T], name: str) -> dict[_T, Incomplete]: ... @overload def set_edge_attributes(G: Graph[_T], values: dict[tuple[_T, _T], Incomplete], name: str = ...) -> None: ... @overload -def set_edge_attributes(G: Graph[Any], values, name: None = ...) -> None: ... +def set_edge_attributes(G: Graph[Hashable], values, name: None = ...) -> None: ... def get_edge_attributes(G: Graph[_T], name: str) -> dict[tuple[_T, _T], Incomplete]: ... def all_neighbors(graph: Graph[_T], node: _T) -> Iterable[_T]: ... def non_neighbors(graph: Graph[_T], node: _T) -> Iterable[_T]: ... @@ -51,7 +51,7 @@ def non_edges(graph: Graph[_T]) -> Iterable[tuple[_T, _T]]: ... def common_neighbors(G: Graph[_T], u: _T, v: _T) -> Iterable[_T]: ... def is_weighted(G: Graph[_T], edge: tuple[_T, _T] | None = ..., weight: str | None = ...) -> bool: ... def is_negatively_weighted(G: Graph[_T], edge: tuple[_T, _T] | None = ..., weight: str | None = ...): ... -def is_empty(G: Graph[Any]) -> bool: ... +def is_empty(G: Graph[Hashable]) -> bool: ... def nodes_with_selfloops(G: Graph[_T]) -> Iterable[_T]: ... @overload def selfloop_edges( @@ -79,4 +79,4 @@ def selfloop_edges( def selfloop_edges( G: Graph[_T], data: str, keys: Literal[True], default: _U | None = None ) -> Iterable[tuple[_T, _T, int, _U]]: ... -def number_of_selfloops(G: Graph[Any]) -> int: ... +def number_of_selfloops(G: Graph[Hashable]) -> int: ... diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi index b3b49bc2cc1a..746a52d32c1b 100644 --- a/stubs/networkx/networkx/classes/graph.pyi +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -1,7 +1,7 @@ -from _typeshed import Incomplete, Self +from _typeshed import Incomplete from collections.abc import Callable, Collection, Hashable, Iterable, Iterator, Mapping, MutableMapping from typing import ClassVar, Generic, TypeVar, overload -from typing_extensions import TypeAlias +from typing_extensions import Self, TypeAlias from networkx.classes.coreviews import AdjacencyView from networkx.classes.digraph import DiGraph @@ -68,7 +68,7 @@ class Graph(Collection[_Node], Generic[_Node]): def clear_edges(self) -> None: ... def is_multigraph(self) -> bool: ... def is_directed(self) -> bool: ... - def copy(self: Self, as_view: bool = ...) -> Self: ... + def copy(self, as_view: bool = ...) -> Self: ... def to_directed(self, as_view: bool = ...) -> DiGraph[_Node]: ... def to_undirected(self, as_view: bool = ...) -> Graph[_Node]: ... def subgraph(self, nodes: Iterable[_Node]) -> Graph[_Node]: ... diff --git a/stubs/networkx/networkx/drawing/nx_agraph.pyi b/stubs/networkx/networkx/drawing/nx_agraph.pyi index d67dbe819cac..aeddf5ce5322 100644 --- a/stubs/networkx/networkx/drawing/nx_agraph.pyi +++ b/stubs/networkx/networkx/drawing/nx_agraph.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete -from collections.abc import Callable +from collections.abc import Callable, Hashable from io import TextIOBase -from typing import Any, TypeVar +from typing import TypeVar from typing_extensions import TypeAlias from networkx.classes.graph import Graph @@ -12,8 +12,8 @@ _AGraph: TypeAlias = Incomplete _T = TypeVar("_T") def from_agraph(A, create_using: Incomplete | None = ...) -> Graph[Incomplete]: ... -def to_agraph(N: Graph[Any]) -> _AGraph: ... -def write_dot(G: Graph[Any], path: str | TextIOBase) -> None: ... +def to_agraph(N: Graph[Hashable]) -> _AGraph: ... +def write_dot(G: Graph[Hashable], path: str | TextIOBase) -> None: ... def read_dot(path: str | TextIOBase) -> Graph[Incomplete]: ... def graphviz_layout(G: Graph[_T], prog: str = ..., root: str | None = ..., args: str = ...) -> dict[_T, tuple[float, float]]: ... diff --git a/stubs/networkx/networkx/readwrite/gml.pyi b/stubs/networkx/networkx/readwrite/gml.pyi index a30afd0afb13..d4d637c24ddc 100644 --- a/stubs/networkx/networkx/readwrite/gml.pyi +++ b/stubs/networkx/networkx/readwrite/gml.pyi @@ -1,7 +1,9 @@ from _typeshed import Incomplete from collections.abc import Generator from enum import Enum -from typing import Any, NamedTuple +from typing import Generic, NamedTuple, TypeVar + +_T = TypeVar("_T") def read_gml(path, label: str = "label", destringizer: Incomplete | None = None): ... def parse_gml(lines, label: str = "label", destringizer: Incomplete | None = None): ... @@ -15,9 +17,9 @@ class Pattern(Enum): DICT_END: int COMMENT_WHITESPACE: int -class Token(NamedTuple): +class Token(NamedTuple, Generic[_T]): category: Pattern - value: Any + value: _T line: int position: int diff --git a/stubs/networkx/networkx/relabel.pyi b/stubs/networkx/networkx/relabel.pyi index 19f090d1e812..fe73b83e31a2 100644 --- a/stubs/networkx/networkx/relabel.pyi +++ b/stubs/networkx/networkx/relabel.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from collections.abc import Mapping -from typing import Any, TypeVar +from collections.abc import Hashable, Mapping +from typing import TypeVar from typing_extensions import Literal from networkx.classes.graph import Graph @@ -10,7 +10,7 @@ _Y = TypeVar("_Y") def relabel_nodes(G: Graph[_X], mapping: Mapping[_X, _Y], copy: bool = ...) -> Graph[_X | _Y]: ... def convert_node_labels_to_integers( - G: Graph[Any], + G: Graph[Hashable], first_label: int = ..., ordering: Literal["default", "sorted", "increasing degree", "decreasing degree"] = ..., label_attribute: Incomplete | None = ..., diff --git a/stubs/networkx/networkx/utils/mapped_queue.pyi b/stubs/networkx/networkx/utils/mapped_queue.pyi index 2d3923881676..9d9fadb46ea5 100644 --- a/stubs/networkx/networkx/utils/mapped_queue.pyi +++ b/stubs/networkx/networkx/utils/mapped_queue.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Iterator class _HeapElement: priority: Incomplete @@ -9,7 +10,7 @@ class _HeapElement: def __eq__(self, other): ... def __hash__(self): ... def __getitem__(self, indx): ... - def __iter__(self): ... + def __iter__(self) -> Iterator[Incomplete]: ... class MappedQueue: heap: Incomplete diff --git a/stubs/networkx/networkx/utils/union_find.pyi b/stubs/networkx/networkx/utils/union_find.pyi index ecb881cee44e..fe50ede3c4df 100644 --- a/stubs/networkx/networkx/utils/union_find.pyi +++ b/stubs/networkx/networkx/utils/union_find.pyi @@ -1,11 +1,11 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Generator, Iterator class UnionFind: parents: Incomplete weights: Incomplete def __init__(self, elements: Incomplete | None = None) -> None: ... def __getitem__(self, object): ... - def __iter__(self): ... + def __iter__(self) -> Iterator[Incomplete]: ... def to_sets(self) -> Generator[Incomplete, Incomplete, None]: ... def union(self, *objects): ... From 7355586d84b4bd734c33ee0425014c164b08aec6 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 23 Oct 2023 18:02:01 -0400 Subject: [PATCH 18/37] Fix stubtest "is not present at runtime" issues (#4) * Fix stubtest "is not present at runtime" issues * Couple more all, maybe fixing pytype --------- Co-authored-by: Audrey Dutcher --- .../algorithms/approximation/treewidth.pyi | 2 + .../networkx/algorithms/centrality/load.pyi | 5 ++ .../networkx/algorithms/coloring/__init__.pyi | 3 +- .../algorithms/coloring/greedy_coloring.pyi | 12 +++++ .../networkx/algorithms/community/quality.pyi | 2 + .../algorithms/connectivity/connectivity.pyi | 9 ++++ .../networkx/algorithms/connectivity/cuts.pyi | 2 + .../connectivity/disjoint_paths.pyi | 2 + .../connectivity/edge_kcomponents.pyi | 2 +- .../algorithms/connectivity/kcomponents.pyi | 2 + .../algorithms/connectivity/kcutsets.pyi | 2 + .../networkx/algorithms/flow/gomory_hu.pyi | 2 + .../algorithms/isomorphism/isomorph.pyi | 2 + .../algorithms/isomorphism/isomorphvf2.pyi | 2 + .../isomorphism/temporalisomorphvf2.pyi | 2 + .../algorithms/isomorphism/vf2userfunc.pyi | 2 + .../networkx/algorithms/planarity.pyi | 5 +- .../networkx/algorithms/simple_paths.pyi | 14 ++++-- .../networkx/algorithms/tree/branchings.pyi | 11 +++++ stubs/networkx/networkx/classes/backends.pyi | 10 ++-- stubs/networkx/networkx/classes/function.pyi | 46 ++++++++++++++++++- .../networkx/generators/degree_seq.pyi | 10 ++++ .../generators/internet_as_graphs.pyi | 2 + stubs/networkx/networkx/lazy_imports.pyi | 5 +- stubs/networkx/networkx/readwrite/gexf.pyi | 2 + stubs/networkx/networkx/readwrite/gml.pyi | 2 + stubs/networkx/networkx/readwrite/graphml.pyi | 11 +++++ stubs/networkx/networkx/readwrite/text.pyi | 2 + 28 files changed, 159 insertions(+), 14 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi index 6e6c5ec06923..637f5740bf3e 100644 --- a/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi @@ -1,5 +1,7 @@ from _typeshed import Incomplete +__all__ = ["treewidth_min_degree", "treewidth_min_fill_in"] + def treewidth_min_degree(G): ... def treewidth_min_fill_in(G): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/load.pyi b/stubs/networkx/networkx/algorithms/centrality/load.pyi index d466e69dde77..a4ed84f5e6b8 100644 --- a/stubs/networkx/networkx/algorithms/centrality/load.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/load.pyi @@ -1,6 +1,11 @@ from _typeshed import Incomplete +__all__ = ["load_centrality", "edge_load_centrality"] + def newman_betweenness_centrality( G, v: Incomplete | None = None, cutoff: Incomplete | None = None, normalized: bool = True, weight: Incomplete | None = None ): ... + +load_centrality = newman_betweenness_centrality + def edge_load_centrality(G, cutoff: bool = False): ... diff --git a/stubs/networkx/networkx/algorithms/coloring/__init__.pyi b/stubs/networkx/networkx/algorithms/coloring/__init__.pyi index da07bcb03d71..764088306473 100644 --- a/stubs/networkx/networkx/algorithms/coloring/__init__.pyi +++ b/stubs/networkx/networkx/algorithms/coloring/__init__.pyi @@ -1,5 +1,4 @@ from networkx.algorithms.coloring.equitable_coloring import equitable_color as equitable_color from networkx.algorithms.coloring.greedy_coloring import * -# Names in __all__ with no definition: -# greedy_color +__all__ = ["greedy_color", "equitable_color"] diff --git a/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi b/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi index 3b158d16903b..22e42b36638b 100644 --- a/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi +++ b/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi @@ -1,6 +1,18 @@ from _typeshed import Incomplete from collections.abc import Generator +__all__ = [ + "greedy_color", + "strategy_connected_sequential", + "strategy_connected_sequential_bfs", + "strategy_connected_sequential_dfs", + "strategy_independent_set", + "strategy_largest_first", + "strategy_random_sequential", + "strategy_saturation_largest_first", + "strategy_smallest_last", +] + def strategy_largest_first(G, colors): ... def strategy_random_sequential(G, colors, seed: Incomplete | None = None): ... def strategy_smallest_last(G, colors): ... diff --git a/stubs/networkx/networkx/algorithms/community/quality.pyi b/stubs/networkx/networkx/algorithms/community/quality.pyi index d9717783f178..d8027bb2258e 100644 --- a/stubs/networkx/networkx/algorithms/community/quality.pyi +++ b/stubs/networkx/networkx/algorithms/community/quality.pyi @@ -1,5 +1,7 @@ from networkx import NetworkXError +__all__ = ["modularity", "partition_quality"] + class NotAPartition(NetworkXError): def __init__(self, G, collection) -> None: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi index 087f9b729dcf..77918d92334c 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi @@ -2,6 +2,15 @@ from _typeshed import Incomplete from networkx.algorithms.flow import edmonds_karp +__all__ = [ + "average_node_connectivity", + "local_node_connectivity", + "node_connectivity", + "local_edge_connectivity", + "edge_connectivity", + "all_pairs_node_connectivity", +] + default_flow_func = edmonds_karp def local_node_connectivity( diff --git a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi index 4cbe9b12e0ad..de6cfd051ece 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi @@ -2,6 +2,8 @@ from _typeshed import Incomplete from networkx.algorithms.flow import edmonds_karp +__all__ = ["minimum_st_node_cut", "minimum_node_cut", "minimum_st_edge_cut", "minimum_edge_cut"] + default_flow_func = edmonds_karp def minimum_st_edge_cut( diff --git a/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi b/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi index a6f68190e634..daca82b9c4f1 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi @@ -3,6 +3,8 @@ from collections.abc import Generator from networkx.algorithms.flow import edmonds_karp +__all__ = ["edge_disjoint_paths", "node_disjoint_paths"] + default_flow_func = edmonds_karp def edge_disjoint_paths( diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi index e6733f374430..b8c4a413b498 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi @@ -9,6 +9,6 @@ class EdgeComponentAuxGraph: A: Incomplete H: Incomplete @classmethod - def construct(EdgeComponentAuxGraph, G): ... + def construct(cls, G): ... def k_edge_components(self, k) -> Generator[Incomplete, Incomplete, None]: ... def k_edge_subgraphs(self, k) -> Generator[Incomplete, Incomplete, None]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi index a94ecbc78828..980187eadeef 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi @@ -2,6 +2,8 @@ from _typeshed import Incomplete from networkx.algorithms.flow import edmonds_karp +__all__ = ["k_components"] + default_flow_func = edmonds_karp def k_components(G, flow_func: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi b/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi index 75a4dc892d35..e72d0800565a 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/kcutsets.pyi @@ -3,6 +3,8 @@ from collections.abc import Generator from networkx.algorithms.flow import edmonds_karp +__all__ = ["all_node_cuts"] + default_flow_func = edmonds_karp def all_node_cuts(G, k: Incomplete | None = None, flow_func: Incomplete | None = None) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi b/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi index 15fbf39209fe..efa59ca8daa7 100644 --- a/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi +++ b/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi @@ -2,6 +2,8 @@ from _typeshed import Incomplete from .edmondskarp import edmonds_karp +__all__ = ["gomory_hu_tree"] + default_flow_func = edmonds_karp def gomory_hu_tree(G, capacity: str = "capacity", flow_func: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi b/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi index 553f6721c0be..35caa37ccf19 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi @@ -1,5 +1,7 @@ from _typeshed import Incomplete +__all__ = ["could_be_isomorphic", "fast_could_be_isomorphic", "faster_could_be_isomorphic", "is_isomorphic"] + def could_be_isomorphic(G1, G2): ... graph_could_be_isomorphic = could_be_isomorphic diff --git a/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi b/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi index 36ac0550fe58..7b2e2c3d296d 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 +__all__ = ["GraphMatcher", "DiGraphMatcher"] + class GraphMatcher: G1: Incomplete G2: Incomplete diff --git a/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi b/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi index 94297ac3f2fd..a3200872c5e1 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi @@ -2,6 +2,8 @@ from _typeshed import Incomplete from .isomorphvf2 import DiGraphMatcher, GraphMatcher +__all__ = ["TimeRespectingGraphMatcher", "TimeRespectingDiGraphMatcher"] + class TimeRespectingGraphMatcher(GraphMatcher): temporal_attribute_name: Incomplete delta: Incomplete diff --git a/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi b/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi index 79cb3ab7a02d..5c84c8f6c340 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi @@ -2,6 +2,8 @@ from _typeshed import Incomplete from . import isomorphvf2 as vf2 +__all__ = ["GraphMatcher", "DiGraphMatcher", "MultiGraphMatcher", "MultiDiGraphMatcher"] + class GraphMatcher(vf2.GraphMatcher): node_match: Incomplete edge_match: Incomplete diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index 18bbad3ce85f..e80611a54159 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -4,10 +4,13 @@ from typing import Generic, TypeVar import networkx as nx -def check_planarity(G, counterexample: bool = ...): ... +__all__ = ["check_planarity", "is_planar", "PlanarEmbedding"] _N = TypeVar("_N") +def is_planar(G) -> bool: ... +def check_planarity(G, counterexample: bool = ...): ... + class Interval: low: Incomplete high: Incomplete diff --git a/stubs/networkx/networkx/algorithms/simple_paths.pyi b/stubs/networkx/networkx/algorithms/simple_paths.pyi index 3744d7c2aa1f..cac0f0342ff1 100644 --- a/stubs/networkx/networkx/algorithms/simple_paths.pyi +++ b/stubs/networkx/networkx/algorithms/simple_paths.pyi @@ -1,14 +1,22 @@ from _typeshed import Incomplete -from collections.abc import Iterator +from collections.abc import Generator from typing import TypeVar from networkx.classes.graph import Graph +__all__ = ["all_simple_paths", "is_simple_path", "shortest_simple_paths", "all_simple_edge_paths"] _T = TypeVar("_T") def is_simple_path(G: Graph[_T], nodes: list[_T]): ... -def all_simple_paths(G: Graph[_T], source: _T, target: _T, cutoff: Incomplete | None = ...) -> Iterator[list[_T]]: ... -def shortest_simple_paths(G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = ...) -> Iterator[list[_T]]: ... +def all_simple_paths( + G: Graph[_T], source: _T, target: _T, cutoff: Incomplete | None = ... +) -> Generator[list[_T], None, None]: ... +def all_simple_edge_paths( + G: Graph[_T], source: _T, target: _T, cutoff: Incomplete | None = None +) -> Generator[list[_T] | list[tuple[_T, _T]], None, list[_T] | None]: ... +def shortest_simple_paths( + G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = ... +) -> Generator[list[_T], None, None]: ... class PathBuffer: paths: Incomplete diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi index b1f5239bae00..fd7b4da7013b 100644 --- a/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -5,6 +5,17 @@ from typing import Generic from networkx.classes.graph import _Node from networkx.classes.multidigraph import MultiDiGraph +__all__ = [ + "branching_weight", + "greedy_branching", + "maximum_branching", + "minimum_branching", + "maximum_spanning_arborescence", + "minimum_spanning_arborescence", + "ArborescenceIterator", + "Edmonds", +] + def branching_weight(G, attr: str = "weight", default: int = 1): ... def greedy_branching(G, attr: str = "weight", default: int = 1, kind: str = "max", seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/classes/backends.pyi b/stubs/networkx/networkx/classes/backends.pyi index f47d2afb0793..3d488f4b64f8 100644 --- a/stubs/networkx/networkx/classes/backends.pyi +++ b/stubs/networkx/networkx/classes/backends.pyi @@ -1,3 +1,8 @@ +from _typeshed import Incomplete +from collections.abc import Callable + +__all__ = ["_dispatch", "_mark_tests"] + class PluginInfo: def __init__(self) -> None: ... def __bool__(self) -> bool: ... @@ -6,6 +11,5 @@ class PluginInfo: def __contains__(self, name) -> bool: ... def __getitem__(self, name): ... -# Names in __all__ with no definition: -# _dispatch -# _mark_tests +def _dispatch(func: Incomplete | None = None, *, name: Incomplete | None = None) -> Callable[..., Incomplete]: ... +def _mark_tests(items) -> None: ... diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index ae0c360417dd..b9221c01bb56 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -4,7 +4,49 @@ from typing import TypeVar, overload from typing_extensions import Literal from networkx.classes.graph import Graph +from networkx.classes.graphviews import subgraph_view as subgraph_view +__all__ = [ + "nodes", + "edges", + "degree", + "degree_histogram", + "neighbors", + "number_of_nodes", + "number_of_edges", + "density", + "is_directed", + "freeze", + "is_frozen", + "subgraph", + "subgraph_view", + "induced_subgraph", + "reverse_view", + "edge_subgraph", + "restricted_view", + "to_directed", + "to_undirected", + "add_star", + "add_path", + "add_cycle", + "create_empty_copy", + "set_node_attributes", + "get_node_attributes", + "set_edge_attributes", + "get_edge_attributes", + "all_neighbors", + "non_neighbors", + "non_edges", + "common_neighbors", + "is_weighted", + "is_negatively_weighted", + "is_empty", + "selfloop_edges", + "nodes_with_selfloops", + "number_of_selfloops", + "path_weight", + "is_path", +] _T = TypeVar("_T") _U = TypeVar("_U") @@ -30,8 +72,6 @@ def reverse_view(digraph): ... def to_directed(graph): ... def to_undirected(graph): ... def create_empty_copy(G, with_data: bool = ...): ... -def info(G, n: Incomplete | None = ...): ... -@overload def set_node_attributes(G: Graph[_T], values: dict[_T, Incomplete], name: str = ...) -> None: ... # Can "Any scalar value" be enforced? @@ -80,3 +120,5 @@ def selfloop_edges( G: Graph[_T], data: str, keys: Literal[True], default: _U | None = None ) -> Iterable[tuple[_T, _T, int, _U]]: ... def number_of_selfloops(G: Graph[Hashable]) -> int: ... +def is_path(G, path) -> bool: ... +def path_weight(G, path, weight) -> int: ... diff --git a/stubs/networkx/networkx/generators/degree_seq.pyi b/stubs/networkx/networkx/generators/degree_seq.pyi index 639b1b837537..c075d61395bf 100644 --- a/stubs/networkx/networkx/generators/degree_seq.pyi +++ b/stubs/networkx/networkx/generators/degree_seq.pyi @@ -1,5 +1,15 @@ from _typeshed import Incomplete +__all__ = [ + "configuration_model", + "directed_configuration_model", + "expected_degree_graph", + "havel_hakimi_graph", + "directed_havel_hakimi_graph", + "degree_sequence_tree", + "random_degree_sequence_graph", +] + def configuration_model(deg_sequence, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... def directed_configuration_model( in_degree_sequence, out_degree_sequence, create_using: Incomplete | None = None, 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 3641675d11e7..060132735097 100644 --- a/stubs/networkx/networkx/generators/internet_as_graphs.pyi +++ b/stubs/networkx/networkx/generators/internet_as_graphs.pyi @@ -1,5 +1,7 @@ from _typeshed import Incomplete +__all__ = ["random_internet_as_graph"] + class AS_graph_generator: seed: Incomplete n_t: Incomplete diff --git a/stubs/networkx/networkx/lazy_imports.pyi b/stubs/networkx/networkx/lazy_imports.pyi index 019a4b4f71eb..b932e90af2c2 100644 --- a/stubs/networkx/networkx/lazy_imports.pyi +++ b/stubs/networkx/networkx/lazy_imports.pyi @@ -1,11 +1,12 @@ import types from _typeshed import Incomplete +__all__ = ["attach", "_lazy_import"] + def attach(module_name, submodules: Incomplete | None = None, submod_attrs: Incomplete | None = None): ... class DelayedImportErrorModule(types.ModuleType): def __init__(self, frame_data, *args, **kwargs) -> None: ... def __getattr__(self, x) -> None: ... -# Names in __all__ with no definition: -# _lazy_import +def _lazy_import(fullname) -> types.ModuleType | DelayedImportErrorModule: ... diff --git a/stubs/networkx/networkx/readwrite/gexf.pyi b/stubs/networkx/networkx/readwrite/gexf.pyi index 4cbc852f3f1b..08c030021838 100644 --- a/stubs/networkx/networkx/readwrite/gexf.pyi +++ b/stubs/networkx/networkx/readwrite/gexf.pyi @@ -1,6 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator +__all__ = ["write_gexf", "read_gexf", "relabel_gexf_graph", "generate_gexf"] + def write_gexf(G, path, encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft") -> None: ... def generate_gexf( G, encoding: str = "utf-8", prettyprint: bool = True, version: str = "1.2draft" diff --git a/stubs/networkx/networkx/readwrite/gml.pyi b/stubs/networkx/networkx/readwrite/gml.pyi index d4d637c24ddc..715c647342fb 100644 --- a/stubs/networkx/networkx/readwrite/gml.pyi +++ b/stubs/networkx/networkx/readwrite/gml.pyi @@ -5,6 +5,8 @@ from typing import Generic, NamedTuple, TypeVar _T = TypeVar("_T") +__all__ = ["read_gml", "parse_gml", "generate_gml", "write_gml"] + def read_gml(path, label: str = "label", destringizer: Incomplete | None = None): ... def parse_gml(lines, label: str = "label", destringizer: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/readwrite/graphml.pyi b/stubs/networkx/networkx/readwrite/graphml.pyi index 069ca96a0d47..b5942feb3a9b 100644 --- a/stubs/networkx/networkx/readwrite/graphml.pyi +++ b/stubs/networkx/networkx/readwrite/graphml.pyi @@ -1,6 +1,17 @@ from _typeshed import Incomplete from collections.abc import Generator +__all__ = [ + "write_graphml", + "read_graphml", + "generate_graphml", + "write_graphml_xml", + "write_graphml_lxml", + "parse_graphml", + "GraphMLWriter", + "GraphMLReader", +] + def write_graphml_xml( G, path, diff --git a/stubs/networkx/networkx/readwrite/text.pyi b/stubs/networkx/networkx/readwrite/text.pyi index d14a181376c6..27b91da83d8a 100644 --- a/stubs/networkx/networkx/readwrite/text.pyi +++ b/stubs/networkx/networkx/readwrite/text.pyi @@ -1,6 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator +__all__ = ["forest_str", "generate_network_text", "write_network_text"] + class _AsciiBaseGlyphs: empty: str newtree_last: str From ebef1076798cd43a143f7de85518f34c9e81ca7a Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 23 Oct 2023 18:04:52 -0400 Subject: [PATCH 19/37] Work around stubuploader issue (#6) https://github.com/typeshed-internal/stub_uploader/issues/90 Co-authored-by: Audrey Dutcher --- stubs/networkx/METADATA.toml | 4 +++- stubs/networkx/networkx/convert_matrix.pyi | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/stubs/networkx/METADATA.toml b/stubs/networkx/METADATA.toml index a0148a6e86c8..270518a1115d 100644 --- a/stubs/networkx/METADATA.toml +++ b/stubs/networkx/METADATA.toml @@ -1,7 +1,9 @@ version = "3.1" upstream_repository = "https://github.com/networkx/networkx" -requires = ["numpy", "pandas-stubs"] +requires = ["numpy"] partial_stub = true [tool.stubtest] ignore_missing_stub = true +# stub_uploader won't allow pandas-stubs in the requires field https://github.com/typeshed-internal/stub_uploader/issues/90 +stubtest_requirements = ["pandas"] diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index e6225ff3bfff..e4a18711363a 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -1,11 +1,15 @@ from _typeshed import Incomplete from collections.abc import Callable, Iterable -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias import numpy from networkx.classes.graph import Graph, _Node -from pandas import DataFrame -from pandas.core.dtypes.base import ExtensionDtype + +# stub_uploader won't allow pandas-stubs in the requires field https://github.com/typeshed-internal/stub_uploader/issues/90 +# from pandas import DataFrame +_DataFrame: TypeAlias = Incomplete +# from pandas.core.dtypes.base import ExtensionDtype +_ExtensionDtype: TypeAlias = Incomplete def to_pandas_adjacency( G: Graph[_Node], @@ -15,18 +19,18 @@ def to_pandas_adjacency( multigraph_weight: Callable[[Iterable[float]], float] = ..., weight: str = ..., nonedge: float = ..., -) -> DataFrame: ... -def from_pandas_adjacency(df: DataFrame, create_using: type[Graph[Incomplete]] = ...) -> Graph[Incomplete]: ... +) -> _DataFrame: ... +def from_pandas_adjacency(df: _DataFrame, create_using: type[Graph[Incomplete]] = ...) -> Graph[Incomplete]: ... def to_pandas_edgelist( G: Graph[_Node], source: str | int = ..., target: str | int = ..., nodelist: list[_Node] | None = ..., - dtype: ExtensionDtype | None = ..., + dtype: _ExtensionDtype | None = ..., edge_key: str | int | None = ..., -) -> DataFrame: ... +) -> _DataFrame: ... def from_pandas_edgelist( - df: DataFrame, + df: _DataFrame, source: str | int = ..., target: str | int = ..., edge_attr: str | int | Iterable[str | int] | Literal[True] | None = ..., From 34d72ae1f9c8256506de852446a22b6b3ba5f561 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 23 Oct 2023 15:10:16 -0700 Subject: [PATCH 20/37] Run stubdefaulter; closes #5 --- .../algorithms/approximation/kcomponents.pyi | 2 +- .../networkx/networkx/algorithms/boundary.pyi | 2 +- .../networkx/networkx/algorithms/bridges.pyi | 4 +- stubs/networkx/networkx/algorithms/chains.pyi | 2 +- stubs/networkx/networkx/algorithms/clique.pyi | 18 ++++---- .../components/strongly_connected.pyi | 4 +- .../connectivity/edge_augmentation.pyi | 6 +-- stubs/networkx/networkx/algorithms/dag.pyi | 6 +-- .../networkx/algorithms/operators/binary.pyi | 2 +- .../networkx/algorithms/operators/unary.pyi | 2 +- .../networkx/algorithms/planarity.pyi | 6 +-- .../algorithms/shortest_paths/generic.pyi | 18 +++++--- .../networkx/algorithms/simple_paths.pyi | 4 +- .../traversal/depth_first_search.pyi | 14 +++---- stubs/networkx/networkx/classes/digraph.pyi | 4 +- stubs/networkx/networkx/classes/function.pyi | 19 ++++----- stubs/networkx/networkx/classes/graph.pyi | 18 ++++---- .../networkx/classes/multidigraph.pyi | 6 +-- .../networkx/networkx/classes/multigraph.pyi | 8 ++-- .../networkx/networkx/classes/reportviews.pyi | 12 +++--- stubs/networkx/networkx/convert_matrix.pyi | 42 +++++++++---------- stubs/networkx/networkx/drawing/nx_agraph.pyi | 16 +++---- stubs/networkx/networkx/relabel.pyi | 8 ++-- 23 files changed, 115 insertions(+), 108 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi index 8a5c024a99e7..2a0bd9b1d082 100644 --- a/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi @@ -1 +1 @@ -def k_components(G, min_density: float = ...): ... +def k_components(G, min_density: float = 0.95): ... diff --git a/stubs/networkx/networkx/algorithms/boundary.pyi b/stubs/networkx/networkx/algorithms/boundary.pyi index b484d0183c96..cc4785675777 100644 --- a/stubs/networkx/networkx/algorithms/boundary.pyi +++ b/stubs/networkx/networkx/algorithms/boundary.pyi @@ -97,4 +97,4 @@ def edge_boundary( keys: Literal[True], default: _U | None = None, ) -> Iterable[tuple[_T, _T, int, dict[str, _U]]]: ... -def node_boundary(G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None = ...) -> Iterable[_T]: ... +def node_boundary(G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None = None) -> Iterable[_T]: ... diff --git a/stubs/networkx/networkx/algorithms/bridges.pyi b/stubs/networkx/networkx/algorithms/bridges.pyi index 5f25533f2cb9..893cba294b25 100644 --- a/stubs/networkx/networkx/algorithms/bridges.pyi +++ b/stubs/networkx/networkx/algorithms/bridges.pyi @@ -5,8 +5,8 @@ from typing_extensions import Literal from networkx.classes.graph import Graph, _Node -def bridges(G: Graph[_Node], root: _Node | None = ...) -> Iterable[_Node]: ... -def has_bridges(G: Graph[_Node], root: Incomplete | None = ...) -> bool: ... +def bridges(G: Graph[_Node], root: _Node | None = None) -> Iterable[_Node]: ... +def has_bridges(G: Graph[_Node], root: Incomplete | None = None) -> bool: ... @overload def local_bridges( G: Graph[_Node], with_span: Literal[False], weight: str | Callable[[_Node], float] | None = None diff --git a/stubs/networkx/networkx/algorithms/chains.pyi b/stubs/networkx/networkx/algorithms/chains.pyi index 8fad5f76313d..f054e87db62c 100644 --- a/stubs/networkx/networkx/algorithms/chains.pyi +++ b/stubs/networkx/networkx/algorithms/chains.pyi @@ -2,4 +2,4 @@ from collections.abc import Iterable from networkx.classes.graph import Graph, _Node -def chain_decomposition(G: Graph[_Node], root: _Node | None = ...) -> Iterable[tuple[_Node, _Node]]: ... +def chain_decomposition(G: Graph[_Node], root: _Node | None = None) -> Iterable[tuple[_Node, _Node]]: ... diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi index f26559ef2737..d7fc97d85f11 100644 --- a/stubs/networkx/networkx/algorithms/clique.pyi +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -3,16 +3,16 @@ from collections.abc import Iterable from networkx.classes.graph import Graph, _Node def enumerate_all_cliques(G: Graph[_Node]) -> Iterable[list[_Node]]: ... -def find_cliques(G: Graph[_Node], nodes: list[_Node] | None = ...) -> Iterable[list[_Node]]: ... -def find_cliques_recursive(G: Graph[_Node], nodes: list[_Node] | None = ...) -> Iterable[list[_Node]]: ... -def make_max_clique_graph(G: Graph[_Node], create_using: type[Graph[_Node]] = ...) -> Graph[_Node]: ... +def find_cliques(G: Graph[_Node], nodes: list[_Node] | None = None) -> Iterable[list[_Node]]: ... +def find_cliques_recursive(G: Graph[_Node], nodes: list[_Node] | None = None) -> Iterable[list[_Node]]: ... +def make_max_clique_graph(G: Graph[_Node], create_using: type[Graph[_Node]] = None) -> Graph[_Node]: ... def make_clique_bipartite( - G: Graph[_Node], fpos: None = ..., create_using: type[Graph[_Node]] = ..., name: None = ... + G: Graph[_Node], fpos: None = None, create_using: type[Graph[_Node]] = None, name: None = None ) -> Graph[_Node]: ... -def graph_clique_number(G: Graph[_Node], cliques: list[_Node] | None = ...) -> int: ... -def graph_number_of_cliques(G: Graph[_Node], cliques: list[_Node] | None = ...) -> int: ... -def node_clique_number(G: Graph[_Node], nodes: list[_Node] | None = ..., cliques: list[list[_Node]] | None = ...) -> int: ... -def number_of_cliques(G: Graph[_Node], nodes: list[_Node] | None = ..., cliques: list[list[_Node]] | None = ...) -> int: ... +def graph_clique_number(G: Graph[_Node], cliques: list[_Node] | None = None) -> int: ... +def graph_number_of_cliques(G: Graph[_Node], cliques: list[_Node] | None = None) -> int: ... +def node_clique_number(G: Graph[_Node], nodes: list[_Node] | None = None, cliques: list[list[_Node]] | None = None) -> int: ... +def number_of_cliques(G: Graph[_Node], nodes: list[_Node] | None = None, cliques: list[list[_Node]] | None = None) -> int: ... def cliques_containing_node( - G: Graph[_Node], nodes: list[_Node] | None = ..., cliques: list[list[_Node]] | None = ... + G: Graph[_Node], nodes: list[_Node] | None = None, cliques: list[list[_Node]] | None = None ) -> Iterable[list[_Node]]: ... diff --git a/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi index f0bcfd8f8b21..918807abfa01 100644 --- a/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi @@ -7,8 +7,8 @@ from networkx.classes.graph import Graph _N = TypeVar("_N") def strongly_connected_components(G: Graph[_N]) -> Iterable[set[_N]]: ... -def kosaraju_strongly_connected_components(G: Graph[_N], source: _N | None = ...) -> Iterable[set[_N]]: ... +def kosaraju_strongly_connected_components(G: Graph[_N], source: _N | None = None) -> Iterable[set[_N]]: ... def strongly_connected_components_recursive(G: Graph[_N]) -> Iterable[set[_N]]: ... def number_strongly_connected_components(G: Graph[Hashable]) -> int: ... def is_strongly_connected(G: Graph[Hashable]) -> bool: ... -def condensation(G: DiGraph[_N], scc: Iterable[set[_N]] | None = ...) -> DiGraph[int]: ... +def condensation(G: DiGraph[_N], scc: Iterable[set[_N]] | None = None) -> DiGraph[int]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi index 1fedb4a4a11a..a1c6b3a7f13d 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -10,7 +10,7 @@ def is_locally_k_edge_connected(G, s, t, k): ... def k_edge_augmentation( G: Graph[_N], k: int, - avail: tuple[_N, _N] | tuple[_N, _N, dict[str, int]] | None = ..., - weight: str | None = ..., - partial: bool = ..., + avail: tuple[_N, _N] | tuple[_N, _N, dict[str, int]] | None = None, + weight: str | None = None, + partial: bool = False, ) -> Iterable[tuple[_N, _N]]: ... diff --git a/stubs/networkx/networkx/algorithms/dag.pyi b/stubs/networkx/networkx/algorithms/dag.pyi index 2ec0c68e484d..e6427f6eb4b3 100644 --- a/stubs/networkx/networkx/algorithms/dag.pyi +++ b/stubs/networkx/networkx/algorithms/dag.pyi @@ -9,12 +9,12 @@ def descendants(G: Graph[_T], source: _T) -> set[_T]: ... def ancestors(G: Graph[_T], source: _T) -> set[_T]: ... def is_directed_acyclic_graph(G): ... def topological_sort(G) -> None: ... -def lexicographical_topological_sort(G, key: Incomplete | None = ...): ... +def lexicographical_topological_sort(G, key: Incomplete | None = None): ... def all_topological_sorts(G) -> None: ... def is_aperiodic(G): ... def transitive_closure(G): ... def transitive_reduction(G): ... def antichains(G) -> None: ... -def dag_longest_path(G, weight: str = ..., default_weight: int = ...): ... -def dag_longest_path_length(G, weight: str = ..., default_weight: int = ...): ... +def dag_longest_path(G, weight: str = "weight", default_weight: int = 1): ... +def dag_longest_path_length(G, weight: str = "weight", default_weight: int = 1): ... def dag_to_branching(G): ... diff --git a/stubs/networkx/networkx/algorithms/operators/binary.pyi b/stubs/networkx/networkx/algorithms/operators/binary.pyi index 322f96187565..53bbe884fa6b 100644 --- a/stubs/networkx/networkx/algorithms/operators/binary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/binary.pyi @@ -14,4 +14,4 @@ _Y = TypeVar("_Y", covariant=True) # TODO: This does not handle the cases when graphs of different types are passed which is allowed def compose(G: DiGraph[_X], H: DiGraph[_Y]) -> DiGraph[_X | _Y]: ... -def union(G: DiGraph[_X], H: DiGraph[_Y], rename: Incomplete = ..., name: Incomplete | None = ...) -> DiGraph[_X | _Y]: ... +def union(G: DiGraph[_X], H: DiGraph[_Y], rename: Incomplete = (), name: Incomplete | None = ...) -> DiGraph[_X | _Y]: ... diff --git a/stubs/networkx/networkx/algorithms/operators/unary.pyi b/stubs/networkx/networkx/algorithms/operators/unary.pyi index 6393b74a6a02..942c2ae6c41e 100644 --- a/stubs/networkx/networkx/algorithms/operators/unary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/unary.pyi @@ -5,4 +5,4 @@ from networkx.classes.digraph import DiGraph _T = TypeVar("_T") def complement(G): ... -def reverse(G: DiGraph[_T], copy: bool = ...) -> DiGraph[_T]: ... +def reverse(G: DiGraph[_T], copy: bool = True) -> DiGraph[_T]: ... diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index e80611a54159..c1f2f0373625 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -9,12 +9,12 @@ __all__ = ["check_planarity", "is_planar", "PlanarEmbedding"] _N = TypeVar("_N") def is_planar(G) -> bool: ... -def check_planarity(G, counterexample: bool = ...): ... +def check_planarity(G, counterexample: bool = False): ... class Interval: low: Incomplete high: Incomplete - def __init__(self, low: Incomplete | None = ..., high: Incomplete | None = ...) -> None: ... + def __init__(self, low: Incomplete | None = None, high: Incomplete | None = None) -> None: ... def empty(self): ... def copy(self): ... def conflicting(self, b, planarity_state): ... @@ -69,5 +69,5 @@ class PlanarEmbedding(Generic[_N], nx.DiGraph[_N]): def connect_components(self, v: _N, w: _N) -> None: ... def add_half_edge_first(self, start_node: _N, end_node: _N) -> None: ... def next_face_half_edge(self, v: _N, w: _N) -> tuple[_N, _N]: ... - def traverse_face(self, v: _N, w: _N, mark_half_edges: set[tuple[_N, _N]] | None = ...) -> list[_N]: ... + def traverse_face(self, v: _N, w: _N, mark_half_edges: set[tuple[_N, _N]] | None = None) -> list[_N]: ... def is_directed(self) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi index 0cd81b3f4e6f..b9870fe0f080 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi @@ -8,15 +8,21 @@ _T = TypeVar("_T") def has_path(G, source, target): ... @overload -def shortest_path(G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = ..., method: str = ...) -> list[_T]: ... +def shortest_path( + G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = None, method: str = "dijkstra" +) -> list[_T]: ... @overload -def shortest_path(G: Graph[_T], target: _T, method: str = ...) -> dict[_T, list[_T]]: ... +def shortest_path(G: Graph[_T], target: _T, method: str = "dijkstra") -> dict[_T, list[_T]]: ... @overload -def shortest_path(G: Graph[_T], source: _T, method: str = ...) -> dict[_T, list[_T]]: ... +def shortest_path(G: Graph[_T], source: _T, method: str = "dijkstra") -> dict[_T, list[_T]]: ... def shortest_path_length( - G, source: Incomplete | None = ..., target: Incomplete | None = ..., weight: Incomplete | None = ..., method: str = ... + G, + source: Incomplete | None = None, + target: Incomplete | None = None, + weight: Incomplete | None = None, + method: str = "dijkstra", ): ... -def average_shortest_path_length(G, weight: Incomplete | None = ..., method: str = ...): ... +def average_shortest_path_length(G, weight: Incomplete | None = None, method: str = None): ... def all_shortest_paths( - G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = ..., method: str = ... + G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = None, method: str = "dijkstra" ) -> Iterable[list[_T]]: ... diff --git a/stubs/networkx/networkx/algorithms/simple_paths.pyi b/stubs/networkx/networkx/algorithms/simple_paths.pyi index cac0f0342ff1..e49301aa5cd5 100644 --- a/stubs/networkx/networkx/algorithms/simple_paths.pyi +++ b/stubs/networkx/networkx/algorithms/simple_paths.pyi @@ -9,13 +9,13 @@ _T = TypeVar("_T") def is_simple_path(G: Graph[_T], nodes: list[_T]): ... def all_simple_paths( - G: Graph[_T], source: _T, target: _T, cutoff: Incomplete | None = ... + G: Graph[_T], source: _T, target: _T, cutoff: Incomplete | None = None ) -> Generator[list[_T], None, None]: ... def all_simple_edge_paths( G: Graph[_T], source: _T, target: _T, cutoff: Incomplete | None = None ) -> Generator[list[_T] | list[tuple[_T, _T]], None, list[_T] | None]: ... def shortest_simple_paths( - G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = ... + G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = None ) -> Generator[list[_T], None, None]: ... class PathBuffer: diff --git a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi index 032f90b44250..234cc81955a6 100644 --- a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi @@ -6,10 +6,10 @@ from networkx.classes.graph import Graph _T = TypeVar("_T") -def dfs_edges(G: Graph[_T], source: _T | None = ..., depth_limit: int | None = ...) -> Iterator[tuple[_T, _T]]: ... -def dfs_tree(G, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...): ... -def dfs_predecessors(G, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...): ... -def dfs_successors(G, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...): ... -def dfs_postorder_nodes(G, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...): ... -def dfs_preorder_nodes(G, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...): ... -def dfs_labeled_edges(G, source: Incomplete | None = ..., depth_limit: Incomplete | None = ...) -> None: ... +def dfs_edges(G: Graph[_T], source: _T | None = None, depth_limit: int | None = None) -> Iterator[tuple[_T, _T]]: ... +def dfs_tree(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... +def dfs_predecessors(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... +def dfs_successors(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... +def dfs_postorder_nodes(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... +def dfs_preorder_nodes(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... +def dfs_labeled_edges(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None) -> None: ... diff --git a/stubs/networkx/networkx/classes/digraph.pyi b/stubs/networkx/networkx/classes/digraph.pyi index fbd2374047a1..ab333d888948 100644 --- a/stubs/networkx/networkx/classes/digraph.pyi +++ b/stubs/networkx/networkx/classes/digraph.pyi @@ -24,5 +24,5 @@ class DiGraph(Graph[_Node], Generic[_Node]): in_degree: InDegreeView[_Node] | InMultiDegreeView[_Node] # ugly hack to make MultiDiGraph work out_edges: OutEdgeView[_Node] out_degree: OutDegreeView[_Node] | OutMultiDegreeView[_Node] # ugly hack to make MultiDiGraph work - def reverse(self, copy: bool = ...) -> DiGraph[_Node]: ... - def copy(self, as_view: bool = ...) -> DiGraph[_Node]: ... + def reverse(self, copy: bool = True) -> DiGraph[_Node]: ... + def copy(self, as_view: bool = False) -> DiGraph[_Node]: ... diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index b9221c01bb56..032f5ca9d861 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -51,8 +51,8 @@ _T = TypeVar("_T") _U = TypeVar("_U") def nodes(G): ... -def edges(G, nbunch: Incomplete | None = ...): ... -def degree(G, nbunch: Incomplete | None = ..., weight: Incomplete | None = ...): ... +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): ... @@ -71,26 +71,25 @@ def restricted_view(G, nodes, edges): ... def reverse_view(digraph): ... def to_directed(graph): ... def to_undirected(graph): ... -def create_empty_copy(G, with_data: bool = ...): ... -def set_node_attributes(G: Graph[_T], values: dict[_T, Incomplete], name: str = ...) -> None: ... +def create_empty_copy(G, with_data: bool = True): ... # Can "Any scalar value" be enforced? @overload -def set_node_attributes(G: Graph[Hashable], values, name: str = ...) -> None: ... +def set_node_attributes(G: Graph[Hashable], values, name: str = None) -> None: ... @overload -def set_node_attributes(G: Graph[_T], values: dict[_T, dict[Incomplete, Incomplete]], name: None = ...) -> None: ... +def set_node_attributes(G: Graph[_T], values: dict[_T, dict[Incomplete, Incomplete]], name: None = None) -> None: ... def get_node_attributes(G: Graph[_T], name: str) -> dict[_T, Incomplete]: ... @overload -def set_edge_attributes(G: Graph[_T], values: dict[tuple[_T, _T], Incomplete], name: str = ...) -> None: ... +def set_edge_attributes(G: Graph[_T], values: dict[tuple[_T, _T], Incomplete], name: str = None) -> None: ... @overload -def set_edge_attributes(G: Graph[Hashable], values, name: None = ...) -> None: ... +def set_edge_attributes(G: Graph[Hashable], values, name: None = None) -> None: ... def get_edge_attributes(G: Graph[_T], name: str) -> dict[tuple[_T, _T], Incomplete]: ... def all_neighbors(graph: Graph[_T], node: _T) -> Iterable[_T]: ... def non_neighbors(graph: Graph[_T], node: _T) -> Iterable[_T]: ... def non_edges(graph: Graph[_T]) -> Iterable[tuple[_T, _T]]: ... def common_neighbors(G: Graph[_T], u: _T, v: _T) -> Iterable[_T]: ... -def is_weighted(G: Graph[_T], edge: tuple[_T, _T] | None = ..., weight: str | None = ...) -> bool: ... -def is_negatively_weighted(G: Graph[_T], edge: tuple[_T, _T] | None = ..., weight: str | None = ...): ... +def is_weighted(G: Graph[_T], edge: tuple[_T, _T] | None = None, weight: str | None = "weight") -> bool: ... +def is_negatively_weighted(G: Graph[_T], edge: tuple[_T, _T] | None = None, weight: str | None = "weight"): ... def is_empty(G: Graph[Hashable]) -> bool: ... def nodes_with_selfloops(G: Graph[_T]) -> Iterable[_T]: ... @overload diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi index 746a52d32c1b..ba2938046993 100644 --- a/stubs/networkx/networkx/classes/graph.pyi +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -46,7 +46,7 @@ class Graph(Collection[_Node], Generic[_Node]): def add_edge(self, u_of_edge: _Node, v_of_edge: _Node, **attr) -> None: ... def add_edges_from(self, ebunch_to_add: Iterable[_EdgePlus[_Node]], **attr) -> None: ... def add_weighted_edges_from( - self, ebunch_to_add: Iterable[tuple[_Node, _Node, Incomplete]], weight: str = ..., **attr: Incomplete + self, ebunch_to_add: Iterable[tuple[_Node, _Node, Incomplete]], weight: str = "weight", **attr: Incomplete ) -> None: ... def remove_edge(self, u: _Node, v: _Node) -> None: ... def remove_edges_from(self, ebunch: Iterable[_EdgePlus[_Node]]) -> None: ... @@ -54,12 +54,12 @@ class Graph(Collection[_Node], Generic[_Node]): def update(self, edges: Graph[_Node], nodes: None = None) -> None: ... @overload def update( - self, edges: Graph[_Node] | Iterable[_EdgePlus[_Node]] | None = ..., nodes: Iterable[_Node] | None = ... + self, edges: Graph[_Node] | Iterable[_EdgePlus[_Node]] | None = None, nodes: Iterable[_Node] | None = None ) -> None: ... def has_edge(self, u: _Node, v: _Node) -> bool: ... def neighbors(self, n: _Node) -> Iterable[_Node]: ... edges: OutEdgeView[_Node] - def get_edge_data(self, u: _Node, v: _Node, default: Incomplete = ...) -> Mapping[str, Incomplete]: ... + def get_edge_data(self, u: _Node, v: _Node, default: Incomplete = None) -> Mapping[str, Incomplete]: ... def adjacency(self) -> Iterable[tuple[_Node, Mapping[_Node, Mapping[str, Incomplete]]]]: ... degree: DiDegreeView[_Node] @@ -68,14 +68,14 @@ class Graph(Collection[_Node], Generic[_Node]): def clear_edges(self) -> None: ... def is_multigraph(self) -> bool: ... def is_directed(self) -> bool: ... - def copy(self, as_view: bool = ...) -> Self: ... - def to_directed(self, as_view: bool = ...) -> DiGraph[_Node]: ... - def to_undirected(self, as_view: bool = ...) -> Graph[_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 edge_subgraph(self, edges: Iterable[_Edge[_Node]]) -> Graph[_Node]: ... @overload - def size(self, weight: None = ...) -> int: ... + def size(self, weight: None = None) -> int: ... @overload def size(self, weight: str) -> float: ... - def number_of_edges(self, u: _Node | None = ..., v: _Node | None = ...) -> int: ... - def nbunch_iter(self, nbunch: _NBunch[_Node] = ...) -> Iterable[_Node]: ... + def number_of_edges(self, u: _Node | None = None, v: _Node | None = None) -> int: ... + def nbunch_iter(self, nbunch: _NBunch[_Node] = None) -> Iterable[_Node]: ... diff --git a/stubs/networkx/networkx/classes/multidigraph.pyi b/stubs/networkx/networkx/classes/multidigraph.pyi index d20eb4732ce7..8f90911ec1db 100644 --- a/stubs/networkx/networkx/classes/multidigraph.pyi +++ b/stubs/networkx/networkx/classes/multidigraph.pyi @@ -7,6 +7,6 @@ class MultiDiGraph(MultiGraph[_Node], DiGraph[_Node]): degree: MultiDegreeView[_Node] in_degree: InMultiDegreeView[_Node] out_degree: OutMultiDegreeView[_Node] - def to_undirected(self, reciprocal: bool = ..., as_view: bool = ...) -> MultiGraph[_Node]: ... # type: ignore - def reverse(self, copy: bool = ...) -> MultiDiGraph[_Node]: ... - def copy(self, as_view: bool = ...) -> MultiDiGraph[_Node]: ... + def to_undirected(self, reciprocal: bool = False, as_view: bool = False) -> MultiGraph[_Node]: ... # type: ignore + 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 088662fe9a4d..463efc09a509 100644 --- a/stubs/networkx/networkx/classes/multigraph.pyi +++ b/stubs/networkx/networkx/classes/multigraph.pyi @@ -5,7 +5,7 @@ from networkx.classes.multidigraph import MultiDiGraph class MultiGraph(Graph[_Node], Generic[_Node]): def new_edge_key(self, u: _Node, v: _Node) -> int: ... - def copy(self, as_view: bool = ...) -> MultiGraph[_Node]: ... - def to_directed(self, as_view: bool = ...) -> MultiDiGraph[_Node]: ... - def to_undirected(self, as_view: bool = ...) -> MultiGraph[_Node]: ... - def number_of_edges(self, u: _Node | None = ..., v: _Node | None = ...) -> int: ... + 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: ... diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index 988f7cd53525..00daca212ca7 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -15,21 +15,21 @@ class NodeView(Generic[_Node]): def __getitem__(self, n: _Node) -> _Node: ... def __contains__(self, n: object) -> bool: ... @overload - def __call__(self, data: Literal[False] = ..., default: Incomplete = ...) -> NodeView[_Node]: ... + def __call__(self, data: Literal[False] = False, default: Incomplete = None) -> NodeView[_Node]: ... @overload - def __call__(self, data: Literal[True] | str, default: Incomplete = ...) -> NodeDataView[_Node]: ... - def data(self, data: bool | str = ..., default: Incomplete = ...) -> NodeDataView[_Node]: ... + def __call__(self, data: Literal[True] | str, default: Incomplete = None) -> NodeDataView[_Node]: ... + def data(self, data: bool | str = True, default: Incomplete = None) -> NodeDataView[_Node]: ... class NodeDataView(Generic[_Node]): - def __init__(self, nodedict: dict[str, Incomplete], data: bool | str = ..., default: Incomplete = ...) -> None: ... + def __init__(self, nodedict: dict[str, Incomplete], data: bool | str = False, default: Incomplete = None) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[tuple[_Node, Incomplete]]: ... def __contains__(self, n: _Node) -> bool: ... def __getitem__(self, n: _Node): ... class DiDegreeView(Generic[_Node]): - def __init__(self, G: Graph[_Node], nbunch: _NBunch[_Node] = ..., weight: None | bool | str = ...) -> None: ... - def __call__(self, nbunch: _NBunch[_Node] = ..., weight: None | bool | str = ...) -> DiDegreeView[_Node]: ... + def __init__(self, G: Graph[_Node], nbunch: _NBunch[_Node] = None, weight: None | bool | str = None) -> None: ... + def __call__(self, nbunch: _NBunch[_Node] = None, weight: None | bool | str = None) -> DiDegreeView[_Node]: ... def __getitem__(self, n: _Node) -> float: ... def __iter__(self) -> Iterator[tuple[_Node, float]]: ... def __len__(self) -> int: ... diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index e4a18711363a..1f5018b7fba9 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -13,38 +13,38 @@ _ExtensionDtype: TypeAlias = Incomplete def to_pandas_adjacency( G: Graph[_Node], - nodelist: list[_Node] | None = ..., - dtype: numpy.dtype[Incomplete] | None = ..., - order: Literal["C", "F"] | None = ..., + nodelist: list[_Node] | None = None, + dtype: numpy.dtype[Incomplete] | None = None, + order: Literal["C", "F"] | None = None, multigraph_weight: Callable[[Iterable[float]], float] = ..., - weight: str = ..., - nonedge: float = ..., + weight: str = "weight", + nonedge: float = 0.0, ) -> _DataFrame: ... -def from_pandas_adjacency(df: _DataFrame, create_using: type[Graph[Incomplete]] = ...) -> Graph[Incomplete]: ... +def from_pandas_adjacency(df: _DataFrame, create_using: type[Graph[Incomplete]] = None) -> Graph[Incomplete]: ... def to_pandas_edgelist( G: Graph[_Node], - source: str | int = ..., - target: str | int = ..., - nodelist: list[_Node] | None = ..., - dtype: _ExtensionDtype | None = ..., - edge_key: str | int | None = ..., + source: str | int = "source", + target: str | int = "target", + nodelist: list[_Node] | None = None, + dtype: _ExtensionDtype | None = None, + edge_key: str | int | None = None, ) -> _DataFrame: ... def from_pandas_edgelist( df: _DataFrame, - source: str | int = ..., - target: str | int = ..., - edge_attr: str | int | Iterable[str | int] | Literal[True] | None = ..., - create_using: type[Graph[Incomplete]] = ..., + source: str | int = "source", + target: str | int = "target", + edge_attr: str | int | Iterable[str | int] | Literal[True] | None = None, + create_using: type[Graph[Incomplete]] = None, ) -> Graph[Incomplete]: ... def to_numpy_array( G: Graph[_Node], - nodelist: list[_Node] | None = ..., - dtype: numpy.dtype[Incomplete] | None = ..., - order: Literal["C", "F"] | None = ..., + nodelist: list[_Node] | None = None, + dtype: numpy.dtype[Incomplete] | None = None, + order: Literal["C", "F"] | None = None, multigraph_weight: Callable[[Iterable[float]], float] = ..., - weight: str = ..., - nonedge: float = ..., + weight: str = "weight", + nonedge: float = 0.0, ) -> numpy.ndarray[Incomplete, numpy.dtype[Incomplete]]: ... def from_numpy_array( - A: numpy.ndarray[Incomplete, Incomplete], parallel_edges: bool = ..., create_using: type[Graph[Incomplete]] = ... + A: numpy.ndarray[Incomplete, Incomplete], parallel_edges: bool = False, create_using: type[Graph[Incomplete]] = None ) -> Graph[Incomplete]: ... diff --git a/stubs/networkx/networkx/drawing/nx_agraph.pyi b/stubs/networkx/networkx/drawing/nx_agraph.pyi index aeddf5ce5322..60d1041bb090 100644 --- a/stubs/networkx/networkx/drawing/nx_agraph.pyi +++ b/stubs/networkx/networkx/drawing/nx_agraph.pyi @@ -11,19 +11,21 @@ from networkx.classes.graph import Graph _AGraph: TypeAlias = Incomplete _T = TypeVar("_T") -def from_agraph(A, create_using: Incomplete | None = ...) -> Graph[Incomplete]: ... +def from_agraph(A, create_using: Incomplete | None = None) -> Graph[Incomplete]: ... def to_agraph(N: Graph[Hashable]) -> _AGraph: ... def write_dot(G: Graph[Hashable], path: str | TextIOBase) -> None: ... def read_dot(path: str | TextIOBase) -> Graph[Incomplete]: ... -def graphviz_layout(G: Graph[_T], prog: str = ..., root: str | None = ..., args: str = ...) -> dict[_T, tuple[float, float]]: ... +def graphviz_layout( + G: Graph[_T], prog: str = "neato", root: str | None = None, args: str = "" +) -> dict[_T, tuple[float, float]]: ... pygraphviz_layout = graphviz_layout def view_pygraphviz( G: Graph[_T], - edgelabel: str | Callable[[_T], str] | None = ..., - prog: str = ..., - args: str = ..., - suffix: str = ..., - path: str | None = ..., + edgelabel: str | Callable[[_T], str] | None = None, + prog: str = "dot", + args: str = "", + suffix: str = "", + path: str | None = None, ): ... diff --git a/stubs/networkx/networkx/relabel.pyi b/stubs/networkx/networkx/relabel.pyi index fe73b83e31a2..668e7fc084e3 100644 --- a/stubs/networkx/networkx/relabel.pyi +++ b/stubs/networkx/networkx/relabel.pyi @@ -8,10 +8,10 @@ from networkx.classes.graph import Graph _X = TypeVar("_X") _Y = TypeVar("_Y") -def relabel_nodes(G: Graph[_X], mapping: Mapping[_X, _Y], copy: bool = ...) -> Graph[_X | _Y]: ... +def relabel_nodes(G: Graph[_X], mapping: Mapping[_X, _Y], copy: bool = True) -> Graph[_X | _Y]: ... def convert_node_labels_to_integers( G: Graph[Hashable], - first_label: int = ..., - ordering: Literal["default", "sorted", "increasing degree", "decreasing degree"] = ..., - label_attribute: Incomplete | None = ..., + first_label: int = 0, + ordering: Literal["default", "sorted", "increasing degree", "decreasing degree"] = "default", + label_attribute: Incomplete | None = None, ) -> Graph[int]: ... From db33680dcdb03658f6fb271aa850e107629b3776 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 23 Oct 2023 21:21:55 -0400 Subject: [PATCH 21/37] Fix invalid default `None` values (#7) --- stubs/networkx/networkx/algorithms/clique.pyi | 4 ++-- .../networkx/networkx/algorithms/shortest_paths/generic.pyi | 2 +- stubs/networkx/networkx/classes/function.pyi | 4 ++-- stubs/networkx/networkx/convert_matrix.pyi | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi index d7fc97d85f11..072f96f51de9 100644 --- a/stubs/networkx/networkx/algorithms/clique.pyi +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -5,9 +5,9 @@ from networkx.classes.graph import Graph, _Node def enumerate_all_cliques(G: Graph[_Node]) -> Iterable[list[_Node]]: ... def find_cliques(G: Graph[_Node], nodes: list[_Node] | None = None) -> Iterable[list[_Node]]: ... def find_cliques_recursive(G: Graph[_Node], nodes: list[_Node] | None = None) -> Iterable[list[_Node]]: ... -def make_max_clique_graph(G: Graph[_Node], create_using: type[Graph[_Node]] = None) -> Graph[_Node]: ... +def make_max_clique_graph(G: Graph[_Node], create_using: type[Graph[_Node]] | None = None) -> Graph[_Node]: ... def make_clique_bipartite( - G: Graph[_Node], fpos: None = None, create_using: type[Graph[_Node]] = None, name: None = None + G: Graph[_Node], fpos: None = None, create_using: type[Graph[_Node]] | None = None, name: None = None ) -> Graph[_Node]: ... def graph_clique_number(G: Graph[_Node], cliques: list[_Node] | None = None) -> int: ... def graph_number_of_cliques(G: Graph[_Node], cliques: list[_Node] | None = None) -> int: ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi index b9870fe0f080..00ba730ce020 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi @@ -22,7 +22,7 @@ def shortest_path_length( weight: Incomplete | None = None, method: str = "dijkstra", ): ... -def average_shortest_path_length(G, weight: Incomplete | None = None, method: str = None): ... +def average_shortest_path_length(G, weight: Incomplete | None = None, method: str | None = None): ... def all_shortest_paths( G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = None, method: str = "dijkstra" ) -> Iterable[list[_T]]: ... diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index 032f5ca9d861..591f153fce0d 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -75,12 +75,12 @@ def create_empty_copy(G, with_data: bool = True): ... # Can "Any scalar value" be enforced? @overload -def set_node_attributes(G: Graph[Hashable], values, name: str = None) -> None: ... +def set_node_attributes(G: Graph[Hashable], values, name: str) -> None: ... @overload def set_node_attributes(G: Graph[_T], values: dict[_T, dict[Incomplete, Incomplete]], name: None = None) -> None: ... def get_node_attributes(G: Graph[_T], name: str) -> dict[_T, Incomplete]: ... @overload -def set_edge_attributes(G: Graph[_T], values: dict[tuple[_T, _T], Incomplete], name: str = None) -> None: ... +def set_edge_attributes(G: Graph[_T], values: dict[tuple[_T, _T], Incomplete], name: str) -> None: ... @overload def set_edge_attributes(G: Graph[Hashable], values, name: None = None) -> None: ... def get_edge_attributes(G: Graph[_T], name: str) -> dict[tuple[_T, _T], Incomplete]: ... diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index 1f5018b7fba9..14e24e3640b7 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -20,7 +20,7 @@ def to_pandas_adjacency( weight: str = "weight", nonedge: float = 0.0, ) -> _DataFrame: ... -def from_pandas_adjacency(df: _DataFrame, create_using: type[Graph[Incomplete]] = None) -> Graph[Incomplete]: ... +def from_pandas_adjacency(df: _DataFrame, create_using: type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... def to_pandas_edgelist( G: Graph[_Node], source: str | int = "source", @@ -34,7 +34,7 @@ def from_pandas_edgelist( source: str | int = "source", target: str | int = "target", edge_attr: str | int | Iterable[str | int] | Literal[True] | None = None, - create_using: type[Graph[Incomplete]] = None, + create_using: type[Graph[Incomplete]] | None = None, ) -> Graph[Incomplete]: ... def to_numpy_array( G: Graph[_Node], @@ -46,5 +46,5 @@ def to_numpy_array( nonedge: float = 0.0, ) -> numpy.ndarray[Incomplete, numpy.dtype[Incomplete]]: ... def from_numpy_array( - A: numpy.ndarray[Incomplete, Incomplete], parallel_edges: bool = False, create_using: type[Graph[Incomplete]] = None + A: numpy.ndarray[Incomplete, Incomplete], parallel_edges: bool = False, create_using: type[Graph[Incomplete]] | None = None ) -> Graph[Incomplete]: ... From 622890332ed510294b1c7e865734df8d298bc8e6 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 23 Oct 2023 21:23:36 -0400 Subject: [PATCH 22/37] Fixing all stubtest errors left (#8) * Fix invalid default `None` values * Fixing all stubtest errors left --------- Co-authored-by: Audrey Dutcher --- stubs/networkx/networkx/algorithms/clique.pyi | 5 +- stubs/networkx/networkx/algorithms/dag.pyi | 6 +- .../networkx/algorithms/operators/binary.pyi | 2 +- stubs/networkx/networkx/classes/digraph.pyi | 1 + stubs/networkx/networkx/classes/function.pyi | 3 +- .../networkx/networkx/classes/multigraph.pyi | 8 +++ .../networkx/networkx/classes/reportviews.pyi | 68 +++++++++++++++---- stubs/networkx/networkx/convert_matrix.pyi | 1 + stubs/networkx/networkx/drawing/nx_agraph.pyi | 1 + 9 files changed, 74 insertions(+), 21 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi index 072f96f51de9..95b6e1023065 100644 --- a/stubs/networkx/networkx/algorithms/clique.pyi +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -1,3 +1,4 @@ +from _typeshed import Unused from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -11,7 +12,9 @@ def make_clique_bipartite( ) -> Graph[_Node]: ... def graph_clique_number(G: Graph[_Node], cliques: list[_Node] | None = None) -> int: ... def graph_number_of_cliques(G: Graph[_Node], cliques: list[_Node] | None = None) -> int: ... -def node_clique_number(G: Graph[_Node], nodes: list[_Node] | None = None, cliques: list[list[_Node]] | None = None) -> int: ... +def node_clique_number( + G: Graph[_Node], nodes: list[_Node] | None = None, cliques: list[list[_Node]] | None = None, separate_nodes: Unused = False +) -> int: ... def number_of_cliques(G: Graph[_Node], nodes: list[_Node] | None = None, cliques: list[list[_Node]] | None = None) -> int: ... def cliques_containing_node( G: Graph[_Node], nodes: list[_Node] | None = None, cliques: list[list[_Node]] | None = None diff --git a/stubs/networkx/networkx/algorithms/dag.pyi b/stubs/networkx/networkx/algorithms/dag.pyi index e6427f6eb4b3..590244fa0d6f 100644 --- a/stubs/networkx/networkx/algorithms/dag.pyi +++ b/stubs/networkx/networkx/algorithms/dag.pyi @@ -12,9 +12,9 @@ def topological_sort(G) -> None: ... def lexicographical_topological_sort(G, key: Incomplete | None = None): ... def all_topological_sorts(G) -> None: ... def is_aperiodic(G): ... -def transitive_closure(G): ... +def transitive_closure(G, reflexive: bool = False): ... def transitive_reduction(G): ... -def antichains(G) -> None: ... -def dag_longest_path(G, weight: str = "weight", default_weight: int = 1): ... +def antichains(G, topo_order: Incomplete | None = None) -> None: ... +def dag_longest_path(G, weight: str = "weight", default_weight: int = 1, topo_order: Incomplete | None = None): ... def dag_longest_path_length(G, weight: str = "weight", default_weight: int = 1): ... def dag_to_branching(G): ... diff --git a/stubs/networkx/networkx/algorithms/operators/binary.pyi b/stubs/networkx/networkx/algorithms/operators/binary.pyi index 53bbe884fa6b..8944c3046a2f 100644 --- a/stubs/networkx/networkx/algorithms/operators/binary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/binary.pyi @@ -14,4 +14,4 @@ _Y = TypeVar("_Y", covariant=True) # TODO: This does not handle the cases when graphs of different types are passed which is allowed def compose(G: DiGraph[_X], H: DiGraph[_Y]) -> DiGraph[_X | _Y]: ... -def union(G: DiGraph[_X], H: DiGraph[_Y], rename: Incomplete = (), name: Incomplete | None = ...) -> DiGraph[_X | _Y]: ... +def union(G: DiGraph[_X], H: DiGraph[_Y], rename: Incomplete = ()) -> DiGraph[_X | _Y]: ... diff --git a/stubs/networkx/networkx/classes/digraph.pyi b/stubs/networkx/networkx/classes/digraph.pyi index ab333d888948..b229b020b44d 100644 --- a/stubs/networkx/networkx/classes/digraph.pyi +++ b/stubs/networkx/networkx/classes/digraph.pyi @@ -24,5 +24,6 @@ class DiGraph(Graph[_Node], Generic[_Node]): in_degree: InDegreeView[_Node] | InMultiDegreeView[_Node] # ugly hack to make MultiDiGraph work out_edges: OutEdgeView[_Node] out_degree: OutDegreeView[_Node] | OutMultiDegreeView[_Node] # ugly hack to make MultiDiGraph work + 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]: ... diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index 591f153fce0d..1bbeff4858cf 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -4,7 +4,7 @@ from typing import TypeVar, overload from typing_extensions import Literal from networkx.classes.graph import Graph -from networkx.classes.graphviews import subgraph_view as subgraph_view +from networkx.classes.graphviews import reverse_view as reverse_view, subgraph_view as subgraph_view __all__ = [ "nodes", @@ -68,7 +68,6 @@ def subgraph(G, nbunch): ... def induced_subgraph(G: Graph[_T], nbunch: _T | Iterable[_T] | None) -> Graph[_T]: ... def edge_subgraph(G, edges): ... def restricted_view(G, nodes, edges): ... -def reverse_view(digraph): ... def to_directed(graph): ... def to_undirected(graph): ... def create_empty_copy(G, with_data: bool = True): ... diff --git a/stubs/networkx/networkx/classes/multigraph.pyi b/stubs/networkx/networkx/classes/multigraph.pyi index 463efc09a509..fb1386c6a777 100644 --- a/stubs/networkx/networkx/classes/multigraph.pyi +++ b/stubs/networkx/networkx/classes/multigraph.pyi @@ -1,10 +1,18 @@ +from _typeshed import Incomplete from typing import Generic from networkx.classes.graph import Graph, _Node from networkx.classes.multidigraph import MultiDiGraph class MultiGraph(Graph[_Node], Generic[_Node]): + def __init__(self, incoming_graph_data: Incomplete | None = None, multigraph_input: bool | None = None, **attr) -> None: ... 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 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]: ... def to_directed(self, as_view: bool = False) -> MultiDiGraph[_Node]: ... def to_undirected(self, as_view: bool = False) -> MultiGraph[_Node]: ... diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index 00daca212ca7..25af4a229837 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -1,14 +1,14 @@ -from _typeshed import Incomplete -from collections.abc import Iterator +from _typeshed import Incomplete, Unused +from collections.abc import Iterator, Mapping, Set as AbstractSet from typing import Generic, TypeVar, overload -from typing_extensions import Literal +from typing_extensions import Literal, Self from networkx.classes.graph import Graph, _Edge, _NBunch, _Node _D = TypeVar("_D") _U = TypeVar("_U") -class NodeView(Generic[_Node]): +class NodeView(Mapping[_Node, _Node], AbstractSet[_Node]): def __init__(self, graph: Graph[_Node]) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_Node]: ... @@ -43,31 +43,37 @@ class InMultiDegreeView(DiDegreeView[_Node], Generic[_Node]): ... class OutMultiDegreeView(DiDegreeView[_Node], Generic[_Node]): ... class OutEdgeDataView(Generic[_Node, _D]): + def __init__(self, viewer, nbunch: _NBunch[_Node] = None, data: bool = False, default: Incomplete | None = None) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_D]: ... def __contains__(self, e: _Edge[_Node]) -> bool: ... class EdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): ... class InEdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): ... -class OutMultiEdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): ... + +class OutMultiEdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): + def __init__( + self, viewer, nbunch: _NBunch[_Node] = None, data: bool = False, keys: bool = False, default: Incomplete | None = None + ) -> None: ... + class MultiEdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): ... class InMultiEdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): ... -class OutEdgeView(Generic[_Node]): - def __init__(self, graph: Graph[_Node]) -> None: ... +class OutEdgeView(AbstractSet[Incomplete], Mapping[Incomplete, Incomplete], Generic[_Node]): + def __init__(self, G: Graph[_Node]) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[tuple[_Node, _Node]]: ... - def __contains__(self, e: _Edge[_Node]) -> bool: ... + def __contains__(self, e: _Edge[_Node]) -> bool: ... # type: ignore[override] def __getitem__(self, e: _Edge[_Node]) -> dict[str, Incomplete]: ... @overload - def __call__(self, nbunch: _NBunch[_Node] = None, data: Literal[False] = False, default=None) -> OutEdgeView[_Node]: ... + def __call__(self, nbunch: None = None, data: Literal[False] = False, default: Unused = None) -> Self: ... @overload def __call__( - self, nbunch: _NBunch[_Node], data: Literal[True], default=None + self, nbunch: _NBunch[_Node], data: Literal[True], default: None = None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... @overload def __call__( - self, nbunch: _NBunch[_Node] = None, *, data: Literal[True], default=None + self, nbunch: _NBunch[_Node] = None, *, data: Literal[True], default: None = None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... @overload def __call__( @@ -78,10 +84,10 @@ class OutEdgeView(Generic[_Node]): self, nbunch: _NBunch[_Node] = None, *, data: str, default: _U | None = None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... @overload - def data(self, data: Literal[False], default=None, nbunch: _NBunch[_Node] = None) -> OutEdgeView[_Node]: ... + def data(self, data: Literal[False], default: Unused = None, nbunch: None = None) -> Self: ... @overload def data( - self, data: Literal[True] = True, default=None, nbunch: _NBunch[_Node] = None + self, data: Literal[True] = True, default: None = None, nbunch: _NBunch[_Node] = None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... @overload def data( @@ -90,6 +96,40 @@ class OutEdgeView(Generic[_Node]): class EdgeView(OutEdgeView[_Node], Generic[_Node]): ... class InEdgeView(OutEdgeView[_Node], Generic[_Node]): ... -class OutMultiEdgeView(OutEdgeView[_Node], Generic[_Node]): ... + +class OutMultiEdgeView(OutEdgeView[_Node], Generic[_Node]): + @overload # type: ignore[override] # Has an additional `keys` keyword argument + def __call__( + self, nbunch: None = None, data: Literal[False] = False, *, keys: Literal[True], default: Unused = None + ) -> Self: ... + @overload + def __call__(self, nbunch: None, data: Literal[False], keys: Literal[True], default: Unused = None) -> Self: ... + @overload + def __call__( + self, nbunch: _NBunch[_Node], data: Literal[True], keys: bool = False, default: None = None + ) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... + @overload + def __call__( + self, nbunch: _NBunch[_Node] = None, *, data: Literal[True], keys: bool = False, default: None = None + ) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... + @overload + def __call__( + self, nbunch: _NBunch[_Node], data: str, keys: bool = False, default: _U | None = None + ) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... + @overload + def __call__( + self, nbunch: _NBunch[_Node] = None, *, data: str, keys: bool = False, default: _U | None = None + ) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... + @overload # type: ignore[override] # Has an additional `keys` keyword argument + def data(self, data: Literal[False], keys: Literal[False] = False, default: Unused = None, nbunch: None = None) -> Self: ... + @overload + def data( + self, data: Literal[True] = True, keys: bool = False, default: None = None, nbunch: _NBunch[_Node] = None + ) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... + @overload + def data( + self, data: str, keys: bool = False, default: _U | None = None, nbunch: _NBunch[_Node] = None + ) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... + class MultiEdgeView(OutMultiEdgeView[_Node], Generic[_Node]): ... class InMultiEdgeView(OutMultiEdgeView[_Node], Generic[_Node]): ... diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index 14e24e3640b7..8eb7621b250d 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -35,6 +35,7 @@ def from_pandas_edgelist( target: str | int = "target", edge_attr: str | int | Iterable[str | int] | Literal[True] | None = None, create_using: type[Graph[Incomplete]] | None = None, + edge_key: str | int | None = None, ) -> Graph[Incomplete]: ... def to_numpy_array( G: Graph[_Node], diff --git a/stubs/networkx/networkx/drawing/nx_agraph.pyi b/stubs/networkx/networkx/drawing/nx_agraph.pyi index 60d1041bb090..9ed44ba23a77 100644 --- a/stubs/networkx/networkx/drawing/nx_agraph.pyi +++ b/stubs/networkx/networkx/drawing/nx_agraph.pyi @@ -28,4 +28,5 @@ def view_pygraphviz( args: str = "", suffix: str = "", path: str | None = None, + show: bool = True, ): ... From 6aa2fce6de00c9837be3d1f75df235c52f5f1f28 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 23 Oct 2023 21:24:41 -0400 Subject: [PATCH 23/37] fix pytype issues (#9) Co-authored-by: Audrey Dutcher --- stubs/networkx/networkx/__init__.pyi | 25 ++++++++++--------- .../networkx/networkx/algorithms/chordal.pyi | 4 +-- .../networkx/algorithms/community/quality.pyi | 2 +- .../networkx/algorithms/planarity.pyi | 4 +-- .../networkx/algorithms/tree/coding.pyi | 4 +-- stubs/networkx/networkx/classes/__init__.pyi | 3 +-- .../networkx/networkx/classes/reportviews.pyi | 1 + 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/stubs/networkx/networkx/__init__.pyi b/stubs/networkx/networkx/__init__.pyi index 45fb09dc3bdd..2884bfc1a481 100644 --- a/stubs/networkx/networkx/__init__.pyi +++ b/stubs/networkx/networkx/__init__.pyi @@ -1,15 +1,3 @@ -from networkx import ( - algorithms as algorithms, - classes as classes, - convert as convert, - convert_matrix as convert_matrix, - drawing as drawing, - generators as generators, - linalg as linalg, - readwrite as readwrite, - relabel as relabel, - utils as utils, -) from networkx.algorithms import * from networkx.classes import * from networkx.classes import filters as filters @@ -21,3 +9,16 @@ from networkx.generators import * from networkx.linalg import * from networkx.readwrite import * from networkx.relabel import * + +from . import ( + algorithms as algorithms, + classes as classes, + convert as convert, + convert_matrix as convert_matrix, + drawing as drawing, + generators as generators, + linalg as linalg, + readwrite as readwrite, + relabel as relabel, + utils as utils, +) diff --git a/stubs/networkx/networkx/algorithms/chordal.pyi b/stubs/networkx/networkx/algorithms/chordal.pyi index ba71d048d620..010fe960c7c7 100644 --- a/stubs/networkx/networkx/algorithms/chordal.pyi +++ b/stubs/networkx/networkx/algorithms/chordal.pyi @@ -1,9 +1,9 @@ from collections.abc import Hashable, Iterable -import networkx as nx from networkx.classes.graph import Graph, _Node +from networkx.exception import NetworkXException -class NetworkXTreewidthBoundExceeded(nx.NetworkXException): ... +class NetworkXTreewidthBoundExceeded(NetworkXException): ... def is_chordal(G: Graph[Hashable]) -> bool: ... def find_induced_nodes(G: Graph[_Node], s: _Node, t: _Node, treewidth_bound: int = ...) -> set[_Node]: ... diff --git a/stubs/networkx/networkx/algorithms/community/quality.pyi b/stubs/networkx/networkx/algorithms/community/quality.pyi index d8027bb2258e..a402d0646a59 100644 --- a/stubs/networkx/networkx/algorithms/community/quality.pyi +++ b/stubs/networkx/networkx/algorithms/community/quality.pyi @@ -1,4 +1,4 @@ -from networkx import NetworkXError +from networkx.exception import NetworkXError __all__ = ["modularity", "partition_quality"] diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index c1f2f0373625..dd5df7d7a905 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -2,7 +2,7 @@ from _typeshed import Incomplete from collections.abc import Iterable from typing import Generic, TypeVar -import networkx as nx +from networkx.classes.digraph import DiGraph __all__ = ["check_planarity", "is_planar", "PlanarEmbedding"] @@ -59,7 +59,7 @@ class LRPlanarity: def sign(self, e): ... def sign_recursive(self, e): ... -class PlanarEmbedding(Generic[_N], nx.DiGraph[_N]): +class PlanarEmbedding(Generic[_N], DiGraph[_N]): def get_data(self) -> dict[_N, list[_N]]: ... def set_data(self, data: dict[_N, list[_N]]) -> None: ... def neighbors_cw_order(self, v: _N) -> Iterable[_N]: ... diff --git a/stubs/networkx/networkx/algorithms/tree/coding.pyi b/stubs/networkx/networkx/algorithms/tree/coding.pyi index 592518f98166..88cfc57bd606 100644 --- a/stubs/networkx/networkx/algorithms/tree/coding.pyi +++ b/stubs/networkx/networkx/algorithms/tree/coding.pyi @@ -1,6 +1,6 @@ -import networkx as nx +from networkx.exception import NetworkXException -class NotATree(nx.NetworkXException): ... +class NotATree(NetworkXException): ... def to_nested_tuple(T, root, canonical_form: bool = False): ... def from_nested_tuple(sequence, sensible_relabeling: bool = False): ... diff --git a/stubs/networkx/networkx/classes/__init__.pyi b/stubs/networkx/networkx/classes/__init__.pyi index 2e2f6c0eca62..1289c8a1cd55 100644 --- a/stubs/networkx/networkx/classes/__init__.pyi +++ b/stubs/networkx/networkx/classes/__init__.pyi @@ -1,11 +1,10 @@ -from networkx.classes import ( +from . import ( backends as backends, coreviews as coreviews, filters as filters, graphviews as graphviews, reportviews as reportviews, ) - from .digraph import DiGraph as DiGraph from .function import * from .graph import Graph as Graph diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index 25af4a229837..c8dada1cc636 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -2,6 +2,7 @@ from _typeshed import Incomplete, Unused from collections.abc import Iterator, Mapping, Set as AbstractSet from typing import Generic, TypeVar, overload from typing_extensions import Literal, Self +from collections.abc import Mapping, Set as AbstractSet from networkx.classes.graph import Graph, _Edge, _NBunch, _Node From 284482b2b9477fed3971d295f69b60db3771664a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 01:25:23 +0000 Subject: [PATCH 24/37] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/networkx/networkx/classes/reportviews.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index c8dada1cc636..25af4a229837 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -2,7 +2,6 @@ from _typeshed import Incomplete, Unused from collections.abc import Iterator, Mapping, Set as AbstractSet from typing import Generic, TypeVar, overload from typing_extensions import Literal, Self -from collections.abc import Mapping, Set as AbstractSet from networkx.classes.graph import Graph, _Edge, _NBunch, _Node From 391234e3c2db27b00d8fb15635594bc15f3a07d6 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 23 Oct 2023 18:41:36 -0700 Subject: [PATCH 25/37] Fix reportviews metaclasses --- stubs/networkx/networkx/classes/reportviews.pyi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index 25af4a229837..d29587661134 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete, Unused +from abc import ABCMeta from collections.abc import Iterator, Mapping, Set as AbstractSet from typing import Generic, TypeVar, overload from typing_extensions import Literal, Self @@ -20,11 +21,11 @@ class NodeView(Mapping[_Node, _Node], AbstractSet[_Node]): def __call__(self, data: Literal[True] | str, default: Incomplete = None) -> NodeDataView[_Node]: ... def data(self, data: bool | str = True, default: Incomplete = None) -> NodeDataView[_Node]: ... -class NodeDataView(Generic[_Node]): +class NodeDataView(Generic[_Node], metaclass=ABCMeta): def __init__(self, nodedict: dict[str, Incomplete], data: bool | str = False, default: Incomplete = None) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[tuple[_Node, Incomplete]]: ... - def __contains__(self, n: _Node) -> bool: ... + def __contains__(self, n: object) -> bool: ... def __getitem__(self, n: _Node): ... class DiDegreeView(Generic[_Node]): From 73c4bb650b811a783e6cc0c9b4b863c80e50f4cc Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 23 Oct 2023 18:44:48 -0700 Subject: [PATCH 26/37] Improve fidelity of interfaces in convert_matrix --- stubs/networkx/networkx/convert_matrix.pyi | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index 8eb7621b250d..8e1bf2cb6dc3 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete from collections.abc import Callable, Iterable +from typing import TypeVar, overload from typing_extensions import Literal, TypeAlias import numpy @@ -10,6 +11,7 @@ from networkx.classes.graph import Graph, _Node _DataFrame: TypeAlias = Incomplete # from pandas.core.dtypes.base import ExtensionDtype _ExtensionDtype: TypeAlias = Incomplete +_G = TypeVar("_G") def to_pandas_adjacency( G: Graph[_Node], @@ -20,7 +22,10 @@ def to_pandas_adjacency( weight: str = "weight", nonedge: float = 0.0, ) -> _DataFrame: ... -def from_pandas_adjacency(df: _DataFrame, create_using: type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... +@overload +def from_pandas_adjacency(df: _DataFrame, create_using: type[_G]) -> _G: ... +@overload +def from_pandas_adjacency(df: _DataFrame, create_using: None = None) -> Graph[Incomplete]: ... def to_pandas_edgelist( G: Graph[_Node], source: str | int = "source", @@ -29,13 +34,24 @@ def to_pandas_edgelist( dtype: _ExtensionDtype | None = None, edge_key: str | int | None = None, ) -> _DataFrame: ... +@overload def from_pandas_edgelist( df: _DataFrame, source: str | int = "source", target: str | int = "target", edge_attr: str | int | Iterable[str | int] | Literal[True] | None = None, - create_using: type[Graph[Incomplete]] | None = None, - edge_key: str | int | None = None, + *, + create_using: type[_G], + edge_key: str | None = None, +) -> _G: ... +@overload +def from_pandas_edgelist( + df: _DataFrame, + source: str | int = "source", + target: str | int = "target", + edge_attr: str | int | Iterable[str | int] | Literal[True] | None = None, + create_using: None = None, + edge_key: str | None = None, ) -> Graph[Incomplete]: ... def to_numpy_array( G: Graph[_Node], @@ -46,6 +62,9 @@ def to_numpy_array( weight: str = "weight", nonedge: float = 0.0, ) -> numpy.ndarray[Incomplete, numpy.dtype[Incomplete]]: ... +@overload def from_numpy_array( - A: numpy.ndarray[Incomplete, Incomplete], parallel_edges: bool = False, create_using: type[Graph[Incomplete]] | None = None + A: numpy.ndarray[Incomplete, Incomplete], parallel_edges: bool = False, create_using: None = ... ) -> Graph[Incomplete]: ... +@overload +def from_numpy_array(A: numpy.ndarray[Incomplete, Incomplete], parallel_edges: bool = False, *, create_using: type[_G]) -> _G: ... From e80965c1504fd8b0d2f1b2a4a1a89efca6f1c968 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 23 Oct 2023 19:05:17 -0700 Subject: [PATCH 27/37] Update stubs/networkx/networkx/convert_matrix.pyi Co-authored-by: Avasam --- stubs/networkx/networkx/convert_matrix.pyi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index 8e1bf2cb6dc3..b457a01e78ba 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -64,7 +64,9 @@ def to_numpy_array( ) -> numpy.ndarray[Incomplete, numpy.dtype[Incomplete]]: ... @overload def from_numpy_array( - A: numpy.ndarray[Incomplete, Incomplete], parallel_edges: bool = False, create_using: None = ... + A: numpy.ndarray[Incomplete, Incomplete], parallel_edges: bool = False, create_using: None = None ) -> Graph[Incomplete]: ... @overload def from_numpy_array(A: numpy.ndarray[Incomplete, Incomplete], parallel_edges: bool = False, *, create_using: type[_G]) -> _G: ... +@overload +def from_numpy_array(A: numpy.ndarray[Incomplete, Incomplete], parallel_edges: bool, create_using: type[_G]) -> _G: ... From cfa3ff6e752912e13ab59a0e2dcc5d7e4524240f Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 23 Oct 2023 19:08:30 -0700 Subject: [PATCH 28/37] Improve two create_using cases --- .../networkx/networkx/classes/graphviews.pyi | 19 ++++++++++++++++++- .../networkx/generators/random_clustered.pyi | 15 +++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/stubs/networkx/networkx/classes/graphviews.pyi b/stubs/networkx/networkx/classes/graphviews.pyi index 0774936b89c7..314dc69a758f 100644 --- a/stubs/networkx/networkx/classes/graphviews.pyi +++ b/stubs/networkx/networkx/classes/graphviews.pyi @@ -1,5 +1,22 @@ from _typeshed import Incomplete +from typing import Any, TypeVar, overload -def generic_graph_view(G, create_using: Incomplete | None = None): ... +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import Graph, _Node +from networkx.classes.multidigraph import MultiDiGraph +from networkx.classes.multigraph import MultiGraph + +_G = TypeVar("_G", bound=Graph[Any]) + +@overload +def generic_graph_view(G: _G, create_using: None = None) -> _G: ... +@overload +def generic_graph_view(G: Graph[_Node], create_using: type[MultiDiGraph[Incomplete]]) -> MultiDiGraph[_Node]: ... +@overload +def generic_graph_view(G: Graph[_Node], create_using: type[DiGraph[Incomplete]]) -> DiGraph[_Node]: ... +@overload +def generic_graph_view(G: Graph[_Node], create_using: type[MultiGraph[Incomplete]]) -> MultiGraph[_Node]: ... +@overload +def generic_graph_view(G: Graph[_Node], create_using: type[Graph[Incomplete]]) -> Graph[_Node]: ... def subgraph_view(G, filter_node=..., filter_edge=...): ... def reverse_view(G): ... diff --git a/stubs/networkx/networkx/generators/random_clustered.pyi b/stubs/networkx/networkx/generators/random_clustered.pyi index 3aaaa7445e16..6ea6b95997d5 100644 --- a/stubs/networkx/networkx/generators/random_clustered.pyi +++ b/stubs/networkx/networkx/generators/random_clustered.pyi @@ -1,3 +1,14 @@ -from _typeshed import Incomplete +from typing import Any, TypeVar, overload -def random_clustered_graph(joint_degree_sequence, create_using: Incomplete | None = None, seed: Incomplete | None = None): ... +from networkx import MultiGraph + +_G = TypeVar("_G", bound=MultiGraph[int]) + +@overload +def random_clustered_graph( + joint_degree_sequence: list[tuple[int, int]], create_using: None = None, seed: int | tuple[Any, ...] | None = None +) -> MultiGraph[int]: ... +@overload +def random_clustered_graph( + joint_degree_sequence: list[tuple[int, int]], create_using: type[_G], seed: int | tuple[Any, ...] | None = None +) -> _G: ... From c5cefbbc6dd0b6f3e6591a9f933554524cc8c327 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 23 Oct 2023 19:31:07 -0700 Subject: [PATCH 29/37] Improve fidelity of graphviews --- .../networkx/networkx/classes/graphviews.pyi | 29 +++++++++++++++---- .../networkx/networkx/classes/multigraph.pyi | 3 ++ stubs/networkx/networkx/relabel.pyi | 12 +++++++- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/stubs/networkx/networkx/classes/graphviews.pyi b/stubs/networkx/networkx/classes/graphviews.pyi index 314dc69a758f..c26cb8ab41ec 100644 --- a/stubs/networkx/networkx/classes/graphviews.pyi +++ b/stubs/networkx/networkx/classes/graphviews.pyi @@ -1,12 +1,14 @@ from _typeshed import Incomplete -from typing import Any, TypeVar, overload +from collections.abc import Callable, Hashable +from typing import TypeVar, overload from networkx.classes.digraph import DiGraph -from networkx.classes.graph import Graph, _Node +from networkx.classes.graph import Graph, _Edge, _Node from networkx.classes.multidigraph import MultiDiGraph -from networkx.classes.multigraph import MultiGraph +from networkx.classes.multigraph import MultiGraph, _MultiEdge -_G = TypeVar("_G", bound=Graph[Any]) +_G = TypeVar("_G", bound=Graph[Hashable]) +_D = TypeVar("_D", bound=DiGraph[Hashable]) @overload def generic_graph_view(G: _G, create_using: None = None) -> _G: ... @@ -18,5 +20,20 @@ def generic_graph_view(G: Graph[_Node], create_using: type[DiGraph[Incomplete]]) def generic_graph_view(G: Graph[_Node], create_using: type[MultiGraph[Incomplete]]) -> MultiGraph[_Node]: ... @overload def generic_graph_view(G: Graph[_Node], create_using: type[Graph[Incomplete]]) -> Graph[_Node]: ... -def subgraph_view(G, filter_node=..., filter_edge=...): ... -def reverse_view(G): ... +@overload +def subgraph_view( + G: MultiDiGraph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_MultiEdge], bool] = ... +) -> MultiDiGraph[_Node]: ... +@overload +def subgraph_view( + G: MultiGraph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_MultiEdge], bool] = ... +) -> MultiGraph[_Node]: ... +@overload +def subgraph_view( + G: DiGraph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_Edge], bool] = ... +) -> DiGraph[_Node]: ... +@overload +def subgraph_view( + G: Graph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_Edge], bool] = ... +) -> Graph[_Node]: ... +def reverse_view(G: _D) -> _D: ... diff --git a/stubs/networkx/networkx/classes/multigraph.pyi b/stubs/networkx/networkx/classes/multigraph.pyi index fb1386c6a777..ac96f7fd6e90 100644 --- a/stubs/networkx/networkx/classes/multigraph.pyi +++ b/stubs/networkx/networkx/classes/multigraph.pyi @@ -1,9 +1,12 @@ from _typeshed import Incomplete from typing import Generic +from typing_extensions import TypeAlias from networkx.classes.graph import Graph, _Node from networkx.classes.multidigraph import MultiDiGraph +_MultiEdge: TypeAlias = tuple[_Node, _Node, int] # noqa: Y047 + class MultiGraph(Graph[_Node], Generic[_Node]): def __init__(self, incoming_graph_data: Incomplete | None = None, multigraph_input: bool | None = None, **attr) -> None: ... def new_edge_key(self, u: _Node, v: _Node) -> int: ... diff --git a/stubs/networkx/networkx/relabel.pyi b/stubs/networkx/networkx/relabel.pyi index 668e7fc084e3..0556bae8924f 100644 --- a/stubs/networkx/networkx/relabel.pyi +++ b/stubs/networkx/networkx/relabel.pyi @@ -1,13 +1,23 @@ from _typeshed import Incomplete from collections.abc import Hashable, Mapping -from typing import TypeVar +from typing import TypeVar, overload from typing_extensions import Literal +from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph +from networkx.classes.multidigraph import MultiDiGraph +from networkx.classes.multigraph import MultiGraph _X = TypeVar("_X") _Y = TypeVar("_Y") +@overload +def relabel_nodes(G: MultiDiGraph[_X], mapping: Mapping[_X, _Y], copy: bool = True) -> MultiDiGraph[_X | _Y]: ... +@overload +def relabel_nodes(G: DiGraph[_X], mapping: Mapping[_X, _Y], copy: bool = True) -> DiGraph[_X | _Y]: ... +@overload +def relabel_nodes(G: MultiGraph[_X], mapping: Mapping[_X, _Y], copy: bool = True) -> MultiGraph[_X | _Y]: ... +@overload def relabel_nodes(G: Graph[_X], mapping: Mapping[_X, _Y], copy: bool = True) -> Graph[_X | _Y]: ... def convert_node_labels_to_integers( G: Graph[Hashable], From 97822cbd5e8b243fea7e40b8433357a611baa415 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Mon, 23 Oct 2023 19:37:37 -0700 Subject: [PATCH 30/37] Specify generic arguments for _Edge --- stubs/networkx/networkx/classes/graphviews.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stubs/networkx/networkx/classes/graphviews.pyi b/stubs/networkx/networkx/classes/graphviews.pyi index c26cb8ab41ec..063a3f5f7c34 100644 --- a/stubs/networkx/networkx/classes/graphviews.pyi +++ b/stubs/networkx/networkx/classes/graphviews.pyi @@ -22,18 +22,18 @@ def generic_graph_view(G: Graph[_Node], create_using: type[MultiGraph[Incomplete def generic_graph_view(G: Graph[_Node], create_using: type[Graph[Incomplete]]) -> Graph[_Node]: ... @overload def subgraph_view( - G: MultiDiGraph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_MultiEdge], bool] = ... + G: MultiDiGraph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_MultiEdge[_Node]], bool] = ... ) -> MultiDiGraph[_Node]: ... @overload def subgraph_view( - G: MultiGraph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_MultiEdge], bool] = ... + G: MultiGraph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_MultiEdge[_Node]], bool] = ... ) -> MultiGraph[_Node]: ... @overload def subgraph_view( - G: DiGraph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_Edge], bool] = ... + G: DiGraph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_Edge[_Node]], bool] = ... ) -> DiGraph[_Node]: ... @overload def subgraph_view( - G: Graph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_Edge], bool] = ... + G: Graph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_Edge[_Node]], bool] = ... ) -> Graph[_Node]: ... def reverse_view(G: _D) -> _D: ... From cdc358e86d71d139fd5d31c579b4404b58670423 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 28 Nov 2023 18:29:21 -0500 Subject: [PATCH 31/37] Batch apply simple suggestions from code review --- .../approximation/traveling_salesman.pyi | 5 +- .../networkx/networkx/algorithms/boundary.pyi | 24 +++++----- .../networkx/networkx/algorithms/bridges.pyi | 6 +-- .../algorithms/centrality/eigenvector.pyi | 2 +- stubs/networkx/networkx/algorithms/chains.pyi | 2 +- .../networkx/networkx/algorithms/chordal.pyi | 4 +- stubs/networkx/networkx/algorithms/clique.pyi | 43 ++++++++++++----- .../networkx/algorithms/community/louvain.pyi | 4 +- .../algorithms/community/modularity_max.pyi | 4 +- .../networkx/algorithms/community/quality.pyi | 2 +- .../components/strongly_connected.pyi | 8 ++-- .../components/weakly_connected.pyi | 2 +- .../connectivity/edge_augmentation.pyi | 2 +- .../networkx/algorithms/flow/preflowpush.pyi | 2 +- .../networkx/algorithms/planarity.pyi | 6 +-- .../networkx/networkx/algorithms/richclub.pyi | 2 +- .../algorithms/shortest_paths/generic.pyi | 2 +- .../networkx/algorithms/simple_paths.pyi | 2 +- .../traversal/depth_first_search.pyi | 2 +- .../networkx/algorithms/tree/branchings.pyi | 21 ++++---- .../networkx/networkx/algorithms/tree/mst.pyi | 13 ++--- stubs/networkx/networkx/classes/function.pyi | 28 +++++------ stubs/networkx/networkx/classes/graph.pyi | 8 ++-- .../networkx/networkx/classes/graphviews.pyi | 8 ++-- .../networkx/networkx/classes/reportviews.pyi | 4 +- stubs/networkx/networkx/convert_matrix.pyi | 27 +++++++---- stubs/networkx/networkx/drawing/layout.pyi | 24 +++++----- stubs/networkx/networkx/drawing/nx_agraph.pyi | 9 ++-- stubs/networkx/networkx/drawing/nx_pylab.pyi | 4 +- .../networkx/networkx/generators/classic.pyi | 2 +- .../networkx/networkx/generators/directed.pyi | 2 +- stubs/networkx/networkx/generators/ego.pyi | 2 +- .../networkx/generators/geometric.pyi | 11 +++-- .../networkx/generators/random_clustered.pyi | 6 +-- .../networkx/generators/random_graphs.pyi | 4 +- stubs/networkx/networkx/readwrite/gml.pyi | 14 +++--- stubs/networkx/networkx/readwrite/graphml.pyi | 8 ++-- stubs/networkx/networkx/readwrite/text.pyi | 48 +++++++++---------- 38 files changed, 193 insertions(+), 174 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi index 729fe837eca4..1959f98f5ca4 100644 --- a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi @@ -11,7 +11,8 @@ def simulated_annealing_tsp( init_cycle, weight: str = "weight", source: Incomplete | None = None, - temp: int = 100, + # docstring says int, but it can be a float and does become a float mid-equation if alpha is also a float + temp: float = 100, move: str = "1-1", max_iterations: int = 10, N_inner: int = 100, @@ -23,7 +24,7 @@ def threshold_accepting_tsp( init_cycle, weight: str = "weight", source: Incomplete | None = None, - threshold: int = 1, + threshold: float = 1, move: str = "1-1", max_iterations: int = 10, N_inner: int = 100, diff --git a/stubs/networkx/networkx/algorithms/boundary.pyi b/stubs/networkx/networkx/algorithms/boundary.pyi index cc4785675777..6bc0fb158b2b 100644 --- a/stubs/networkx/networkx/algorithms/boundary.pyi +++ b/stubs/networkx/networkx/algorithms/boundary.pyi @@ -16,7 +16,7 @@ def edge_boundary( data: Literal[False] = False, keys: Literal[False] = False, default=None, -) -> Iterable[tuple[_T, _T]]: ... +) -> Generator[tuple[_T, _T], None, None]: ... @overload def edge_boundary( G: Graph[_T], @@ -25,7 +25,7 @@ def edge_boundary( data: Literal[True], keys: Literal[False] = False, default=None, -) -> Iterable[tuple[_T, _T, dict[str, Incomplete]]]: ... +) -> Generator[tuple[_T, _T, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( G: Graph[_T], @@ -35,7 +35,7 @@ def edge_boundary( data: Literal[True], keys: Literal[False] = False, default=None, -) -> Iterable[tuple[_T, _T, dict[str, Incomplete]]]: ... +) -> Generator[tuple[_T, _T, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( G: Graph[_T], @@ -44,7 +44,7 @@ def edge_boundary( data: str, keys: Literal[False] = False, default: _U | None = None, -) -> Iterable[tuple[_T, _T, dict[str, _U]]]: ... +) -> Generator[tuple[_T, _T, dict[str, _U]], None, None]: ... @overload def edge_boundary( G: Graph[_T], @@ -54,11 +54,11 @@ def edge_boundary( data: str, keys: Literal[False] = False, default: _U | None = None, -) -> Iterable[tuple[_T, _T, dict[str, _U]]]: ... +) -> Generator[tuple[_T, _T, dict[str, _U]], None, None]: ... @overload def edge_boundary( G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None, data: Literal[False], keys: Literal[True], default=None -) -> Iterable[tuple[_T, _T, int]]: ... +) -> Generator[tuple[_T, _T, int], None, None]: ... @overload def edge_boundary( G: Graph[_T], @@ -68,11 +68,11 @@ def edge_boundary( *, keys: Literal[True], default=None, -) -> Iterable[tuple[_T, _T, int]]: ... +) -> Generator[tuple[_T, _T, int], None, None]: ... @overload def edge_boundary( G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None, data: Literal[True], keys: Literal[True], default=None -) -> Iterable[tuple[_T, _T, int, dict[str, Incomplete]]]: ... +) -> Generator[tuple[_T, _T, int, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( G: Graph[_T], @@ -82,11 +82,11 @@ def edge_boundary( data: Literal[True], keys: Literal[True], default=None, -) -> Iterable[tuple[_T, _T, int, dict[str, Incomplete]]]: ... +) -> Generator[tuple[_T, _T, int, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None, data: str, keys: Literal[True], default: _U | None = None -) -> Iterable[tuple[_T, _T, int, dict[str, _U]]]: ... +) -> Generator[tuple[_T, _T, int, dict[str, _U]], None, None]: ... @overload def edge_boundary( G: Graph[_T], @@ -96,5 +96,5 @@ def edge_boundary( data: str, keys: Literal[True], default: _U | None = None, -) -> Iterable[tuple[_T, _T, int, dict[str, _U]]]: ... -def node_boundary(G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None = None) -> Iterable[_T]: ... +) -> Generator[tuple[_T, _T, int, dict[str, _U]], None, None]: ... +def node_boundary(G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None = None) -> set[_T]: ... diff --git a/stubs/networkx/networkx/algorithms/bridges.pyi b/stubs/networkx/networkx/algorithms/bridges.pyi index 893cba294b25..36383103883f 100644 --- a/stubs/networkx/networkx/algorithms/bridges.pyi +++ b/stubs/networkx/networkx/algorithms/bridges.pyi @@ -5,13 +5,13 @@ from typing_extensions import Literal from networkx.classes.graph import Graph, _Node -def bridges(G: Graph[_Node], root: _Node | None = None) -> Iterable[_Node]: ... +def bridges(G: Graph[_Node], root: _Node | None = None) -> Generator[_Node, None, None]: ... def has_bridges(G: Graph[_Node], root: Incomplete | None = None) -> bool: ... @overload def local_bridges( G: Graph[_Node], with_span: Literal[False], weight: str | Callable[[_Node], float] | None = None -) -> Iterable[tuple[_Node, _Node]]: ... +) -> Generator[tuple[_Node, _Node], Node, Node]: ... @overload def local_bridges( G: Graph[_Node], with_span: Literal[True] = True, weight: str | Callable[[_Node], float] | None = None -) -> Iterable[tuple[_Node, _Node, int]]: ... +) -> Generator[tuple[_Node, _Node, int], Node, Node]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi index bed661c10ab4..4043738aa0e2 100644 --- a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi @@ -3,4 +3,4 @@ from _typeshed import Incomplete def eigenvector_centrality( G, max_iter: int = 100, tol: float = 1e-06, nstart: Incomplete | None = None, weight: Incomplete | None = None ): ... -def eigenvector_centrality_numpy(G, weight: Incomplete | None = None, max_iter: int = 50, tol: int = 0): ... +def eigenvector_centrality_numpy(G, weight: Incomplete | None = None, max_iter: int = 50, tol: float = 0): ... diff --git a/stubs/networkx/networkx/algorithms/chains.pyi b/stubs/networkx/networkx/algorithms/chains.pyi index f054e87db62c..9835abddfe4b 100644 --- a/stubs/networkx/networkx/algorithms/chains.pyi +++ b/stubs/networkx/networkx/algorithms/chains.pyi @@ -2,4 +2,4 @@ from collections.abc import Iterable from networkx.classes.graph import Graph, _Node -def chain_decomposition(G: Graph[_Node], root: _Node | None = None) -> Iterable[tuple[_Node, _Node]]: ... +def chain_decomposition(G: Graph[_Node], root: _Node | None = None) -> Generator[list[tuple[_Node, _Node]], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/chordal.pyi b/stubs/networkx/networkx/algorithms/chordal.pyi index 010fe960c7c7..287e6ce1f3dc 100644 --- a/stubs/networkx/networkx/algorithms/chordal.pyi +++ b/stubs/networkx/networkx/algorithms/chordal.pyi @@ -6,6 +6,6 @@ from networkx.exception import NetworkXException class NetworkXTreewidthBoundExceeded(NetworkXException): ... def is_chordal(G: Graph[Hashable]) -> bool: ... -def find_induced_nodes(G: Graph[_Node], s: _Node, t: _Node, treewidth_bound: int = ...) -> set[_Node]: ... -def chordal_graph_cliques(G: Graph[_Node]) -> Iterable[frozenset[_Node]]: ... +def find_induced_nodes(G: Graph[_Node], s: _Node, t: _Node, treewidth_bound: float = sys.maxsize) -> set[_Node]: ... +def chordal_graph_cliques(G: Graph[_Node]) -> Generator[frozenset[_Node], None, None]: ... def chordal_graph_treewidth(G: Graph[Hashable]) -> int: ... diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi index 95b6e1023065..6f85ac71e4c5 100644 --- a/stubs/networkx/networkx/algorithms/clique.pyi +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -1,21 +1,40 @@ -from _typeshed import Unused -from collections.abc import Iterable +from _typeshed import SupportsGetItem, Unused +from collections.abc import Iterable, Generator, Iterator, Sized, Container +from typing import overload from networkx.classes.graph import Graph, _Node -def enumerate_all_cliques(G: Graph[_Node]) -> Iterable[list[_Node]]: ... -def find_cliques(G: Graph[_Node], nodes: list[_Node] | None = None) -> Iterable[list[_Node]]: ... -def find_cliques_recursive(G: Graph[_Node], nodes: list[_Node] | None = None) -> Iterable[list[_Node]]: ... +def enumerate_all_cliques(G: Graph[_Node]) -> Generator[list[_Node], None, None]: ... +def find_cliques(G: Graph[_Node], nodes: SupportsGetItem[slice, _Node] | None = None) -> Generator[list[_Node], None, None]: ... +def find_cliques_recursive(G: Graph[_Node], nodes: SupportsGetItem[slice, _Node] | None = None) -> Iterator[list[_Node]]: ... def make_max_clique_graph(G: Graph[_Node], create_using: type[Graph[_Node]] | None = None) -> Graph[_Node]: ... def make_clique_bipartite( - G: Graph[_Node], fpos: None = None, create_using: type[Graph[_Node]] | None = None, name: None = None + G: Graph[_Node], fpos: Unused = None, create_using: type[Graph[_Node]] | None = None, name: Unused = None ) -> Graph[_Node]: ... -def graph_clique_number(G: Graph[_Node], cliques: list[_Node] | None = None) -> int: ... -def graph_number_of_cliques(G: Graph[_Node], cliques: list[_Node] | None = None) -> int: ... +def graph_clique_number(G: Graph[_Node], cliques: Iterable[_Node] | None = None) -> int: ... +def graph_number_of_cliques(G: Graph[_Node], cliques: Sized | None = None) -> int: ... +@overload +def node_clique_number( # type: ignore[misc] # Incompatible return types + G: Graph[_Node], + nodes: Iterable[_Node] | None = None, + cliques: Iterable[Iterable[_Node]] | None = None, + separate_nodes: Unused = False, +) -> dict[_Node, int]: ... +@overload def node_clique_number( - G: Graph[_Node], nodes: list[_Node] | None = None, cliques: list[list[_Node]] | None = None, separate_nodes: Unused = False + G: Graph[_Node], nodes: _Node, cliques: Iterable[Sized] | None = None, separate_nodes: Unused = False ) -> int: ... -def number_of_cliques(G: Graph[_Node], nodes: list[_Node] | None = None, cliques: list[list[_Node]] | None = None) -> int: ... +@overload +def number_of_cliques( # type: ignore[misc] # Incompatible return types + G: Graph[_Node], nodes: list[_Node] | None = None, cliques: Iterable[Container[_Node]] | None = None +) -> dict[_Node, int]: ... +@overload +def number_of_cliques(G: Graph[_Node], nodes: _Node, cliques: Iterable[Container[_Node]] | None = None) -> int: ... +@overload +def cliques_containing_node( # type: ignore[misc] # Incompatible return types + G: Graph[_Node], nodes: list[_Node] | None = None, cliques: Iterable[Container[_Node]] | None = None +) -> dict[_Node, list[_Node]]: ... +@overload def cliques_containing_node( - G: Graph[_Node], nodes: list[_Node] | None = None, cliques: list[list[_Node]] | None = None -) -> Iterable[list[_Node]]: ... + G: Graph[_Node], nodes: _Node, cliques: Iterable[Container[_Node]] | None = None +) -> Generator[list[_Node], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/community/louvain.pyi b/stubs/networkx/networkx/algorithms/community/louvain.pyi index 81145cbb7cf1..64c554664e24 100644 --- a/stubs/networkx/networkx/algorithms/community/louvain.pyi +++ b/stubs/networkx/networkx/algorithms/community/louvain.pyi @@ -2,8 +2,8 @@ from _typeshed import Incomplete from collections.abc import Generator def louvain_communities( - G, weight: str = "weight", resolution: int = 1, threshold: float = 1e-07, seed: Incomplete | None = None + G, weight: str = "weight", resolution: float = 1, threshold: float = 1e-07, seed: Incomplete | None = None ): ... def louvain_partitions( - G, weight: str = "weight", resolution: int = 1, threshold: float = 1e-07, seed: Incomplete | None = None + G, weight: str = "weight", resolution: float = 1, threshold: float = 1e-07, seed: Incomplete | None = None ) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/community/modularity_max.pyi b/stubs/networkx/networkx/algorithms/community/modularity_max.pyi index aacc7ab926fc..e994d7760705 100644 --- a/stubs/networkx/networkx/algorithms/community/modularity_max.pyi +++ b/stubs/networkx/networkx/algorithms/community/modularity_max.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete def greedy_modularity_communities( - G, weight: Incomplete | None = None, resolution: int = 1, cutoff: int = 1, best_n: Incomplete | None = None + G, weight: Incomplete | None = None, resolution: float = 1, cutoff: int = 1, best_n: Incomplete | None = None ): ... -def naive_greedy_modularity_communities(G, resolution: int = 1, weight: Incomplete | None = None): ... +def naive_greedy_modularity_communities(G, resolution: float = 1, weight: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/community/quality.pyi b/stubs/networkx/networkx/algorithms/community/quality.pyi index a402d0646a59..dff61e455eaa 100644 --- a/stubs/networkx/networkx/algorithms/community/quality.pyi +++ b/stubs/networkx/networkx/algorithms/community/quality.pyi @@ -5,5 +5,5 @@ __all__ = ["modularity", "partition_quality"] class NotAPartition(NetworkXError): def __init__(self, G, collection) -> None: ... -def modularity(G, communities, weight: str = "weight", resolution: int = 1): ... +def modularity(G, communities, weight: str = "weight", resolution: float = 1): ... def partition_quality(G, partition): ... diff --git a/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi index 918807abfa01..4403ddfeea62 100644 --- a/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi @@ -6,9 +6,9 @@ from networkx.classes.graph import Graph _N = TypeVar("_N") -def strongly_connected_components(G: Graph[_N]) -> Iterable[set[_N]]: ... -def kosaraju_strongly_connected_components(G: Graph[_N], source: _N | None = None) -> Iterable[set[_N]]: ... -def strongly_connected_components_recursive(G: Graph[_N]) -> Iterable[set[_N]]: ... +def strongly_connected_components(G: Graph[_N]) -> Generator[set[_N], None, None]: ... +def kosaraju_strongly_connected_components(G: Graph[_N], source: _N | None = None) -> Generator[set[_N], None, None]: ... +def strongly_connected_components_recursive(G: Graph[_N]) -> Generator[set[_N], None, None]: ... def number_strongly_connected_components(G: Graph[Hashable]) -> int: ... def is_strongly_connected(G: Graph[Hashable]) -> bool: ... -def condensation(G: DiGraph[_N], scc: Iterable[set[_N]] | None = None) -> DiGraph[int]: ... +def condensation(G: DiGraph[_N], scc: Iterable[Iterable[_N]] | None = None) -> DiGraph[int]: ... diff --git a/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi b/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi index 7a49e5d583c8..cb25783bec58 100644 --- a/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi @@ -5,6 +5,6 @@ from networkx.classes.graph import Graph _N = TypeVar("_N") -def weakly_connected_components(G: Graph[_N]) -> Iterable[set[_N]]: ... +def weakly_connected_components(G: Graph[_N]) -> Generator[set[_N], None, None]: ... def number_weakly_connected_components(G: Graph[Hashable]) -> int: ... def is_weakly_connected(G: Graph[Hashable]) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi index a1c6b3a7f13d..a53b54e0fd30 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -13,4 +13,4 @@ def k_edge_augmentation( avail: tuple[_N, _N] | tuple[_N, _N, dict[str, int]] | None = None, weight: str | None = None, partial: bool = False, -) -> Iterable[tuple[_N, _N]]: ... +) -> Generator[tuple[_N, _N], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi b/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi index 9069a6de4253..6d38c6b93654 100644 --- a/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi +++ b/stubs/networkx/networkx/algorithms/flow/preflowpush.pyi @@ -6,6 +6,6 @@ def preflow_push( t, capacity: str = "capacity", residual: Incomplete | None = None, - global_relabel_freq: int = 1, + global_relabel_freq: float = 1, value_only: bool = False, ): ... diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index dd5df7d7a905..f7dddcbf22ef 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -61,13 +61,13 @@ class LRPlanarity: class PlanarEmbedding(Generic[_N], DiGraph[_N]): def get_data(self) -> dict[_N, list[_N]]: ... - def set_data(self, data: dict[_N, list[_N]]) -> None: ... - def neighbors_cw_order(self, v: _N) -> Iterable[_N]: ... + def set_data(self, data: Mapping[_N, Reversible[_N]]) -> None: ... + def neighbors_cw_order(self, v: _N) -> Generator[_N, None, None]: ... def check_structure(self) -> None: ... def add_half_edge_ccw(self, start_node: _N, end_node: _N, reference_neighbor: _N) -> None: ... def add_half_edge_cw(self, start_node: _N, end_node: _N, reference_neighbor: _N) -> None: ... def connect_components(self, v: _N, w: _N) -> None: ... def add_half_edge_first(self, start_node: _N, end_node: _N) -> None: ... def next_face_half_edge(self, v: _N, w: _N) -> tuple[_N, _N]: ... - def traverse_face(self, v: _N, w: _N, mark_half_edges: set[tuple[_N, _N]] | None = None) -> list[_N]: ... + def traverse_face(self, v: _N, w: _N, mark_half_edges: MutableSet[tuple[_N, _N]] | None = None) -> list[_N]: ... def is_directed(self) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/richclub.pyi b/stubs/networkx/networkx/algorithms/richclub.pyi index 0e5093a45278..5e7903e1956f 100644 --- a/stubs/networkx/networkx/algorithms/richclub.pyi +++ b/stubs/networkx/networkx/algorithms/richclub.pyi @@ -1,3 +1,3 @@ from _typeshed import Incomplete -def rich_club_coefficient(G, normalized: bool = True, Q: int = 100, seed: Incomplete | None = None): ... +def rich_club_coefficient(G, normalized: bool = True, Q: float = 100, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi index 00ba730ce020..f55c9019f927 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi @@ -25,4 +25,4 @@ def shortest_path_length( def average_shortest_path_length(G, weight: Incomplete | None = None, method: str | None = None): ... def all_shortest_paths( G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = None, method: str = "dijkstra" -) -> Iterable[list[_T]]: ... +) -> Generator[list[_T], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/simple_paths.pyi b/stubs/networkx/networkx/algorithms/simple_paths.pyi index e49301aa5cd5..41575a4c630f 100644 --- a/stubs/networkx/networkx/algorithms/simple_paths.pyi +++ b/stubs/networkx/networkx/algorithms/simple_paths.pyi @@ -7,7 +7,7 @@ from networkx.classes.graph import Graph __all__ = ["all_simple_paths", "is_simple_path", "shortest_simple_paths", "all_simple_edge_paths"] _T = TypeVar("_T") -def is_simple_path(G: Graph[_T], nodes: list[_T]): ... +def is_simple_path(G: Graph[_T], nodes: Sequence[_T]): ... def all_simple_paths( G: Graph[_T], source: _T, target: _T, cutoff: Incomplete | None = None ) -> Generator[list[_T], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi index 234cc81955a6..92b96007eb7a 100644 --- a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi @@ -6,7 +6,7 @@ from networkx.classes.graph import Graph _T = TypeVar("_T") -def dfs_edges(G: Graph[_T], source: _T | None = None, depth_limit: int | None = None) -> Iterator[tuple[_T, _T]]: ... +def dfs_edges(G: Graph[_T], source: _T | None = None, depth_limit: int | None = None) -> Generator[tuple[_T, _T], None, None]: ... def dfs_tree(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... def dfs_predecessors(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... def dfs_successors(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi index fd7b4da7013b..11550dcd4263 100644 --- a/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -16,8 +16,8 @@ __all__ = [ "Edmonds", ] -def branching_weight(G, attr: str = "weight", default: int = 1): ... -def greedy_branching(G, attr: str = "weight", default: int = 1, kind: str = "max", seed: Incomplete | None = None): ... +def branching_weight(G, attr: str = "weight", default: float = 1): ... +def greedy_branching(G, attr: str = "weight", default: float = 1, kind: str = "max", seed: Incomplete | None = None): ... class MultiDiGraph_EdgeKey(MultiDiGraph[_Node], Generic[_Node]): edge_index: Incomplete @@ -38,7 +38,7 @@ class Edmonds: def find_optimum( self, attr: str = "weight", - default: int = 1, + default: float = 1, kind: str = "max", style: str = "branching", preserve_attrs: bool = False, @@ -47,28 +47,23 @@ class Edmonds: ): ... def maximum_branching( - G, attr: str = "weight", default: int = 1, preserve_attrs: bool = False, partition: Incomplete | None = None + G, attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: Incomplete | None = None ): ... def minimum_branching( - G, attr: str = "weight", default: int = 1, preserve_attrs: bool = False, partition: Incomplete | None = None + G, attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: Incomplete | None = None ): ... def maximum_spanning_arborescence( - G, attr: str = "weight", default: int = 1, preserve_attrs: bool = False, partition: Incomplete | None = None + G, attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: Incomplete | None = None ): ... def minimum_spanning_arborescence( - G, attr: str = "weight", default: int = 1, preserve_attrs: bool = False, partition: Incomplete | None = None + G, attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: Incomplete | None = None ): ... class ArborescenceIterator: + @dataclass(order=True) class Partition: mst_weight: float partition_dict: dict[Incomplete, Incomplete] - def __copy__(self): ... - def __init__(self, mst_weight, partition_dict) -> None: ... - def __lt__(self, other): ... - def __gt__(self, other): ... - def __le__(self, other): ... - def __ge__(self, other): ... G: Incomplete weight: Incomplete minimum: Incomplete diff --git a/stubs/networkx/networkx/algorithms/tree/mst.pyi b/stubs/networkx/networkx/algorithms/tree/mst.pyi index 5aaf111b9d43..9407954fb2d7 100644 --- a/stubs/networkx/networkx/algorithms/tree/mst.pyi +++ b/stubs/networkx/networkx/algorithms/tree/mst.pyi @@ -3,9 +3,9 @@ from collections.abc import Iterator from enum import Enum class EdgePartition(Enum): - OPEN: int - INCLUDED: int - EXCLUDED: int + OPEN = 0 + INCLUDED = 1 + EXCLUDED = 2 def minimum_spanning_edges( G, algorithm: str = "kruskal", weight: str = "weight", keys: bool = True, data: bool = True, ignore_nan: bool = False @@ -21,15 +21,10 @@ def maximum_spanning_tree(G, weight: str = "weight", algorithm: str = "kruskal", def random_spanning_tree(G, weight: Incomplete | None = None, *, multiplicative: bool = True, seed: Incomplete | None = None): ... class SpanningTreeIterator: + @dataclass(order=True) class Partition: mst_weight: float partition_dict: dict[Incomplete, Incomplete] - def __copy__(self): ... - def __init__(self, mst_weight, partition_dict) -> None: ... - def __lt__(self, other): ... - def __gt__(self, other): ... - def __le__(self, other): ... - def __ge__(self, other): ... G: Incomplete weight: Incomplete minimum: Incomplete diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index 1bbeff4858cf..ab91eecbee25 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -65,14 +65,14 @@ 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 induced_subgraph(G: Graph[_T], nbunch: _T | Iterable[_T] | None) -> Graph[_T]: ... +def induced_subgraph(G: Graph[_T], nbunch: _NBunch[_T]) -> Graph[_T]: ... def edge_subgraph(G, edges): ... def restricted_view(G, nodes, edges): ... def to_directed(graph): ... def to_undirected(graph): ... def create_empty_copy(G, with_data: bool = True): ... -# Can "Any scalar value" be enforced? +# incomplete: Can "Any scalar value" be enforced? @overload def set_node_attributes(G: Graph[Hashable], values, name: str) -> None: ... @overload @@ -83,40 +83,40 @@ def set_edge_attributes(G: Graph[_T], values: dict[tuple[_T, _T], Incomplete], n @overload def set_edge_attributes(G: Graph[Hashable], values, name: None = None) -> None: ... def get_edge_attributes(G: Graph[_T], name: str) -> dict[tuple[_T, _T], Incomplete]: ... -def all_neighbors(graph: Graph[_T], node: _T) -> Iterable[_T]: ... -def non_neighbors(graph: Graph[_T], node: _T) -> Iterable[_T]: ... -def non_edges(graph: Graph[_T]) -> Iterable[tuple[_T, _T]]: ... -def common_neighbors(G: Graph[_T], u: _T, v: _T) -> Iterable[_T]: ... +def all_neighbors(graph: Graph[_T], node: _T) -> Iterator[_T]: ... +def non_neighbors(graph: Graph[_T], node: _T) -> Generator[_T, None, None]: ... +def non_edges(graph: Graph[_T]) -> Generator[tuple[_T, _T], None, None]: ... +def common_neighbors(G: Graph[_T], u: _T, v: _T) -> Generator[_T, None, None]: ... def is_weighted(G: Graph[_T], edge: tuple[_T, _T] | None = None, weight: str | None = "weight") -> bool: ... def is_negatively_weighted(G: Graph[_T], edge: tuple[_T, _T] | None = None, weight: str | None = "weight"): ... def is_empty(G: Graph[Hashable]) -> bool: ... -def nodes_with_selfloops(G: Graph[_T]) -> Iterable[_T]: ... +def nodes_with_selfloops(G: Graph[_T]) -> Generator[_T, None, None]: ... @overload def selfloop_edges( G: Graph[_T], data: Literal[False] = False, keys: Literal[False] = False, default=None -) -> Iterable[tuple[_T, _T]]: ... +) -> Generator[tuple[_T, _T], None, None]: ... @overload def selfloop_edges( G: Graph[_T], data: Literal[True], keys: Literal[False] = False, default=None -) -> Iterable[tuple[_T, _T, dict[str, Incomplete]]]: ... +) -> Generator[tuple[_T, _T, dict[str, Incomplete]], None, None]: ... @overload def selfloop_edges( G: Graph[_T], data: str, keys: Literal[False] = False, default: _U | None = None -) -> Iterable[tuple[_T, _T, _U]]: ... +) -> Generator[tuple[_T, _T, _U], None, None]: ... @overload -def selfloop_edges(G: Graph[_T], data: Literal[False], keys: Literal[True], default=None) -> Iterable[tuple[_T, _T, int]]: ... +def selfloop_edges(G: Graph[_T], data: Literal[False], keys: Literal[True], default=None) -> Generator[tuple[_T, _T, int], None, None]: ... @overload def selfloop_edges( G: Graph[_T], data: Literal[False] = False, *, keys: Literal[True], default=None -) -> Iterable[tuple[_T, _T, int]]: ... +) -> Generator[tuple[_T, _T, int]], None, None]: ... @overload def selfloop_edges( G: Graph[_T], data: Literal[True], keys: Literal[True], default=None -) -> Iterable[tuple[_T, _T, int, dict[str, Incomplete]]]: ... +) -> Generator[tuple[_T, _T, int, dict[str, Incomplete]], None, None]: ... @overload def selfloop_edges( G: Graph[_T], data: str, keys: Literal[True], default: _U | None = None -) -> Iterable[tuple[_T, _T, int, _U]]: ... +) -> Generator[tuple[_T, _T, 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: ... diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi index ba2938046993..d27c2cb1bc8b 100644 --- a/stubs/networkx/networkx/classes/graph.pyi +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -29,7 +29,7 @@ class Graph(Collection[_Node], Generic[_Node]): adj: AdjacencyView[_Node, _Node, dict[str, Incomplete]] name: str - def __getitem__(self, n: _Node) -> MutableMapping[Hashable, Incomplete]: ... + def __getitem__(self, n: _Node) -> AtlasView[_Node, _Node, dict[str, Incomplete]]: ... def __iter__(self) -> Iterator[_Node]: ... def __contains__(self, n: object) -> bool: ... def __len__(self) -> int: ... @@ -57,10 +57,10 @@ class Graph(Collection[_Node], Generic[_Node]): self, edges: Graph[_Node] | Iterable[_EdgePlus[_Node]] | None = None, nodes: Iterable[_Node] | None = None ) -> None: ... def has_edge(self, u: _Node, v: _Node) -> bool: ... - def neighbors(self, n: _Node) -> Iterable[_Node]: ... + def neighbors(self, n: _Node) -> Iterator[_Node]: ... edges: OutEdgeView[_Node] def get_edge_data(self, u: _Node, v: _Node, default: Incomplete = None) -> Mapping[str, Incomplete]: ... - def adjacency(self) -> Iterable[tuple[_Node, Mapping[_Node, Mapping[str, Incomplete]]]]: ... + def adjacency(self) -> Iterator[tuple[_Node, Mapping[_Node, Mapping[str, Incomplete]]]]: ... degree: DiDegreeView[_Node] @@ -78,4 +78,4 @@ class Graph(Collection[_Node], Generic[_Node]): @overload def size(self, weight: str) -> float: ... def number_of_edges(self, u: _Node | None = None, v: _Node | None = None) -> int: ... - def nbunch_iter(self, nbunch: _NBunch[_Node] = None) -> Iterable[_Node]: ... + def nbunch_iter(self, nbunch: _NBunch[_Node] = None) -> Iterator[_Node]: ... diff --git a/stubs/networkx/networkx/classes/graphviews.pyi b/stubs/networkx/networkx/classes/graphviews.pyi index 063a3f5f7c34..13979caf1dfa 100644 --- a/stubs/networkx/networkx/classes/graphviews.pyi +++ b/stubs/networkx/networkx/classes/graphviews.pyi @@ -13,13 +13,13 @@ _D = TypeVar("_D", bound=DiGraph[Hashable]) @overload def generic_graph_view(G: _G, create_using: None = None) -> _G: ... @overload -def generic_graph_view(G: Graph[_Node], create_using: type[MultiDiGraph[Incomplete]]) -> MultiDiGraph[_Node]: ... +def generic_graph_view(G: Graph[_Node], create_using: type[MultiDiGraph[_Node]]) -> MultiDiGraph[_Node]: ... @overload -def generic_graph_view(G: Graph[_Node], create_using: type[DiGraph[Incomplete]]) -> DiGraph[_Node]: ... +def generic_graph_view(G: Graph[_Node], create_using: type[DiGraph[_Node]]) -> DiGraph[_Node]: ... @overload -def generic_graph_view(G: Graph[_Node], create_using: type[MultiGraph[Incomplete]]) -> MultiGraph[_Node]: ... +def generic_graph_view(G: Graph[_Node], create_using: type[MultiGraph[_Node]]) -> MultiGraph[_Node]: ... @overload -def generic_graph_view(G: Graph[_Node], create_using: type[Graph[Incomplete]]) -> Graph[_Node]: ... +def generic_graph_view(G: Graph[_Node], create_using: type[Graph[_Node]]) -> Graph[_Node]: ... @overload def subgraph_view( G: MultiDiGraph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_MultiEdge[_Node]], bool] = ... diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index d29587661134..20ed412fa923 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -21,8 +21,8 @@ class NodeView(Mapping[_Node, _Node], AbstractSet[_Node]): def __call__(self, data: Literal[True] | str, default: Incomplete = None) -> NodeDataView[_Node]: ... def data(self, data: bool | str = True, default: Incomplete = None) -> NodeDataView[_Node]: ... -class NodeDataView(Generic[_Node], metaclass=ABCMeta): - def __init__(self, nodedict: dict[str, Incomplete], data: bool | str = False, default: Incomplete = None) -> None: ... +class NodeDataView(AbstractSet[_Node]): + def __init__(self, nodedict: Mapping[str, Incomplete], data: bool | str = False, default: Incomplete = None) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[tuple[_Node, Incomplete]]: ... def __contains__(self, n: object) -> bool: ... diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index b457a01e78ba..9e775dec850b 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -11,14 +11,14 @@ from networkx.classes.graph import Graph, _Node _DataFrame: TypeAlias = Incomplete # from pandas.core.dtypes.base import ExtensionDtype _ExtensionDtype: TypeAlias = Incomplete -_G = TypeVar("_G") +_G = TypeVar("_G", bound=Graph[Hashable]) def to_pandas_adjacency( G: Graph[_Node], nodelist: list[_Node] | None = None, dtype: numpy.dtype[Incomplete] | None = None, - order: Literal["C", "F"] | None = None, - multigraph_weight: Callable[[Iterable[float]], float] = ..., + order: numpy._OrderCF = None, + multigraph_weight: Callable[[list[float]], float] = ..., weight: str = "weight", nonedge: float = 0.0, ) -> _DataFrame: ... @@ -30,16 +30,25 @@ def to_pandas_edgelist( G: Graph[_Node], source: str | int = "source", target: str | int = "target", - nodelist: list[_Node] | None = None, + nodelist: Iterable[_Node] | None = None, dtype: _ExtensionDtype | None = None, edge_key: str | int | None = None, ) -> _DataFrame: ... @overload +def from_pandas_edgelist( + df: _DataFrame, + source: str | int, + target: str | int, + edge_attr: str | int | list[str | int] | tuple[str | int] | Literal[True] | None, + create_using: type[_G], + edge_key: str | None = None, +) -> _G: ... +@overload def from_pandas_edgelist( df: _DataFrame, source: str | int = "source", target: str | int = "target", - edge_attr: str | int | Iterable[str | int] | Literal[True] | None = None, + edge_attr: str | int | list[str | int] | tuple[str | int] | Literal[True] | None = None, *, create_using: type[_G], edge_key: str | None = None, @@ -49,16 +58,16 @@ def from_pandas_edgelist( df: _DataFrame, source: str | int = "source", target: str | int = "target", - edge_attr: str | int | Iterable[str | int] | Literal[True] | None = None, + edge_attr: str | int | list[str | int] | tuple[str | int] | Literal[True] | None = None, create_using: None = None, edge_key: str | None = None, ) -> Graph[Incomplete]: ... def to_numpy_array( G: Graph[_Node], - nodelist: list[_Node] | None = None, + nodelist: Collection[_Node] | None = None, dtype: numpy.dtype[Incomplete] | None = None, - order: Literal["C", "F"] | None = None, - multigraph_weight: Callable[[Iterable[float]], float] = ..., + order: numpy._OrderCF = None, + multigraph_weight: Callable[[list[float]], float] = ..., weight: str = "weight", nonedge: float = 0.0, ) -> numpy.ndarray[Incomplete, numpy.dtype[Incomplete]]: ... diff --git a/stubs/networkx/networkx/drawing/layout.pyi b/stubs/networkx/networkx/drawing/layout.pyi index 41a69a12f607..d84ae0b55131 100644 --- a/stubs/networkx/networkx/drawing/layout.pyi +++ b/stubs/networkx/networkx/drawing/layout.pyi @@ -1,17 +1,17 @@ from _typeshed import Incomplete def random_layout(G, center: Incomplete | None = None, dim: int = 2, seed: Incomplete | None = None): ... -def circular_layout(G, scale: int = 1, center: Incomplete | None = None, dim: int = 2): ... +def circular_layout(G, scale: float = 1, center: Incomplete | None = None, dim: int = 2): ... def shell_layout( G, nlist: Incomplete | None = None, rotate: Incomplete | None = None, - scale: int = 1, + scale: float = 1, center: Incomplete | None = None, dim: int = 2, ): ... def bipartite_layout( - G, nodes, align: str = "vertical", scale: int = 1, center: Incomplete | None = None, aspect_ratio: float = ... + G, nodes, align: str = "vertical", scale: float = 1, center: Incomplete | None = None, aspect_ratio: float = ... ): ... def spring_layout( G, @@ -21,7 +21,7 @@ def spring_layout( iterations: int = 50, threshold: float = 0.0001, weight: str = "weight", - scale: int = 1, + scale: float = 1, center: Incomplete | None = None, dim: int = 2, seed: Incomplete | None = None, @@ -34,26 +34,26 @@ def kamada_kawai_layout( dist: Incomplete | None = None, pos: Incomplete | None = None, weight: str = "weight", - scale: int = 1, + scale: float = 1, center: Incomplete | None = None, dim: int = 2, ): ... -def spectral_layout(G, weight: str = "weight", scale: int = 1, center: Incomplete | None = None, dim: int = 2): ... -def planar_layout(G, scale: int = 1, center: Incomplete | 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): ... def spiral_layout( - G, scale: int = 1, center: Incomplete | None = None, dim: int = 2, resolution: float = 0.35, equidistant: bool = False + G, scale: float = 1, center: Incomplete | None = None, dim: int = 2, resolution: float = 0.35, equidistant: bool = False ): ... def multipartite_layout( - G, subset_key: str = "subset", align: str = "vertical", scale: int = 1, center: Incomplete | None = None + G, subset_key: str = "subset", align: str = "vertical", scale: float = 1, center: Incomplete | None = None ): ... def arf_layout( G, pos: Incomplete | None = None, - scaling: int = 1, + scaling: float = 1, a: float = 1.1, etol: float = 1e-06, dt: float = 0.001, max_iter: int = 1000, ): ... -def rescale_layout(pos, scale: int = 1): ... -def rescale_layout_dict(pos, scale: int = 1): ... +def rescale_layout(pos, scale: float = 1): ... +def rescale_layout_dict(pos, scale: float = 1): ... diff --git a/stubs/networkx/networkx/drawing/nx_agraph.pyi b/stubs/networkx/networkx/drawing/nx_agraph.pyi index 9ed44ba23a77..0b91cbba467a 100644 --- a/stubs/networkx/networkx/drawing/nx_agraph.pyi +++ b/stubs/networkx/networkx/drawing/nx_agraph.pyi @@ -7,7 +7,6 @@ from typing_extensions import TypeAlias from networkx.classes.graph import Graph # from pygraphviz.agraph import AGraph as _AGraph - _AGraph: TypeAlias = Incomplete _T = TypeVar("_T") @@ -16,14 +15,14 @@ def to_agraph(N: Graph[Hashable]) -> _AGraph: ... def write_dot(G: Graph[Hashable], path: str | TextIOBase) -> None: ... def read_dot(path: str | TextIOBase) -> Graph[Incomplete]: ... def graphviz_layout( - G: Graph[_T], prog: str = "neato", root: str | None = None, args: str = "" -) -> dict[_T, tuple[float, float]]: ... + G: Graph[_Node], prog: str = "neato", root: str | None = None, args: str = "" +) -> dict[_Node, tuple[float, float]]: ... pygraphviz_layout = graphviz_layout def view_pygraphviz( - G: Graph[_T], - edgelabel: str | Callable[[_T], str] | None = None, + G: Graph[_Node], + edgelabel: str | Callable[[_Node], str] | None = None, prog: str = "dot", args: str = "", suffix: str = "", diff --git a/stubs/networkx/networkx/drawing/nx_pylab.pyi b/stubs/networkx/networkx/drawing/nx_pylab.pyi index d01a088a71fb..1fc090b5f0a7 100644 --- a/stubs/networkx/networkx/drawing/nx_pylab.pyi +++ b/stubs/networkx/networkx/drawing/nx_pylab.pyi @@ -8,7 +8,7 @@ def draw_networkx_nodes( G, pos, nodelist: Incomplete | None = None, - node_size: int = 300, + node_size: Incomplete | int = 300, node_color: str = "#1f78b4", node_shape: str = "o", alpha: Incomplete | None = None, @@ -37,7 +37,7 @@ def draw_networkx_edges( ax: Incomplete | None = None, arrows: Incomplete | None = None, label: Incomplete | None = None, - node_size: int = 300, + node_size: Incomplete | int = 300, nodelist: Incomplete | None = None, node_shape: str = "o", connectionstyle: str = "arc3", diff --git a/stubs/networkx/networkx/generators/classic.pyi b/stubs/networkx/networkx/generators/classic.pyi index 26e7a87062b2..10f57320828c 100644 --- a/stubs/networkx/networkx/generators/classic.pyi +++ b/stubs/networkx/networkx/generators/classic.pyi @@ -9,7 +9,7 @@ def circular_ladder_graph(n, create_using: Incomplete | None = None): ... def circulant_graph(n, offsets, create_using: Incomplete | None = None): ... def cycle_graph(n, create_using: Incomplete | None = None): ... def dorogovtsev_goltsev_mendes_graph(n, create_using: Incomplete | None = None): ... -def empty_graph(n: int = 0, create_using: Incomplete | None = None, default=...): ... +def empty_graph(n: Incomplete | int = 0, create_using: Incomplete | None = None, default=...): ... def ladder_graph(n, create_using: Incomplete | None = None): ... def lollipop_graph(m, n, create_using: Incomplete | None = None): ... def null_graph(create_using: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/directed.pyi b/stubs/networkx/networkx/generators/directed.pyi index bed206dbbad2..73a9b62da530 100644 --- a/stubs/networkx/networkx/generators/directed.pyi +++ b/stubs/networkx/networkx/generators/directed.pyi @@ -9,7 +9,7 @@ def scale_free_graph( beta: float = 0.54, gamma: float = 0.05, delta_in: float = 0.2, - delta_out: int = 0, + delta_out: float = 0, create_using: Incomplete | None = None, seed: Incomplete | None = None, initial_graph: Incomplete | None = None, diff --git a/stubs/networkx/networkx/generators/ego.pyi b/stubs/networkx/networkx/generators/ego.pyi index 1ce413e52d5c..509eb94eaa74 100644 --- a/stubs/networkx/networkx/generators/ego.pyi +++ b/stubs/networkx/networkx/generators/ego.pyi @@ -1,3 +1,3 @@ from _typeshed import Incomplete -def ego_graph(G, n, radius: int = 1, center: bool = True, undirected: bool = False, distance: Incomplete | None = None): ... +def ego_graph(G, n, radius: float = 1, center: bool = True, undirected: bool = False, distance: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/geometric.pyi b/stubs/networkx/networkx/generators/geometric.pyi index a9270d2fec64..2ca20fa48e59 100644 --- a/stubs/networkx/networkx/generators/geometric.pyi +++ b/stubs/networkx/networkx/generators/geometric.pyi @@ -1,15 +1,15 @@ from _typeshed import Incomplete -def geometric_edges(G, radius, p: int = 2): ... +def geometric_edges(G, radius, p: float = 2): ... def random_geometric_graph( - n, radius, dim: int = 2, pos: Incomplete | None = None, p: int = 2, seed: Incomplete | None = None + n, radius, dim: int = 2, pos: Incomplete | None = None, p: float = 2, seed: Incomplete | None = None ): ... def soft_random_geometric_graph( n, radius, dim: int = 2, pos: Incomplete | None = None, - p: int = 2, + p: float = 2, p_dist: Incomplete | None = None, seed: Incomplete | None = None, ): ... @@ -32,7 +32,8 @@ def waxman_graph( metric: Incomplete | None = None, seed: Incomplete | None = None, ): ... -def navigable_small_world_graph(n, p: int = 1, q: int = 1, r: int = 2, dim: int = 2, seed: Incomplete | None = None): ... +# docstring marks p as int, but it still works with floats. So I think it's better for consistency +def navigable_small_world_graph(n, p: float = 1, q: int = 1, r: float = 2, dim: int = 2, seed: Incomplete | None = None): ... def thresholded_random_geometric_graph( n, radius, @@ -40,6 +41,6 @@ def thresholded_random_geometric_graph( dim: int = 2, pos: Incomplete | None = None, weight: Incomplete | None = None, - p: int = 2, + p: float = 2, seed: Incomplete | None = None, ): ... diff --git a/stubs/networkx/networkx/generators/random_clustered.pyi b/stubs/networkx/networkx/generators/random_clustered.pyi index 6ea6b95997d5..2cb62c77716a 100644 --- a/stubs/networkx/networkx/generators/random_clustered.pyi +++ b/stubs/networkx/networkx/generators/random_clustered.pyi @@ -2,13 +2,13 @@ from typing import Any, TypeVar, overload from networkx import MultiGraph -_G = TypeVar("_G", bound=MultiGraph[int]) +_G = TypeVar("_G", bound=Graph[int]) @overload def random_clustered_graph( - joint_degree_sequence: list[tuple[int, int]], create_using: None = None, seed: int | tuple[Any, ...] | None = None + joint_degree_sequence: Iterable[tuple[int, int]], create_using: None = None, seed: int | tuple[Any, ...] | None = None ) -> MultiGraph[int]: ... @overload def random_clustered_graph( - joint_degree_sequence: list[tuple[int, int]], create_using: type[_G], seed: int | tuple[Any, ...] | None = None + joint_degree_sequence: Iterable[tuple[int, int]], create_using: type[_G], seed: int | tuple[Any, ...] | None = None ) -> _G: ... diff --git a/stubs/networkx/networkx/generators/random_graphs.pyi b/stubs/networkx/networkx/generators/random_graphs.pyi index 036b1f9a50b5..6a075ac2a5e9 100644 --- a/stubs/networkx/networkx/generators/random_graphs.pyi +++ b/stubs/networkx/networkx/generators/random_graphs.pyi @@ -18,6 +18,6 @@ def extended_barabasi_albert_graph(n, m, p, q, seed: Incomplete | None = None): def powerlaw_cluster_graph(n, m, p, seed: Incomplete | None = None): ... def random_lobster(n, p1, p2, seed: Incomplete | None = None): ... def random_shell_graph(constructor, seed: Incomplete | None = None): ... -def random_powerlaw_tree(n, gamma: int = 3, seed: Incomplete | None = None, tries: int = 100): ... -def random_powerlaw_tree_sequence(n, gamma: int = 3, seed: Incomplete | None = None, tries: int = 100): ... +def random_powerlaw_tree(n, gamma: float = 3, seed: Incomplete | None = None, tries: int = 100): ... +def random_powerlaw_tree_sequence(n, gamma: float = 3, seed: Incomplete | None = None, tries: int = 100): ... def random_kernel_graph(n, kernel_integral, kernel_root: Incomplete | None = None, seed: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/readwrite/gml.pyi b/stubs/networkx/networkx/readwrite/gml.pyi index 715c647342fb..363de75fa2d2 100644 --- a/stubs/networkx/networkx/readwrite/gml.pyi +++ b/stubs/networkx/networkx/readwrite/gml.pyi @@ -11,13 +11,13 @@ def read_gml(path, label: str = "label", destringizer: Incomplete | None = None) def parse_gml(lines, label: str = "label", destringizer: Incomplete | None = None): ... class Pattern(Enum): - KEYS: int - REALS: int - INTS: int - STRINGS: int - DICT_START: int - DICT_END: int - COMMENT_WHITESPACE: int + KEYS = 0 + REALS = 1 + INTS = 2 + STRINGS = 3 + DICT_START = 4 + DICT_END = 5 + COMMENT_WHITESPACE = 6 class Token(NamedTuple, Generic[_T]): category: Pattern diff --git a/stubs/networkx/networkx/readwrite/graphml.pyi b/stubs/networkx/networkx/readwrite/graphml.pyi index b5942feb3a9b..bfe67ab4731b 100644 --- a/stubs/networkx/networkx/readwrite/graphml.pyi +++ b/stubs/networkx/networkx/readwrite/graphml.pyi @@ -41,10 +41,10 @@ def read_graphml(path, node_type=..., edge_key_type=..., force_multigraph: bool def parse_graphml(graphml_string, node_type=..., edge_key_type=..., force_multigraph: bool = False): ... class GraphML: - NS_GRAPHML: str - NS_XSI: str - NS_Y: str - SCHEMALOCATION: Incomplete + NS_GRAPHML: Literal[str] + NS_XSI: Literal[str] + NS_Y: Literal[str] + SCHEMALOCATION: Literal[str] xml_type: Incomplete python_type: Incomplete def construct_types(self) -> None: ... diff --git a/stubs/networkx/networkx/readwrite/text.pyi b/stubs/networkx/networkx/readwrite/text.pyi index 27b91da83d8a..5da7380e3799 100644 --- a/stubs/networkx/networkx/readwrite/text.pyi +++ b/stubs/networkx/networkx/readwrite/text.pyi @@ -4,40 +4,40 @@ from collections.abc import Generator __all__ = ["forest_str", "generate_network_text", "write_network_text"] class _AsciiBaseGlyphs: - empty: str - newtree_last: str - newtree_mid: str - endof_forest: str - within_forest: str - within_tree: str + empty: ClassVar[str] + newtree_last: ClassVar[str] + newtree_mid: ClassVar[str] + endof_forest: ClassVar[str] + within_forest: ClassVar[str] + within_tree: ClassVar[str] class AsciiDirectedGlyphs(_AsciiBaseGlyphs): - last: str - mid: str - backedge: str + last: ClassVar[str] + mid: ClassVar[str] + backedge: ClassVar[str] class AsciiUndirectedGlyphs(_AsciiBaseGlyphs): - last: str - mid: str - backedge: str + last: ClassVar[str] + mid: ClassVar[str] + backedge: ClassVar[str] class _UtfBaseGlyphs: - empty: str - newtree_last: str - newtree_mid: str - endof_forest: str - within_forest: str - within_tree: str + empty: ClassVar[str] + newtree_last: ClassVar[str] + newtree_mid: ClassVar[str] + endof_forest: ClassVar[str] + within_forest: ClassVar[str] + within_tree: ClassVar[str] class UtfDirectedGlyphs(_UtfBaseGlyphs): - last: str - mid: str - backedge: str + last: ClassVar[str] + mid: ClassVar[str] + backedge: ClassVar[str] class UtfUndirectedGlyphs(_UtfBaseGlyphs): - last: str - mid: str - backedge: str + last: ClassVar[str] + mid: ClassVar[str] + backedge: ClassVar[str] def generate_network_text( graph, From e0743796783afbbc6d831ed9ce4328b8201a5f5d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 28 Nov 2023 23:30:01 +0000 Subject: [PATCH 32/37] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/networkx/networkx/algorithms/bridges.pyi | 2 +- stubs/networkx/networkx/algorithms/chains.pyi | 1 - stubs/networkx/networkx/algorithms/chordal.pyi | 2 +- stubs/networkx/networkx/algorithms/clique.pyi | 2 +- .../networkx/algorithms/components/weakly_connected.pyi | 2 +- .../networkx/algorithms/connectivity/edge_augmentation.pyi | 2 +- stubs/networkx/networkx/algorithms/planarity.pyi | 1 - stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi | 1 - .../networkx/algorithms/traversal/depth_first_search.pyi | 1 - stubs/networkx/networkx/classes/graphviews.pyi | 1 - stubs/networkx/networkx/classes/reportviews.pyi | 1 - stubs/networkx/networkx/generators/geometric.pyi | 1 + 12 files changed, 6 insertions(+), 11 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/bridges.pyi b/stubs/networkx/networkx/algorithms/bridges.pyi index 36383103883f..6a1667b8c239 100644 --- a/stubs/networkx/networkx/algorithms/bridges.pyi +++ b/stubs/networkx/networkx/algorithms/bridges.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Callable, Iterable +from collections.abc import Callable from typing import overload from typing_extensions import Literal diff --git a/stubs/networkx/networkx/algorithms/chains.pyi b/stubs/networkx/networkx/algorithms/chains.pyi index 9835abddfe4b..173998730462 100644 --- a/stubs/networkx/networkx/algorithms/chains.pyi +++ b/stubs/networkx/networkx/algorithms/chains.pyi @@ -1,4 +1,3 @@ -from collections.abc import Iterable from networkx.classes.graph import Graph, _Node diff --git a/stubs/networkx/networkx/algorithms/chordal.pyi b/stubs/networkx/networkx/algorithms/chordal.pyi index 287e6ce1f3dc..949771ab744d 100644 --- a/stubs/networkx/networkx/algorithms/chordal.pyi +++ b/stubs/networkx/networkx/algorithms/chordal.pyi @@ -1,4 +1,4 @@ -from collections.abc import Hashable, Iterable +from collections.abc import Hashable from networkx.classes.graph import Graph, _Node from networkx.exception import NetworkXException diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi index 6f85ac71e4c5..3cfe6eb83aa6 100644 --- a/stubs/networkx/networkx/algorithms/clique.pyi +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -1,5 +1,5 @@ from _typeshed import SupportsGetItem, Unused -from collections.abc import Iterable, Generator, Iterator, Sized, Container +from collections.abc import Container, Generator, Iterable, Iterator, Sized from typing import overload from networkx.classes.graph import Graph, _Node diff --git a/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi b/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi index cb25783bec58..58e8f403a259 100644 --- a/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi @@ -1,4 +1,4 @@ -from collections.abc import Hashable, Iterable +from collections.abc import Hashable from typing import TypeVar from networkx.classes.graph import Graph diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi index a53b54e0fd30..05e9c16a188b 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -1,4 +1,4 @@ -from collections.abc import Hashable, Iterable +from collections.abc import Hashable from typing import TypeVar from networkx.classes.graph import Graph diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index f7dddcbf22ef..cbcd667d1498 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -1,5 +1,4 @@ from _typeshed import Incomplete -from collections.abc import Iterable from typing import Generic, TypeVar from networkx.classes.digraph import DiGraph diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi index f55c9019f927..84c7411bc765 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi @@ -1,5 +1,4 @@ from _typeshed import Incomplete -from collections.abc import Iterable from typing import TypeVar, overload from networkx.classes.graph import Graph diff --git a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi index 92b96007eb7a..df5e1d6ab353 100644 --- a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi @@ -1,5 +1,4 @@ from _typeshed import Incomplete -from collections.abc import Iterator from typing import TypeVar from networkx.classes.graph import Graph diff --git a/stubs/networkx/networkx/classes/graphviews.pyi b/stubs/networkx/networkx/classes/graphviews.pyi index 13979caf1dfa..a356213889b3 100644 --- a/stubs/networkx/networkx/classes/graphviews.pyi +++ b/stubs/networkx/networkx/classes/graphviews.pyi @@ -1,4 +1,3 @@ -from _typeshed import Incomplete from collections.abc import Callable, Hashable from typing import TypeVar, overload diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index 20ed412fa923..8c11b1881208 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -1,5 +1,4 @@ from _typeshed import Incomplete, Unused -from abc import ABCMeta from collections.abc import Iterator, Mapping, Set as AbstractSet from typing import Generic, TypeVar, overload from typing_extensions import Literal, Self diff --git a/stubs/networkx/networkx/generators/geometric.pyi b/stubs/networkx/networkx/generators/geometric.pyi index 2ca20fa48e59..aabc390701ad 100644 --- a/stubs/networkx/networkx/generators/geometric.pyi +++ b/stubs/networkx/networkx/generators/geometric.pyi @@ -32,6 +32,7 @@ def waxman_graph( metric: Incomplete | None = None, seed: Incomplete | None = None, ): ... + # docstring marks p as int, but it still works with floats. So I think it's better for consistency def navigable_small_world_graph(n, p: float = 1, q: int = 1, r: float = 2, dim: int = 2, seed: Incomplete | None = None): ... def thresholded_random_geometric_graph( From ddcb1b5d992806ae4286b19e5307acb2a182b7b6 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 28 Nov 2023 18:58:14 -0500 Subject: [PATCH 33/37] Fix imports and types after batch suggestions --- stubs/networkx/networkx/algorithms/boundary.pyi | 2 +- stubs/networkx/networkx/algorithms/bridges.pyi | 6 +++--- stubs/networkx/networkx/algorithms/chains.pyi | 1 + stubs/networkx/networkx/algorithms/chordal.pyi | 3 ++- .../algorithms/components/strongly_connected.pyi | 2 +- .../algorithms/components/weakly_connected.pyi | 2 +- .../algorithms/connectivity/edge_augmentation.pyi | 2 +- stubs/networkx/networkx/algorithms/planarity.pyi | 1 + .../networkx/algorithms/shortest_paths/generic.pyi | 1 + stubs/networkx/networkx/algorithms/simple_paths.pyi | 2 +- .../algorithms/traversal/depth_first_search.pyi | 1 + stubs/networkx/networkx/algorithms/tree/branchings.pyi | 3 ++- stubs/networkx/networkx/algorithms/tree/mst.pyi | 3 ++- stubs/networkx/networkx/classes/function.pyi | 10 ++++++---- stubs/networkx/networkx/classes/graph.pyi | 2 +- stubs/networkx/networkx/classes/reportviews.pyi | 2 +- stubs/networkx/networkx/convert_matrix.pyi | 2 +- stubs/networkx/networkx/drawing/nx_agraph.pyi | 4 +--- .../networkx/networkx/generators/random_clustered.pyi | 2 ++ stubs/networkx/networkx/readwrite/graphml.pyi | 9 +++++---- stubs/networkx/networkx/readwrite/text.pyi | 1 + 21 files changed, 36 insertions(+), 25 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/boundary.pyi b/stubs/networkx/networkx/algorithms/boundary.pyi index 6bc0fb158b2b..db55d6db8566 100644 --- a/stubs/networkx/networkx/algorithms/boundary.pyi +++ b/stubs/networkx/networkx/algorithms/boundary.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Iterable +from collections.abc import Generator, Iterable from typing import TypeVar, overload from typing_extensions import Literal diff --git a/stubs/networkx/networkx/algorithms/bridges.pyi b/stubs/networkx/networkx/algorithms/bridges.pyi index 6a1667b8c239..c528d29fa6c9 100644 --- a/stubs/networkx/networkx/algorithms/bridges.pyi +++ b/stubs/networkx/networkx/algorithms/bridges.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Callable +from collections.abc import Callable, Generator from typing import overload from typing_extensions import Literal @@ -10,8 +10,8 @@ def has_bridges(G: Graph[_Node], root: Incomplete | None = None) -> bool: ... @overload def local_bridges( G: Graph[_Node], with_span: Literal[False], weight: str | Callable[[_Node], float] | None = None -) -> Generator[tuple[_Node, _Node], Node, Node]: ... +) -> Generator[tuple[_Node, _Node], None, None]: ... @overload def local_bridges( G: Graph[_Node], with_span: Literal[True] = True, weight: str | Callable[[_Node], float] | None = None -) -> Generator[tuple[_Node, _Node, int], Node, Node]: ... +) -> Generator[tuple[_Node, _Node, int], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/chains.pyi b/stubs/networkx/networkx/algorithms/chains.pyi index 173998730462..03249f994e6e 100644 --- a/stubs/networkx/networkx/algorithms/chains.pyi +++ b/stubs/networkx/networkx/algorithms/chains.pyi @@ -1,3 +1,4 @@ +from collections.abc import Generator from networkx.classes.graph import Graph, _Node diff --git a/stubs/networkx/networkx/algorithms/chordal.pyi b/stubs/networkx/networkx/algorithms/chordal.pyi index 949771ab744d..2f2fde3a19ca 100644 --- a/stubs/networkx/networkx/algorithms/chordal.pyi +++ b/stubs/networkx/networkx/algorithms/chordal.pyi @@ -1,4 +1,5 @@ -from collections.abc import Hashable +import sys +from collections.abc import Generator, Hashable from networkx.classes.graph import Graph, _Node from networkx.exception import NetworkXException diff --git a/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi index 4403ddfeea62..99f557ff6b98 100644 --- a/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi @@ -1,4 +1,4 @@ -from collections.abc import Hashable, Iterable +from collections.abc import Generator, Hashable, Iterable from typing import TypeVar from networkx.classes.digraph import DiGraph diff --git a/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi b/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi index 58e8f403a259..e10645e432ec 100644 --- a/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi @@ -1,4 +1,4 @@ -from collections.abc import Hashable +from collections.abc import Generator, Hashable from typing import TypeVar from networkx.classes.graph import Graph diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi index 05e9c16a188b..7e73c86a0d20 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -1,4 +1,4 @@ -from collections.abc import Hashable +from collections.abc import Generator, Hashable from typing import TypeVar from networkx.classes.graph import Graph diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index cbcd667d1498..5447e684876a 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Generator, Mapping, MutableSet, Reversible from typing import Generic, TypeVar from networkx.classes.digraph import DiGraph diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi index 84c7411bc765..22f6c2dbec28 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Generator from typing import TypeVar, overload from networkx.classes.graph import Graph diff --git a/stubs/networkx/networkx/algorithms/simple_paths.pyi b/stubs/networkx/networkx/algorithms/simple_paths.pyi index 41575a4c630f..1d4ad7fe96ea 100644 --- a/stubs/networkx/networkx/algorithms/simple_paths.pyi +++ b/stubs/networkx/networkx/algorithms/simple_paths.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Generator, Sequence from typing import TypeVar from networkx.classes.graph import Graph diff --git a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi index df5e1d6ab353..bbe263f6a22f 100644 --- a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Generator from typing import TypeVar from networkx.classes.graph import Graph diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi index 11550dcd4263..b1e75121219d 100644 --- a/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete from collections.abc import Iterator +from dataclasses import dataclass from typing import Generic from networkx.classes.graph import _Node @@ -60,7 +61,7 @@ def minimum_spanning_arborescence( ): ... class ArborescenceIterator: - @dataclass(order=True) + @dataclass class Partition: mst_weight: float partition_dict: dict[Incomplete, Incomplete] diff --git a/stubs/networkx/networkx/algorithms/tree/mst.pyi b/stubs/networkx/networkx/algorithms/tree/mst.pyi index 9407954fb2d7..5ab610c6965f 100644 --- a/stubs/networkx/networkx/algorithms/tree/mst.pyi +++ b/stubs/networkx/networkx/algorithms/tree/mst.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete from collections.abc import Iterator +from dataclasses import dataclass from enum import Enum class EdgePartition(Enum): @@ -21,7 +22,7 @@ def maximum_spanning_tree(G, weight: str = "weight", algorithm: str = "kruskal", def random_spanning_tree(G, weight: Incomplete | None = None, *, multiplicative: bool = True, seed: Incomplete | None = None): ... class SpanningTreeIterator: - @dataclass(order=True) + @dataclass class Partition: mst_weight: float partition_dict: dict[Incomplete, Incomplete] diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index ab91eecbee25..36c6f7805e8c 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -1,9 +1,9 @@ from _typeshed import Incomplete -from collections.abc import Hashable, Iterable +from collections.abc import Generator, Hashable, Iterator from typing import TypeVar, overload from typing_extensions import Literal -from networkx.classes.graph import Graph +from networkx.classes.graph import Graph, _NBunch from networkx.classes.graphviews import reverse_view as reverse_view, subgraph_view as subgraph_view __all__ = [ @@ -104,11 +104,13 @@ def selfloop_edges( G: Graph[_T], data: str, keys: Literal[False] = False, default: _U | None = None ) -> Generator[tuple[_T, _T, _U], None, None]: ... @overload -def selfloop_edges(G: Graph[_T], data: Literal[False], keys: Literal[True], default=None) -> Generator[tuple[_T, _T, int], None, None]: ... +def selfloop_edges( + G: Graph[_T], data: Literal[False], keys: Literal[True], default=None +) -> Generator[tuple[_T, _T, int], None, None]: ... @overload def selfloop_edges( G: Graph[_T], data: Literal[False] = False, *, keys: Literal[True], default=None -) -> Generator[tuple[_T, _T, int]], None, None]: ... +) -> Generator[tuple[_T, _T, int], None, None]: ... @overload def selfloop_edges( G: Graph[_T], data: Literal[True], keys: Literal[True], default=None diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi index d27c2cb1bc8b..f1dce7854c16 100644 --- a/stubs/networkx/networkx/classes/graph.pyi +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -3,7 +3,7 @@ from collections.abc import Callable, Collection, Hashable, Iterable, Iterator, from typing import ClassVar, Generic, TypeVar, overload from typing_extensions import Self, TypeAlias -from networkx.classes.coreviews import AdjacencyView +from networkx.classes.coreviews import AdjacencyView, AtlasView from networkx.classes.digraph import DiGraph from networkx.classes.reportviews import DiDegreeView, NodeView, OutEdgeView from networkx.convert import _Data diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index 8c11b1881208..74077f4b5e89 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -23,7 +23,7 @@ class NodeView(Mapping[_Node, _Node], AbstractSet[_Node]): class NodeDataView(AbstractSet[_Node]): def __init__(self, nodedict: Mapping[str, Incomplete], data: bool | str = False, default: Incomplete = None) -> None: ... def __len__(self) -> int: ... - def __iter__(self) -> Iterator[tuple[_Node, Incomplete]]: ... + def __iter__(self) -> Iterator[tuple[_Node, Incomplete]]: ... # type: ignore[override] def __contains__(self, n: object) -> bool: ... def __getitem__(self, n: _Node): ... diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index 9e775dec850b..6b846efbc501 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Callable, Iterable +from collections.abc import Callable, Collection, Hashable, Iterable from typing import TypeVar, overload from typing_extensions import Literal, TypeAlias diff --git a/stubs/networkx/networkx/drawing/nx_agraph.pyi b/stubs/networkx/networkx/drawing/nx_agraph.pyi index 0b91cbba467a..f84b3ee180b3 100644 --- a/stubs/networkx/networkx/drawing/nx_agraph.pyi +++ b/stubs/networkx/networkx/drawing/nx_agraph.pyi @@ -1,14 +1,12 @@ from _typeshed import Incomplete from collections.abc import Callable, Hashable from io import TextIOBase -from typing import TypeVar from typing_extensions import TypeAlias -from networkx.classes.graph import Graph +from networkx.classes.graph import Graph, _Node # from pygraphviz.agraph import AGraph as _AGraph _AGraph: TypeAlias = Incomplete -_T = TypeVar("_T") def from_agraph(A, create_using: Incomplete | None = None) -> Graph[Incomplete]: ... def to_agraph(N: Graph[Hashable]) -> _AGraph: ... diff --git a/stubs/networkx/networkx/generators/random_clustered.pyi b/stubs/networkx/networkx/generators/random_clustered.pyi index 2cb62c77716a..348511fe2a5d 100644 --- a/stubs/networkx/networkx/generators/random_clustered.pyi +++ b/stubs/networkx/networkx/generators/random_clustered.pyi @@ -1,6 +1,8 @@ +from collections.abc import Iterable from typing import Any, TypeVar, overload from networkx import MultiGraph +from networkx.classes.graph import Graph _G = TypeVar("_G", bound=Graph[int]) diff --git a/stubs/networkx/networkx/readwrite/graphml.pyi b/stubs/networkx/networkx/readwrite/graphml.pyi index bfe67ab4731b..6771f6e1c0c1 100644 --- a/stubs/networkx/networkx/readwrite/graphml.pyi +++ b/stubs/networkx/networkx/readwrite/graphml.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete from collections.abc import Generator +from typing_extensions import Final __all__ = [ "write_graphml", @@ -41,10 +42,10 @@ def read_graphml(path, node_type=..., edge_key_type=..., force_multigraph: bool def parse_graphml(graphml_string, node_type=..., edge_key_type=..., force_multigraph: bool = False): ... class GraphML: - NS_GRAPHML: Literal[str] - NS_XSI: Literal[str] - NS_Y: Literal[str] - SCHEMALOCATION: Literal[str] + NS_GRAPHML: Final[str] + NS_XSI: Final[str] + NS_Y: Final[str] + SCHEMALOCATION: Final[str] xml_type: Incomplete python_type: Incomplete def construct_types(self) -> None: ... diff --git a/stubs/networkx/networkx/readwrite/text.pyi b/stubs/networkx/networkx/readwrite/text.pyi index 5da7380e3799..9bd43b819728 100644 --- a/stubs/networkx/networkx/readwrite/text.pyi +++ b/stubs/networkx/networkx/readwrite/text.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete from collections.abc import Generator +from typing import ClassVar __all__ = ["forest_str", "generate_network_text", "write_network_text"] From ea04db6b80bf85d17f5400c38b0fb06a3e5cca37 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 28 Nov 2023 19:07:56 -0500 Subject: [PATCH 34/37] Fix new Y059, Y060 violations --- .../networkx/algorithms/planarity.pyi | 4 +-- .../networkx/algorithms/tree/branchings.pyi | 3 +- stubs/networkx/networkx/classes/coreviews.pyi | 24 ++++++------- stubs/networkx/networkx/classes/digraph.pyi | 3 +- stubs/networkx/networkx/classes/graph.pyi | 4 +-- .../networkx/networkx/classes/multigraph.pyi | 3 +- .../networkx/networkx/classes/reportviews.pyi | 34 +++++++++---------- 7 files changed, 36 insertions(+), 39 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index 5447e684876a..c53a5ae115ed 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from collections.abc import Generator, Mapping, MutableSet, Reversible -from typing import Generic, TypeVar +from typing import TypeVar from networkx.classes.digraph import DiGraph @@ -59,7 +59,7 @@ class LRPlanarity: def sign(self, e): ... def sign_recursive(self, e): ... -class PlanarEmbedding(Generic[_N], DiGraph[_N]): +class PlanarEmbedding(DiGraph[_N]): def get_data(self) -> dict[_N, list[_N]]: ... def set_data(self, data: Mapping[_N, Reversible[_N]]) -> None: ... def neighbors_cw_order(self, v: _N) -> Generator[_N, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi index b1e75121219d..4d4e5bcfe228 100644 --- a/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -1,7 +1,6 @@ from _typeshed import Incomplete from collections.abc import Iterator from dataclasses import dataclass -from typing import Generic from networkx.classes.graph import _Node from networkx.classes.multidigraph import MultiDiGraph @@ -20,7 +19,7 @@ __all__ = [ def branching_weight(G, attr: str = "weight", default: float = 1): ... def greedy_branching(G, attr: str = "weight", default: float = 1, kind: str = "max", seed: Incomplete | None = None): ... -class MultiDiGraph_EdgeKey(MultiDiGraph[_Node], Generic[_Node]): +class MultiDiGraph_EdgeKey(MultiDiGraph[_Node]): edge_index: Incomplete def __init__(self, incoming_graph_data: Incomplete | None = None, **attr) -> None: ... def remove_node(self, n) -> None: ... diff --git a/stubs/networkx/networkx/classes/coreviews.pyi b/stubs/networkx/networkx/classes/coreviews.pyi index 61fc4a6e941f..15afbf5cf573 100644 --- a/stubs/networkx/networkx/classes/coreviews.pyi +++ b/stubs/networkx/networkx/classes/coreviews.pyi @@ -1,46 +1,46 @@ from collections.abc import Callable, Iterator, Mapping -from typing import Generic, TypeVar +from typing import TypeVar from typing_extensions import Self _T = TypeVar("_T") _U = TypeVar("_U") _V = TypeVar("_V") -class AtlasView(Mapping[_T, dict[_U, _V]], Generic[_T, _U, _V]): +class AtlasView(Mapping[_T, dict[_U, _V]]): def __init__(self, d: Mapping[_T, dict[_U, _V]]) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_T]: ... def __getitem__(self, key: _T) -> dict[_U, _V]: ... def copy(self) -> Self: ... -class AdjacencyView(AtlasView[_T, _U, _V], Generic[_T, _U, _V]): ... -class MultiAdjacencyView(AdjacencyView[_T, _U, _V], Generic[_T, _U, _V]): ... +class AdjacencyView(AtlasView[_T, _U, _V]): ... +class MultiAdjacencyView(AdjacencyView[_T, _U, _V]): ... -class UnionAtlas(Mapping[_T, dict[_U, _V]], Generic[_T, _U, _V]): +class UnionAtlas(Mapping[_T, dict[_U, _V]]): def __init__(self, succ: AtlasView[_T, _U, _V], pred: AtlasView[_T, _U, _V]) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_T]: ... def __getitem__(self, key: _T) -> dict[_U, _V]: ... def copy(self) -> Self: ... -class UnionAdjacency(Mapping[_T, dict[_U, _V]], Generic[_T, _U, _V]): +class UnionAdjacency(Mapping[_T, dict[_U, _V]]): def __init__(self, succ: AdjacencyView[_T, _U, _V], pred: AdjacencyView[_T, _U, _V]) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_T]: ... def __getitem__(self, key: _T) -> dict[_U, _V]: ... def copy(self) -> Self: ... -class UnionMultiInner(UnionAtlas[_T, _U, _V], Generic[_T, _U, _V]): ... -class UnionMultiAdjacency(UnionAdjacency[_T, _U, _V], Generic[_T, _U, _V]): ... +class UnionMultiInner(UnionAtlas[_T, _U, _V]): ... +class UnionMultiAdjacency(UnionAdjacency[_T, _U, _V]): ... -class FilterAtlas(Mapping[_T, _U], Generic[_T, _U]): +class FilterAtlas(Mapping[_T, _U]): NODE_OK: Callable[[_T], bool] def __init__(self, d: Mapping[_T, _U], NODE_OK: Callable[[_T], bool]) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator[_T]: ... def __getitem__(self, key: _T) -> _U: ... -class FilterAdjacency(Mapping[_T, Mapping[_U, _V]], Generic[_T, _U, _V]): +class FilterAdjacency(Mapping[_T, Mapping[_U, _V]]): NODE_OK: Callable[[_T], bool] EDGE_OK: Callable[[_T, _T], bool] def __init__( @@ -50,5 +50,5 @@ class FilterAdjacency(Mapping[_T, Mapping[_U, _V]], Generic[_T, _U, _V]): def __iter__(self): ... def __getitem__(self, node: _T) -> FilterAtlas[_U, _V]: ... -class FilterMultiInner(FilterAdjacency[_T, _U, _V], Generic[_T, _U, _V]): ... -class FilterMultiAdjacency(FilterAdjacency[_T, _U, _V], Generic[_T, _U, _V]): ... +class FilterMultiInner(FilterAdjacency[_T, _U, _V]): ... +class FilterMultiAdjacency(FilterAdjacency[_T, _U, _V]): ... diff --git a/stubs/networkx/networkx/classes/digraph.pyi b/stubs/networkx/networkx/classes/digraph.pyi index b229b020b44d..1636f6307c5d 100644 --- a/stubs/networkx/networkx/classes/digraph.pyi +++ b/stubs/networkx/networkx/classes/digraph.pyi @@ -1,6 +1,5 @@ from _typeshed import Incomplete from collections.abc import Iterator -from typing import Generic from networkx.classes.coreviews import AdjacencyView from networkx.classes.graph import Graph, _Node @@ -13,7 +12,7 @@ from networkx.classes.reportviews import ( OutMultiDegreeView, ) -class DiGraph(Graph[_Node], Generic[_Node]): +class DiGraph(Graph[_Node]): succ: AdjacencyView[_Node, _Node, dict[str, Incomplete]] pred: AdjacencyView[_Node, _Node, dict[str, Incomplete]] def has_successor(self, u: _Node, v: _Node) -> bool: ... diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi index f1dce7854c16..ba9049a23fd6 100644 --- a/stubs/networkx/networkx/classes/graph.pyi +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from collections.abc import Callable, Collection, Hashable, Iterable, Iterator, Mapping, MutableMapping -from typing import ClassVar, Generic, TypeVar, overload +from typing import ClassVar, TypeVar, overload from typing_extensions import Self, TypeAlias from networkx.classes.coreviews import AdjacencyView, AtlasView @@ -14,7 +14,7 @@ _EdgePlus: TypeAlias = _Edge[_Node] | tuple[_Node, _Node, dict[str, Incomplete]] _MapFactory: TypeAlias = Callable[[], MutableMapping[str, Incomplete]] _NBunch: TypeAlias = _Node | Iterable[_Node] | None -class Graph(Collection[_Node], Generic[_Node]): +class Graph(Collection[_Node]): node_dict_factory: ClassVar[_MapFactory] = ... node_attr_dict_factory: ClassVar[_MapFactory] = ... adjlist_outer_dict_factory: ClassVar[_MapFactory] = ... diff --git a/stubs/networkx/networkx/classes/multigraph.pyi b/stubs/networkx/networkx/classes/multigraph.pyi index ac96f7fd6e90..9462bd64cf64 100644 --- a/stubs/networkx/networkx/classes/multigraph.pyi +++ b/stubs/networkx/networkx/classes/multigraph.pyi @@ -1,5 +1,4 @@ from _typeshed import Incomplete -from typing import Generic from typing_extensions import TypeAlias from networkx.classes.graph import Graph, _Node @@ -7,7 +6,7 @@ from networkx.classes.multidigraph import MultiDiGraph _MultiEdge: TypeAlias = tuple[_Node, _Node, int] # noqa: Y047 -class MultiGraph(Graph[_Node], Generic[_Node]): +class MultiGraph(Graph[_Node]): def __init__(self, incoming_graph_data: Incomplete | None = None, multigraph_input: bool | None = None, **attr) -> None: ... 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 diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index 74077f4b5e89..ae28f0c060ef 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -34,13 +34,13 @@ class DiDegreeView(Generic[_Node]): def __iter__(self) -> Iterator[tuple[_Node, float]]: ... def __len__(self) -> int: ... -class DegreeView(DiDegreeView[_Node], Generic[_Node]): ... -class OutDegreeView(DiDegreeView[_Node], Generic[_Node]): ... -class InDegreeView(DiDegreeView[_Node], Generic[_Node]): ... -class MultiDegreeView(DiDegreeView[_Node], Generic[_Node]): ... -class DiMultiDegreeView(DiDegreeView[_Node], Generic[_Node]): ... -class InMultiDegreeView(DiDegreeView[_Node], Generic[_Node]): ... -class OutMultiDegreeView(DiDegreeView[_Node], Generic[_Node]): ... +class DegreeView(DiDegreeView[_Node]): ... +class OutDegreeView(DiDegreeView[_Node]): ... +class InDegreeView(DiDegreeView[_Node]): ... +class MultiDegreeView(DiDegreeView[_Node]): ... +class DiMultiDegreeView(DiDegreeView[_Node]): ... +class InMultiDegreeView(DiDegreeView[_Node]): ... +class OutMultiDegreeView(DiDegreeView[_Node]): ... class OutEdgeDataView(Generic[_Node, _D]): def __init__(self, viewer, nbunch: _NBunch[_Node] = None, data: bool = False, default: Incomplete | None = None) -> None: ... @@ -48,16 +48,16 @@ class OutEdgeDataView(Generic[_Node, _D]): def __iter__(self) -> Iterator[_D]: ... def __contains__(self, e: _Edge[_Node]) -> bool: ... -class EdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): ... -class InEdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): ... +class EdgeDataView(OutEdgeDataView[_Node, _D]): ... +class InEdgeDataView(OutEdgeDataView[_Node, _D]): ... -class OutMultiEdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): +class OutMultiEdgeDataView(OutEdgeDataView[_Node, _D]): def __init__( self, viewer, nbunch: _NBunch[_Node] = None, data: bool = False, keys: bool = False, default: Incomplete | None = None ) -> None: ... -class MultiEdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): ... -class InMultiEdgeDataView(OutEdgeDataView[_Node, _D], Generic[_Node, _D]): ... +class MultiEdgeDataView(OutEdgeDataView[_Node, _D]): ... +class InMultiEdgeDataView(OutEdgeDataView[_Node, _D]): ... class OutEdgeView(AbstractSet[Incomplete], Mapping[Incomplete, Incomplete], Generic[_Node]): def __init__(self, G: Graph[_Node]) -> None: ... @@ -94,10 +94,10 @@ class OutEdgeView(AbstractSet[Incomplete], Mapping[Incomplete, Incomplete], Gene self, data: str, default: _U | None = None, nbunch: _NBunch[_Node] = None ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... -class EdgeView(OutEdgeView[_Node], Generic[_Node]): ... -class InEdgeView(OutEdgeView[_Node], Generic[_Node]): ... +class EdgeView(OutEdgeView[_Node]): ... +class InEdgeView(OutEdgeView[_Node]): ... -class OutMultiEdgeView(OutEdgeView[_Node], Generic[_Node]): +class OutMultiEdgeView(OutEdgeView[_Node]): @overload # type: ignore[override] # Has an additional `keys` keyword argument def __call__( self, nbunch: None = None, data: Literal[False] = False, *, keys: Literal[True], default: Unused = None @@ -131,5 +131,5 @@ class OutMultiEdgeView(OutEdgeView[_Node], Generic[_Node]): self, data: str, keys: bool = False, default: _U | None = None, nbunch: _NBunch[_Node] = None ) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... -class MultiEdgeView(OutMultiEdgeView[_Node], Generic[_Node]): ... -class InMultiEdgeView(OutMultiEdgeView[_Node], Generic[_Node]): ... +class MultiEdgeView(OutMultiEdgeView[_Node]): ... +class InMultiEdgeView(OutMultiEdgeView[_Node]): ... From f17307e251b2ce70e19f04d7783ec7e59a06dc87 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 28 Nov 2023 19:38:34 -0500 Subject: [PATCH 35/37] Reduce unbound TypeVar declarations, reuse _Node --- .../networkx/networkx/algorithms/boundary.pyi | 96 +++++++++++-------- .../components/strongly_connected.pyi | 13 +-- .../components/weakly_connected.pyi | 7 +- .../connectivity/edge_augmentation.pyi | 11 +-- stubs/networkx/networkx/algorithms/dag.pyi | 9 +- .../networkx/algorithms/operators/binary.pyi | 7 +- .../networkx/algorithms/operators/unary.pyi | 7 +- .../networkx/algorithms/planarity.pyi | 26 ++--- .../algorithms/shortest_paths/generic.pyi | 18 ++-- .../networkx/algorithms/simple_paths.pyi | 18 ++-- .../traversal/depth_first_search.pyi | 9 +- stubs/networkx/networkx/classes/function.pyi | 55 ++++++----- stubs/networkx/networkx/classes/graph.pyi | 10 +- stubs/networkx/networkx/convert.pyi | 31 +++--- stubs/networkx/networkx/relabel.pyi | 4 +- 15 files changed, 162 insertions(+), 159 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/boundary.pyi b/stubs/networkx/networkx/algorithms/boundary.pyi index db55d6db8566..10200a11b249 100644 --- a/stubs/networkx/networkx/algorithms/boundary.pyi +++ b/stubs/networkx/networkx/algorithms/boundary.pyi @@ -3,98 +3,112 @@ from collections.abc import Generator, Iterable from typing import TypeVar, overload from typing_extensions import Literal -from networkx.classes.graph import Graph +from networkx.classes.graph import Graph, _Node -_T = TypeVar("_T") _U = TypeVar("_U") @overload def edge_boundary( - G: Graph[_T], - nbunch1: Iterable[_T], - nbunch2: Iterable[_T] | None = None, + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None = None, data: Literal[False] = False, keys: Literal[False] = False, default=None, -) -> Generator[tuple[_T, _T], None, None]: ... +) -> Generator[tuple[_Node, _Node], None, None]: ... @overload def edge_boundary( - G: Graph[_T], - nbunch1: Iterable[_T], - nbunch2: Iterable[_T] | None, + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None, data: Literal[True], keys: Literal[False] = False, default=None, -) -> Generator[tuple[_T, _T, dict[str, Incomplete]], None, None]: ... +) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( - G: Graph[_T], - nbunch1: Iterable[_T], - nbunch2: Iterable[_T] | None = None, + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None = None, *, data: Literal[True], keys: Literal[False] = False, default=None, -) -> Generator[tuple[_T, _T, dict[str, Incomplete]], None, None]: ... +) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( - G: Graph[_T], - nbunch1: Iterable[_T], - nbunch2: Iterable[_T] | None, + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None, data: str, keys: Literal[False] = False, default: _U | None = None, -) -> Generator[tuple[_T, _T, dict[str, _U]], None, None]: ... +) -> Generator[tuple[_Node, _Node, dict[str, _U]], None, None]: ... @overload def edge_boundary( - G: Graph[_T], - nbunch1: Iterable[_T], - nbunch2: Iterable[_T] | None = None, + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None = None, *, data: str, keys: Literal[False] = False, default: _U | None = None, -) -> Generator[tuple[_T, _T, dict[str, _U]], None, None]: ... +) -> Generator[tuple[_Node, _Node, dict[str, _U]], None, None]: ... @overload def edge_boundary( - G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None, data: Literal[False], keys: Literal[True], default=None -) -> Generator[tuple[_T, _T, int], None, None]: ... + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None, + data: Literal[False], + keys: Literal[True], + default=None, +) -> Generator[tuple[_Node, _Node, int], None, None]: ... @overload def edge_boundary( - G: Graph[_T], - nbunch1: Iterable[_T], - nbunch2: Iterable[_T] | None = None, + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None = None, data: Literal[False] = False, *, keys: Literal[True], default=None, -) -> Generator[tuple[_T, _T, int], None, None]: ... +) -> Generator[tuple[_Node, _Node, int], None, None]: ... @overload def edge_boundary( - G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None, data: Literal[True], keys: Literal[True], default=None -) -> Generator[tuple[_T, _T, int, dict[str, Incomplete]], None, None]: ... + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None, + data: Literal[True], + keys: Literal[True], + default=None, +) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( - G: Graph[_T], - nbunch1: Iterable[_T], - nbunch2: Iterable[_T] | None = None, + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None = None, *, data: Literal[True], keys: Literal[True], default=None, -) -> Generator[tuple[_T, _T, int, dict[str, Incomplete]], None, None]: ... +) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ... @overload def edge_boundary( - G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None, data: str, keys: Literal[True], default: _U | None = None -) -> Generator[tuple[_T, _T, int, dict[str, _U]], None, None]: ... + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None, + data: str, + keys: Literal[True], + default: _U | None = None, +) -> Generator[tuple[_Node, _Node, int, dict[str, _U]], None, None]: ... @overload def edge_boundary( - G: Graph[_T], - nbunch1: Iterable[_T], - nbunch2: Iterable[_T] | None = None, + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None = None, *, data: str, keys: Literal[True], default: _U | None = None, -) -> Generator[tuple[_T, _T, int, dict[str, _U]], None, None]: ... -def node_boundary(G: Graph[_T], nbunch1: Iterable[_T], nbunch2: Iterable[_T] | None = None) -> set[_T]: ... +) -> Generator[tuple[_Node, _Node, int, dict[str, _U]], None, None]: ... +def node_boundary(G: Graph[_Node], nbunch1: Iterable[_Node], nbunch2: Iterable[_Node] | None = None) -> set[_Node]: ... diff --git a/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi index 99f557ff6b98..27c58b9280df 100644 --- a/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi @@ -1,14 +1,11 @@ from collections.abc import Generator, Hashable, Iterable -from typing import TypeVar from networkx.classes.digraph import DiGraph -from networkx.classes.graph import Graph +from networkx.classes.graph import Graph, _Node -_N = TypeVar("_N") - -def strongly_connected_components(G: Graph[_N]) -> Generator[set[_N], None, None]: ... -def kosaraju_strongly_connected_components(G: Graph[_N], source: _N | None = None) -> Generator[set[_N], None, None]: ... -def strongly_connected_components_recursive(G: Graph[_N]) -> Generator[set[_N], None, None]: ... +def strongly_connected_components(G: Graph[_Node]) -> Generator[set[_Node], None, None]: ... +def kosaraju_strongly_connected_components(G: Graph[_Node], source: _Node | None = None) -> Generator[set[_Node], None, None]: ... +def strongly_connected_components_recursive(G: Graph[_Node]) -> Generator[set[_Node], None, None]: ... def number_strongly_connected_components(G: Graph[Hashable]) -> int: ... def is_strongly_connected(G: Graph[Hashable]) -> bool: ... -def condensation(G: DiGraph[_N], scc: Iterable[Iterable[_N]] | None = None) -> DiGraph[int]: ... +def condensation(G: DiGraph[_Node], scc: Iterable[Iterable[_Node]] | None = None) -> DiGraph[int]: ... diff --git a/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi b/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi index e10645e432ec..04f5c555e572 100644 --- a/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi +++ b/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi @@ -1,10 +1,7 @@ from collections.abc import Generator, Hashable -from typing import TypeVar -from networkx.classes.graph import Graph +from networkx.classes.graph import Graph, _Node -_N = TypeVar("_N") - -def weakly_connected_components(G: Graph[_N]) -> Generator[set[_N], None, None]: ... +def weakly_connected_components(G: Graph[_Node]) -> Generator[set[_Node], None, None]: ... def number_weakly_connected_components(G: Graph[Hashable]) -> int: ... def is_weakly_connected(G: Graph[Hashable]) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi index 7e73c86a0d20..0608747f127e 100644 --- a/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -1,16 +1,13 @@ from collections.abc import Generator, Hashable -from typing import TypeVar -from networkx.classes.graph import Graph - -_N = TypeVar("_N") +from networkx.classes.graph import Graph, _Node def is_k_edge_connected(G: Graph[Hashable], k: int): ... def is_locally_k_edge_connected(G, s, t, k): ... def k_edge_augmentation( - G: Graph[_N], + G: Graph[_Node], k: int, - avail: tuple[_N, _N] | tuple[_N, _N, dict[str, int]] | None = None, + avail: tuple[_Node, _Node] | tuple[_Node, _Node, dict[str, int]] | None = None, weight: str | None = None, partial: bool = False, -) -> Generator[tuple[_N, _N], None, None]: ... +) -> Generator[tuple[_Node, _Node], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/dag.pyi b/stubs/networkx/networkx/algorithms/dag.pyi index 590244fa0d6f..0ad382b98b3c 100644 --- a/stubs/networkx/networkx/algorithms/dag.pyi +++ b/stubs/networkx/networkx/algorithms/dag.pyi @@ -1,12 +1,9 @@ from _typeshed import Incomplete -from typing import TypeVar -from networkx.classes.graph import Graph +from networkx.classes.graph import Graph, _Node -_T = TypeVar("_T") - -def descendants(G: Graph[_T], source: _T) -> set[_T]: ... -def ancestors(G: Graph[_T], source: _T) -> set[_T]: ... +def descendants(G: Graph[_Node], source: _Node) -> set[_Node]: ... +def ancestors(G: Graph[_Node], source: _Node) -> set[_Node]: ... def is_directed_acyclic_graph(G): ... def topological_sort(G) -> None: ... def lexicographical_topological_sort(G, key: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/algorithms/operators/binary.pyi b/stubs/networkx/networkx/algorithms/operators/binary.pyi index 8944c3046a2f..37cf06498b4c 100644 --- a/stubs/networkx/networkx/algorithms/operators/binary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/binary.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Hashable from typing import TypeVar from networkx.classes.digraph import DiGraph @@ -8,9 +9,9 @@ def intersection(G, H): ... def difference(G, H): ... def symmetric_difference(G, H): ... -_X = TypeVar("_X", covariant=True) -_Y = TypeVar("_Y", covariant=True) -# GT = TypeVar('GT', bound=Graph) +_X = TypeVar("_X", bound=Hashable, covariant=True) +_Y = TypeVar("_Y", bound=Hashable, covariant=True) +# GT = TypeVar('GT', bound=Graph[_Node]) # TODO: This does not handle the cases when graphs of different types are passed which is allowed def compose(G: DiGraph[_X], H: DiGraph[_Y]) -> DiGraph[_X | _Y]: ... diff --git a/stubs/networkx/networkx/algorithms/operators/unary.pyi b/stubs/networkx/networkx/algorithms/operators/unary.pyi index 942c2ae6c41e..e4d2985a71e5 100644 --- a/stubs/networkx/networkx/algorithms/operators/unary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/unary.pyi @@ -1,8 +1,5 @@ -from typing import TypeVar - from networkx.classes.digraph import DiGraph - -_T = TypeVar("_T") +from networkx.classes.graph import _Node def complement(G): ... -def reverse(G: DiGraph[_T], copy: bool = True) -> DiGraph[_T]: ... +def reverse(G: DiGraph[_Node], copy: bool = True) -> DiGraph[_Node]: ... diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index c53a5ae115ed..5c6886ff7b95 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -1,13 +1,11 @@ from _typeshed import Incomplete from collections.abc import Generator, Mapping, MutableSet, Reversible -from typing import TypeVar from networkx.classes.digraph import DiGraph +from networkx.classes.graph import _Node __all__ = ["check_planarity", "is_planar", "PlanarEmbedding"] -_N = TypeVar("_N") - def is_planar(G) -> bool: ... def check_planarity(G, counterexample: bool = False): ... @@ -59,15 +57,17 @@ class LRPlanarity: def sign(self, e): ... def sign_recursive(self, e): ... -class PlanarEmbedding(DiGraph[_N]): - def get_data(self) -> dict[_N, list[_N]]: ... - def set_data(self, data: Mapping[_N, Reversible[_N]]) -> None: ... - def neighbors_cw_order(self, v: _N) -> Generator[_N, None, None]: ... +class PlanarEmbedding(DiGraph[_Node]): + def get_data(self) -> dict[_Node, list[_Node]]: ... + def set_data(self, data: Mapping[_Node, Reversible[_Node]]) -> None: ... + def neighbors_cw_order(self, v: _Node) -> Generator[_Node, None, None]: ... def check_structure(self) -> None: ... - def add_half_edge_ccw(self, start_node: _N, end_node: _N, reference_neighbor: _N) -> None: ... - def add_half_edge_cw(self, start_node: _N, end_node: _N, reference_neighbor: _N) -> None: ... - def connect_components(self, v: _N, w: _N) -> None: ... - def add_half_edge_first(self, start_node: _N, end_node: _N) -> None: ... - def next_face_half_edge(self, v: _N, w: _N) -> tuple[_N, _N]: ... - def traverse_face(self, v: _N, w: _N, mark_half_edges: MutableSet[tuple[_N, _N]] | None = None) -> list[_N]: ... + def add_half_edge_ccw(self, start_node: _Node, end_node: _Node, reference_neighbor: _Node) -> None: ... + def add_half_edge_cw(self, start_node: _Node, end_node: _Node, reference_neighbor: _Node) -> None: ... + def connect_components(self, v: _Node, w: _Node) -> None: ... + def add_half_edge_first(self, start_node: _Node, end_node: _Node) -> None: ... + def next_face_half_edge(self, v: _Node, w: _Node) -> tuple[_Node, _Node]: ... + def traverse_face( + self, v: _Node, w: _Node, mark_half_edges: MutableSet[tuple[_Node, _Node]] | None = None + ) -> list[_Node]: ... def is_directed(self) -> bool: ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi index 22f6c2dbec28..4c60b9483883 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi @@ -1,20 +1,18 @@ from _typeshed import Incomplete from collections.abc import Generator -from typing import TypeVar, overload +from typing import overload -from networkx.classes.graph import Graph - -_T = TypeVar("_T") +from networkx.classes.graph import Graph, _Node def has_path(G, source, target): ... @overload def shortest_path( - G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = None, method: str = "dijkstra" -) -> list[_T]: ... + G: Graph[_Node], source: _Node, target: _Node, weight: Incomplete | None = None, method: str = "dijkstra" +) -> list[_Node]: ... @overload -def shortest_path(G: Graph[_T], target: _T, method: str = "dijkstra") -> dict[_T, list[_T]]: ... +def shortest_path(G: Graph[_Node], target: _Node, method: str = "dijkstra") -> dict[_Node, list[_Node]]: ... @overload -def shortest_path(G: Graph[_T], source: _T, method: str = "dijkstra") -> dict[_T, list[_T]]: ... +def shortest_path(G: Graph[_Node], source: _Node, method: str = "dijkstra") -> dict[_Node, list[_Node]]: ... def shortest_path_length( G, source: Incomplete | None = None, @@ -24,5 +22,5 @@ def shortest_path_length( ): ... def average_shortest_path_length(G, weight: Incomplete | None = None, method: str | None = None): ... def all_shortest_paths( - G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = None, method: str = "dijkstra" -) -> Generator[list[_T], None, None]: ... + G: Graph[_Node], source: _Node, target: _Node, weight: Incomplete | None = None, method: str = "dijkstra" +) -> Generator[list[_Node], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/simple_paths.pyi b/stubs/networkx/networkx/algorithms/simple_paths.pyi index 1d4ad7fe96ea..46b3d643a5a4 100644 --- a/stubs/networkx/networkx/algorithms/simple_paths.pyi +++ b/stubs/networkx/networkx/algorithms/simple_paths.pyi @@ -1,22 +1,20 @@ from _typeshed import Incomplete from collections.abc import Generator, Sequence -from typing import TypeVar -from networkx.classes.graph import Graph +from networkx.classes.graph import Graph, _Node __all__ = ["all_simple_paths", "is_simple_path", "shortest_simple_paths", "all_simple_edge_paths"] -_T = TypeVar("_T") -def is_simple_path(G: Graph[_T], nodes: Sequence[_T]): ... +def is_simple_path(G: Graph[_Node], nodes: Sequence[_Node]): ... def all_simple_paths( - G: Graph[_T], source: _T, target: _T, cutoff: Incomplete | None = None -) -> Generator[list[_T], None, None]: ... + G: Graph[_Node], source: _Node, target: _Node, cutoff: Incomplete | None = None +) -> Generator[list[_Node], None, None]: ... def all_simple_edge_paths( - G: Graph[_T], source: _T, target: _T, cutoff: Incomplete | None = None -) -> Generator[list[_T] | list[tuple[_T, _T]], None, list[_T] | None]: ... + G: Graph[_Node], source: _Node, target: _Node, cutoff: Incomplete | None = None +) -> Generator[list[_Node] | list[tuple[_Node, _Node]], None, list[_Node] | None]: ... def shortest_simple_paths( - G: Graph[_T], source: _T, target: _T, weight: Incomplete | None = None -) -> Generator[list[_T], None, None]: ... + G: Graph[_Node], source: _Node, target: _Node, weight: Incomplete | None = None +) -> Generator[list[_Node], None, None]: ... class PathBuffer: paths: Incomplete diff --git a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi index bbe263f6a22f..f7bdc54f06c4 100644 --- a/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi +++ b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi @@ -1,12 +1,11 @@ from _typeshed import Incomplete from collections.abc import Generator -from typing import TypeVar -from networkx.classes.graph import Graph +from networkx.classes.graph import Graph, _Node -_T = TypeVar("_T") - -def dfs_edges(G: Graph[_T], source: _T | None = None, depth_limit: int | None = None) -> Generator[tuple[_T, _T], None, None]: ... +def dfs_edges( + G: Graph[_Node], source: _Node | None = None, depth_limit: int | None = None +) -> Generator[tuple[_Node, _Node], None, None]: ... def dfs_tree(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... def dfs_predecessors(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... def dfs_successors(G, source: Incomplete | None = None, depth_limit: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index 36c6f7805e8c..78d8b769c404 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -3,7 +3,7 @@ from collections.abc import Generator, Hashable, Iterator from typing import TypeVar, overload from typing_extensions import Literal -from networkx.classes.graph import Graph, _NBunch +from networkx.classes.graph import Graph, _NBunch, _Node from networkx.classes.graphviews import reverse_view as reverse_view, subgraph_view as subgraph_view __all__ = [ @@ -47,7 +47,6 @@ __all__ = [ "path_weight", "is_path", ] -_T = TypeVar("_T") _U = TypeVar("_U") def nodes(G): ... @@ -65,7 +64,7 @@ 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 induced_subgraph(G: Graph[_T], nbunch: _NBunch[_T]) -> Graph[_T]: ... +def induced_subgraph(G: Graph[_Node], nbunch: _NBunch[_Node]) -> Graph[_Node]: ... def edge_subgraph(G, edges): ... def restricted_view(G, nodes, edges): ... def to_directed(graph): ... @@ -76,49 +75,49 @@ def create_empty_copy(G, with_data: bool = True): ... @overload def set_node_attributes(G: Graph[Hashable], values, name: str) -> None: ... @overload -def set_node_attributes(G: Graph[_T], values: dict[_T, dict[Incomplete, Incomplete]], name: None = None) -> None: ... -def get_node_attributes(G: Graph[_T], name: str) -> dict[_T, Incomplete]: ... +def set_node_attributes(G: Graph[_Node], values: dict[_Node, dict[Incomplete, Incomplete]], name: None = None) -> None: ... +def get_node_attributes(G: Graph[_Node], name: str) -> dict[_Node, Incomplete]: ... @overload -def set_edge_attributes(G: Graph[_T], values: dict[tuple[_T, _T], Incomplete], name: str) -> None: ... +def set_edge_attributes(G: Graph[_Node], values: dict[tuple[_Node, _Node], Incomplete], name: str) -> None: ... @overload def set_edge_attributes(G: Graph[Hashable], values, name: None = None) -> None: ... -def get_edge_attributes(G: Graph[_T], name: str) -> dict[tuple[_T, _T], Incomplete]: ... -def all_neighbors(graph: Graph[_T], node: _T) -> Iterator[_T]: ... -def non_neighbors(graph: Graph[_T], node: _T) -> Generator[_T, None, None]: ... -def non_edges(graph: Graph[_T]) -> Generator[tuple[_T, _T], None, None]: ... -def common_neighbors(G: Graph[_T], u: _T, v: _T) -> Generator[_T, None, None]: ... -def is_weighted(G: Graph[_T], edge: tuple[_T, _T] | None = None, weight: str | None = "weight") -> bool: ... -def is_negatively_weighted(G: Graph[_T], edge: tuple[_T, _T] | None = None, weight: str | None = "weight"): ... +def get_edge_attributes(G: Graph[_Node], name: str) -> dict[tuple[_Node, _Node], Incomplete]: ... +def all_neighbors(graph: Graph[_Node], node: _Node) -> Iterator[_Node]: ... +def non_neighbors(graph: Graph[_Node], node: _Node) -> Generator[_Node, None, None]: ... +def non_edges(graph: Graph[_Node]) -> Generator[tuple[_Node, _Node], None, None]: ... +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 | None = "weight") -> bool: ... +def is_negatively_weighted(G: Graph[_Node], edge: tuple[_Node, _Node] | None = None, weight: str | None = "weight"): ... def is_empty(G: Graph[Hashable]) -> bool: ... -def nodes_with_selfloops(G: Graph[_T]) -> Generator[_T, None, None]: ... +def nodes_with_selfloops(G: Graph[_Node]) -> Generator[_Node, None, None]: ... @overload def selfloop_edges( - G: Graph[_T], data: Literal[False] = False, keys: Literal[False] = False, default=None -) -> Generator[tuple[_T, _T], None, None]: ... + G: Graph[_Node], data: Literal[False] = False, keys: Literal[False] = False, default=None +) -> Generator[tuple[_Node, _Node], None, None]: ... @overload def selfloop_edges( - G: Graph[_T], data: Literal[True], keys: Literal[False] = False, default=None -) -> Generator[tuple[_T, _T, dict[str, Incomplete]], None, None]: ... + G: Graph[_Node], data: Literal[True], keys: Literal[False] = False, default=None +) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ... @overload def selfloop_edges( - G: Graph[_T], data: str, keys: Literal[False] = False, default: _U | None = None -) -> Generator[tuple[_T, _T, _U], None, None]: ... + G: Graph[_Node], data: str, keys: Literal[False] = False, default: _U | None = None +) -> Generator[tuple[_Node, _Node, _U], None, None]: ... @overload def selfloop_edges( - G: Graph[_T], data: Literal[False], keys: Literal[True], default=None -) -> Generator[tuple[_T, _T, int], None, None]: ... + G: Graph[_Node], data: Literal[False], keys: Literal[True], default=None +) -> Generator[tuple[_Node, _Node, int], None, None]: ... @overload def selfloop_edges( - G: Graph[_T], data: Literal[False] = False, *, keys: Literal[True], default=None -) -> Generator[tuple[_T, _T, int], None, None]: ... + G: Graph[_Node], data: Literal[False] = False, *, keys: Literal[True], default=None +) -> Generator[tuple[_Node, _Node, int], None, None]: ... @overload def selfloop_edges( - G: Graph[_T], data: Literal[True], keys: Literal[True], default=None -) -> Generator[tuple[_T, _T, int, dict[str, Incomplete]], None, None]: ... + G: Graph[_Node], data: Literal[True], keys: Literal[True], default=None +) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ... @overload def selfloop_edges( - G: Graph[_T], data: str, keys: Literal[True], default: _U | None = None -) -> Generator[tuple[_T, _T, int, _U], None, None]: ... + 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: ... diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi index ba9049a23fd6..011e55862d90 100644 --- a/stubs/networkx/networkx/classes/graph.pyi +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -3,16 +3,24 @@ from collections.abc import Callable, Collection, Hashable, Iterable, Iterator, from typing import ClassVar, TypeVar, overload 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.convert import _Data _Node = TypeVar("_Node", bound=Hashable) _Edge: TypeAlias = tuple[_Node, _Node] _EdgePlus: TypeAlias = _Edge[_Node] | tuple[_Node, _Node, dict[str, Incomplete]] _MapFactory: TypeAlias = Callable[[], MutableMapping[str, Incomplete]] _NBunch: TypeAlias = _Node | Iterable[_Node] | None +_Data: TypeAlias = ( + Graph[_Node] + | dict[_Node, dict[_Node, dict[str, Incomplete]]] + | dict[_Node, Iterable[_Node]] + | Iterable[_EdgePlus[_Node]] + | numpy.ndarray[_Node, Incomplete] + # | scipy.sparse.base.spmatrix +) class Graph(Collection[_Node]): node_dict_factory: ClassVar[_MapFactory] = ... diff --git a/stubs/networkx/networkx/convert.pyi b/stubs/networkx/networkx/convert.pyi index 3da459bf1745..bb99e7e58bfe 100644 --- a/stubs/networkx/networkx/convert.pyi +++ b/stubs/networkx/networkx/convert.pyi @@ -1,18 +1,19 @@ from _typeshed import Incomplete -from collections.abc import Iterable -from typing_extensions import TypeAlias -import numpy +__all__ = [ + "to_networkx_graph", + "from_dict_of_dicts", + "to_dict_of_dicts", + "from_dict_of_lists", + "to_dict_of_lists", + "from_edgelist", + "to_edgelist", +] -# import scipy -from networkx.classes.graph import Graph, _EdgePlus, _Node - -# this is imported from other stub files -_Data: TypeAlias = ( # noqa: Y047 - Graph[_Node] - | dict[_Node, dict[_Node, dict[str, Incomplete]]] - | dict[_Node, Iterable[_Node]] - | Iterable[_EdgePlus[_Node]] - | numpy.ndarray[_Node, Incomplete] - # | scipy.sparse.base.spmatrix -) +def to_networkx_graph(data, create_using=None, multigraph_input=False): ... +def to_dict_of_lists(G, nodelist=None) -> dict[Incomplete, Incomplete]: ... +def from_dict_of_lists(d, create_using=None): ... +def to_dict_of_dicts(G, nodelist=None, edge_data=None) -> dict[Incomplete, Incomplete]: ... +def from_dict_of_dicts(d, create_using=None, multigraph_input=False): ... +def to_edgelist(G, nodelist=None): ... +def from_edgelist(edgelist, create_using=None): ... diff --git a/stubs/networkx/networkx/relabel.pyi b/stubs/networkx/networkx/relabel.pyi index 0556bae8924f..d70ed9c8a239 100644 --- a/stubs/networkx/networkx/relabel.pyi +++ b/stubs/networkx/networkx/relabel.pyi @@ -8,8 +8,8 @@ from networkx.classes.graph import Graph from networkx.classes.multidigraph import MultiDiGraph from networkx.classes.multigraph import MultiGraph -_X = TypeVar("_X") -_Y = TypeVar("_Y") +_X = TypeVar("_X", bound=Hashable) +_Y = TypeVar("_Y", bound=Hashable) @overload def relabel_nodes(G: MultiDiGraph[_X], mapping: Mapping[_X, _Y], copy: bool = True) -> MultiDiGraph[_X | _Y]: ... From 1941eb8e085e0a891c6db5efd79acfe0ff633411 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 28 Nov 2023 20:55:28 -0500 Subject: [PATCH 36/37] Applied further suggestions --- .../networkx/algorithms/operators/unary.pyi | 10 +++++-- .../networkx/algorithms/planarity.pyi | 1 - stubs/networkx/networkx/classes/function.pyi | 30 ++++++++++++++----- stubs/networkx/networkx/convert_matrix.pyi | 5 +++- .../networkx/generators/random_clustered.pyi | 7 +++-- stubs/networkx/networkx/utils/misc.pyi | 12 +++++++- 6 files changed, 48 insertions(+), 17 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/operators/unary.pyi b/stubs/networkx/networkx/algorithms/operators/unary.pyi index e4d2985a71e5..45878fa549f7 100644 --- a/stubs/networkx/networkx/algorithms/operators/unary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/unary.pyi @@ -1,5 +1,9 @@ -from networkx.classes.digraph import DiGraph -from networkx.classes.graph import _Node +from collections.abc import Hashable +from typing import TypeVar + +from networkx.classes.graph import Graph + +_G = TypeVar("_G", bound=Graph[Hashable]) def complement(G): ... -def reverse(G: DiGraph[_Node], copy: bool = True) -> DiGraph[_Node]: ... +def reverse(G: _G, copy: bool = True) -> _G: ... diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index 5c6886ff7b95..9a3d14db0b75 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -70,4 +70,3 @@ class PlanarEmbedding(DiGraph[_Node]): def traverse_face( self, v: _Node, w: _Node, mark_half_edges: MutableSet[tuple[_Node, _Node]] | None = None ) -> list[_Node]: ... - def is_directed(self) -> bool: ... diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index 78d8b769c404..60c231b3adf5 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -1,10 +1,13 @@ -from _typeshed import Incomplete -from collections.abc import Generator, Hashable, Iterator +from _typeshed import Incomplete, SupportsItems, SupportsKeysAndGetItem, Unused +from collections.abc import Generator, Hashable, Iterable, Iterator from typing import TypeVar, overload from typing_extensions import Literal +from networkx.algorithms.planarity import PlanarEmbedding +from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _NBunch, _Node from networkx.classes.graphviews import reverse_view as reverse_view, subgraph_view as subgraph_view +from networkx.classes.multigraph import MultiGraph __all__ = [ "nodes", @@ -57,7 +60,12 @@ def number_of_nodes(G): ... def number_of_edges(G): ... def density(G): ... def degree_histogram(G): ... -def is_directed(G): ... +@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 add_star(G_to_add_to, nodes_for_star, **attr) -> None: ... @@ -73,12 +81,18 @@ def create_empty_copy(G, with_data: bool = True): ... # incomplete: Can "Any scalar value" be enforced? @overload -def set_node_attributes(G: Graph[Hashable], values, name: str) -> None: ... +def set_node_attributes(G: Graph[Hashable], values: SupportsItems[_Node, Unused], name: str) -> None: ... @overload -def set_node_attributes(G: Graph[_Node], values: dict[_Node, dict[Incomplete, Incomplete]], name: None = None) -> None: ... +def set_node_attributes( + G: Graph[_Node], + values: SupportsItems[_Node, SupportsKeysAndGetItem[Incomplete, Incomplete] | Iterable[tuple[Incomplete, Incomplete]]], + name: None = None, +) -> None: ... def get_node_attributes(G: Graph[_Node], name: str) -> dict[_Node, Incomplete]: ... @overload -def set_edge_attributes(G: Graph[_Node], values: dict[tuple[_Node, _Node], Incomplete], name: str) -> None: ... +def set_edge_attributes(G: Graph[_Node], values: SupportsItems[tuple[_Node, _Node], Incomplete], name: str) -> None: ... +@overload +def set_edge_attributes(G: MultiGraph[_Node], values: dict[tuple[_Node, _Node, Incomplete], Incomplete], name: str) -> None: ... @overload def set_edge_attributes(G: Graph[Hashable], values, name: None = None) -> None: ... def get_edge_attributes(G: Graph[_Node], name: str) -> dict[tuple[_Node, _Node], Incomplete]: ... @@ -86,8 +100,8 @@ def all_neighbors(graph: Graph[_Node], node: _Node) -> Iterator[_Node]: ... def non_neighbors(graph: Graph[_Node], node: _Node) -> Generator[_Node, None, None]: ... def non_edges(graph: Graph[_Node]) -> Generator[tuple[_Node, _Node], None, None]: ... 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 | None = "weight") -> bool: ... -def is_negatively_weighted(G: Graph[_Node], edge: tuple[_Node, _Node] | None = None, weight: str | None = "weight"): ... +def is_weighted(G: Graph[_Node], edge: tuple[_Node, _Node] | None = None, weight: str = "weight") -> bool: ... +def is_negatively_weighted(G: Graph[_Node], edge: tuple[_Node, _Node] | None = None, weight: str = "weight"): ... def is_empty(G: Graph[Hashable]) -> bool: ... def nodes_with_selfloops(G: Graph[_Node]) -> Generator[_Node, None, None]: ... @overload diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index 6b846efbc501..ffbaf05d2326 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -11,11 +11,14 @@ from networkx.classes.graph import Graph, _Node _DataFrame: TypeAlias = Incomplete # from pandas.core.dtypes.base import ExtensionDtype _ExtensionDtype: TypeAlias = Incomplete +# pandas._typing import Axes +# _Axes: TypeAlias = Index | Series | np.ndarray | list | dict | range | tuple +_Axes: TypeAlias = Collection[_Node] _G = TypeVar("_G", bound=Graph[Hashable]) def to_pandas_adjacency( G: Graph[_Node], - nodelist: list[_Node] | None = None, + nodelist: _Axes[_Node] | None = None, dtype: numpy.dtype[Incomplete] | None = None, order: numpy._OrderCF = None, multigraph_weight: Callable[[list[float]], float] = ..., diff --git a/stubs/networkx/networkx/generators/random_clustered.pyi b/stubs/networkx/networkx/generators/random_clustered.pyi index 348511fe2a5d..1a914e12bc04 100644 --- a/stubs/networkx/networkx/generators/random_clustered.pyi +++ b/stubs/networkx/networkx/generators/random_clustered.pyi @@ -1,16 +1,17 @@ from collections.abc import Iterable -from typing import Any, TypeVar, overload +from typing import TypeVar, overload from networkx import MultiGraph from networkx.classes.graph import Graph +from networkx.utils.misc import _RandomState _G = TypeVar("_G", bound=Graph[int]) @overload def random_clustered_graph( - joint_degree_sequence: Iterable[tuple[int, int]], create_using: None = None, seed: int | tuple[Any, ...] | None = None + joint_degree_sequence: Iterable[tuple[int, int]], create_using: None = None, seed: _RandomState = None ) -> MultiGraph[int]: ... @overload def random_clustered_graph( - joint_degree_sequence: Iterable[tuple[int, int]], create_using: type[_G], seed: int | tuple[Any, ...] | None = None + joint_degree_sequence: Iterable[tuple[int, int]], create_using: type[_G], seed: _RandomState = None ) -> _G: ... diff --git a/stubs/networkx/networkx/utils/misc.pyi b/stubs/networkx/networkx/utils/misc.pyi index ee1f811ebd4b..eb5414bc7bbc 100644 --- a/stubs/networkx/networkx/utils/misc.pyi +++ b/stubs/networkx/networkx/utils/misc.pyi @@ -1,4 +1,14 @@ +import random from _typeshed import Incomplete +from types import ModuleType +from typing_extensions import TypeAlias + +import numpy + +_RandomNumberGenerator: TypeAlias = ( + ModuleType | random.Random | numpy.random.RandomState | numpy.random.Generator | PythonRandomInterface +) +_RandomState: TypeAlias = int | _RandomNumberGenerator | None def flatten(obj, result: Incomplete | None = None): ... def make_list_of_ints(sequence): ... @@ -21,7 +31,7 @@ class PythonRandomInterface: def expovariate(self, scale): ... def paretovariate(self, shape): ... -def create_py_random_state(random_state: Incomplete | None = None): ... +def create_py_random_state(random_state: _RandomState = None): ... def nodes_equal(nodes1, nodes2): ... def edges_equal(edges1, edges2): ... def graphs_equal(graph1, graph2): ... From 12395368e19ee1025299dd67ad785c756fca6276 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 28 Nov 2023 21:11:17 -0500 Subject: [PATCH 37/37] Add comment to `view_pygraphviz`'s `edgelabel` param --- stubs/networkx/networkx/drawing/nx_agraph.pyi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stubs/networkx/networkx/drawing/nx_agraph.pyi b/stubs/networkx/networkx/drawing/nx_agraph.pyi index f84b3ee180b3..7327740591a8 100644 --- a/stubs/networkx/networkx/drawing/nx_agraph.pyi +++ b/stubs/networkx/networkx/drawing/nx_agraph.pyi @@ -20,6 +20,9 @@ pygraphviz_layout = graphviz_layout def view_pygraphviz( G: Graph[_Node], + # From implementation looks like Callable could return object since it's always immediatly stringified + # But judging by documentation this seems like an extra runtime safty thing and not intended + # Leaving as str unless anyone reports a valid use-case edgelabel: str | Callable[[_Node], str] | None = None, prog: str = "dot", args: str = "",