diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 7975ccb0d254..85d904e72d17 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..270518a1115d --- /dev/null +++ b/stubs/networkx/METADATA.toml @@ -0,0 +1,9 @@ +version = "3.1" +upstream_repository = "https://github.com/networkx/networkx" +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/__init__.pyi b/stubs/networkx/networkx/__init__.pyi new file mode 100644 index 000000000000..2884bfc1a481 --- /dev/null +++ b/stubs/networkx/networkx/__init__.pyi @@ -0,0 +1,24 @@ +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 * + +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/__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..2884da3b93ef --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/connectivity.pyi @@ -0,0 +1,5 @@ +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..2a0bd9b1d082 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi @@ -0,0 +1 @@ +def k_components(G, min_density: float = 0.95): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/matching.pyi b/stubs/networkx/networkx/algorithms/approximation/matching.pyi 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..170f728531f3 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi @@ -0,0 +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): ... 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..572c0bf5b232 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/steinertree.pyi @@ -0,0 +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): ... 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..1959f98f5ca4 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi @@ -0,0 +1,33 @@ +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, + # 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, + alpha: float = 0.01, + seed: Incomplete | None = None, +): ... +def threshold_accepting_tsp( + G, + init_cycle, + weight: str = "weight", + source: Incomplete | None = None, + threshold: float = 1, + move: str = "1-1", + max_iterations: int = 10, + N_inner: int = 100, + alpha: float = 0.1, + seed: Incomplete | None = None, +): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi new file mode 100644 index 000000000000..637f5740bf3e --- /dev/null +++ b/stubs/networkx/networkx/algorithms/approximation/treewidth.pyi @@ -0,0 +1,11 @@ +from _typeshed import Incomplete + +__all__ = ["treewidth_min_degree", "treewidth_min_fill_in"] + +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..e0f8cb99417f --- /dev/null +++ b/stubs/networkx/networkx/algorithms/assortativity/connectivity.pyi @@ -0,0 +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 +): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi new file mode 100644 index 000000000000..300160c7e874 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi @@ -0,0 +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 +): ... +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..0801a6719210 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/assortativity/mixing.pyi @@ -0,0 +1,19 @@ +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..42649c6f6a5f --- /dev/null +++ b/stubs/networkx/networkx/algorithms/assortativity/neighbor_degree.pyi @@ -0,0 +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 +): ... diff --git a/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi b/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi new file mode 100644 index 000000000000..dc834ba8164f --- /dev/null +++ b/stubs/networkx/networkx/algorithms/assortativity/pairs.pyi @@ -0,0 +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_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..9251989a2d39 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi @@ -0,0 +1,23 @@ +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..7c36a00a8751 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi @@ -0,0 +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 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..de89ed68fdb9 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi @@ -0,0 +1,9 @@ +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..79f344772f58 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi @@ -0,0 +1,11 @@ +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..ad7e73bb00e7 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/projection.pyi @@ -0,0 +1,7 @@ +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..3ae4c3180793 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bipartite/spectral.pyi @@ -0,0 +1,3 @@ +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..10200a11b249 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/boundary.pyi @@ -0,0 +1,114 @@ +from _typeshed import Incomplete +from collections.abc import Generator, Iterable +from typing import TypeVar, overload +from typing_extensions import Literal + +from networkx.classes.graph import Graph, _Node + +_U = TypeVar("_U") + +@overload +def edge_boundary( + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None = None, + data: Literal[False] = False, + keys: Literal[False] = False, + default=None, +) -> Generator[tuple[_Node, _Node], None, None]: ... +@overload +def edge_boundary( + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None, + data: Literal[True], + keys: Literal[False] = False, + default=None, +) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ... +@overload +def edge_boundary( + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None = None, + *, + data: Literal[True], + keys: Literal[False] = False, + default=None, +) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ... +@overload +def edge_boundary( + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None, + data: str, + keys: Literal[False] = False, + default: _U | None = None, +) -> Generator[tuple[_Node, _Node, dict[str, _U]], None, None]: ... +@overload +def edge_boundary( + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None = None, + *, + data: str, + keys: Literal[False] = False, + default: _U | None = None, +) -> Generator[tuple[_Node, _Node, dict[str, _U]], None, None]: ... +@overload +def edge_boundary( + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None, + data: Literal[False], + keys: Literal[True], + default=None, +) -> Generator[tuple[_Node, _Node, int], None, None]: ... +@overload +def edge_boundary( + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None = None, + data: Literal[False] = False, + *, + keys: Literal[True], + default=None, +) -> Generator[tuple[_Node, _Node, int], None, None]: ... +@overload +def edge_boundary( + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None, + data: Literal[True], + keys: Literal[True], + default=None, +) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ... +@overload +def edge_boundary( + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None = None, + *, + data: Literal[True], + keys: Literal[True], + default=None, +) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ... +@overload +def edge_boundary( + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None, + data: str, + keys: Literal[True], + default: _U | None = None, +) -> Generator[tuple[_Node, _Node, int, dict[str, _U]], None, None]: ... +@overload +def edge_boundary( + G: Graph[_Node], + nbunch1: Iterable[_Node], + nbunch2: Iterable[_Node] | None = None, + *, + data: str, + keys: Literal[True], + default: _U | None = None, +) -> 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/bridges.pyi b/stubs/networkx/networkx/algorithms/bridges.pyi new file mode 100644 index 000000000000..c528d29fa6c9 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/bridges.pyi @@ -0,0 +1,17 @@ +from _typeshed import Incomplete +from collections.abc import Callable, Generator +from typing import overload +from typing_extensions import Literal + +from networkx.classes.graph import Graph, _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 +) -> 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], None, None]: ... 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..38cc77a1af5c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/betweenness.pyi @@ -0,0 +1,13 @@ +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..a5cdba3b0ace --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/betweenness_subset.pyi @@ -0,0 +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): ... diff --git a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi new file mode 100644 index 000000000000..da0e5ab87eaa --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi @@ -0,0 +1,6 @@ +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..c6f6bea33f14 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness.pyi @@ -0,0 +1,18 @@ +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..6d760a50153e --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_betweenness_subset.pyi @@ -0,0 +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" +): ... +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..202594de0604 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi @@ -0,0 +1,5 @@ +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..4043738aa0e2 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi @@ -0,0 +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: float = 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..d137dab3d66d --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi @@ -0,0 +1,36 @@ +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..0b446f548a6e --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/group.pyi @@ -0,0 +1,16 @@ +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..3f518c33c1ac --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/harmonic.pyi @@ -0,0 +1,5 @@ +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..a557413285e5 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/katz.pyi @@ -0,0 +1,15 @@ +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..a4ed84f5e6b8 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/load.pyi @@ -0,0 +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/centrality/percolation.pyi b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi new file mode 100644 index 000000000000..5cccd57e1d68 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi @@ -0,0 +1,5 @@ +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..6dca49336a10 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/reaching.pyi @@ -0,0 +1,6 @@ +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..393b4a4bca13 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/centrality/trophic.pyi @@ -0,0 +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): ... 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..03249f994e6e --- /dev/null +++ b/stubs/networkx/networkx/algorithms/chains.pyi @@ -0,0 +1,5 @@ +from collections.abc import Generator + +from networkx.classes.graph import Graph, _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 new file mode 100644 index 000000000000..2f2fde3a19ca --- /dev/null +++ b/stubs/networkx/networkx/algorithms/chordal.pyi @@ -0,0 +1,12 @@ +import sys +from collections.abc import Generator, Hashable + +from networkx.classes.graph import Graph, _Node +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: 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 new file mode 100644 index 000000000000..3cfe6eb83aa6 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -0,0 +1,40 @@ +from _typeshed import SupportsGetItem, Unused +from collections.abc import Container, Generator, Iterable, Iterator, Sized +from typing import overload + +from networkx.classes.graph import Graph, _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: Unused = None, create_using: type[Graph[_Node]] | None = None, name: Unused = None +) -> Graph[_Node]: ... +def graph_clique_number(G: Graph[_Node], cliques: Iterable[_Node] | None = None) -> int: ... +def graph_number_of_cliques(G: Graph[_Node], cliques: Sized | None = None) -> int: ... +@overload +def node_clique_number( # type: ignore[misc] # Incompatible return types + G: Graph[_Node], + 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: _Node, cliques: Iterable[Sized] | None = None, separate_nodes: Unused = False +) -> int: ... +@overload +def number_of_cliques( # type: ignore[misc] # Incompatible return types + G: Graph[_Node], nodes: list[_Node] | None = None, cliques: Iterable[Container[_Node]] | None = None +) -> dict[_Node, int]: ... +@overload +def number_of_cliques(G: Graph[_Node], nodes: _Node, cliques: Iterable[Container[_Node]] | None = None) -> int: ... +@overload +def cliques_containing_node( # type: ignore[misc] # Incompatible return types + G: Graph[_Node], nodes: list[_Node] | None = None, cliques: Iterable[Container[_Node]] | None = None +) -> dict[_Node, list[_Node]]: ... +@overload +def cliques_containing_node( + G: Graph[_Node], nodes: _Node, cliques: Iterable[Container[_Node]] | None = None +) -> Generator[list[_Node], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/cluster.pyi b/stubs/networkx/networkx/algorithms/cluster.pyi new file mode 100644 index 000000000000..9e4b5211eb92 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/cluster.pyi @@ -0,0 +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 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..764088306473 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/coloring/__init__.pyi @@ -0,0 +1,4 @@ +from networkx.algorithms.coloring.equitable_coloring import equitable_color as equitable_color +from networkx.algorithms.coloring.greedy_coloring import * + +__all__ = ["greedy_color", "equitable_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..22e42b36638b --- /dev/null +++ b/stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi @@ -0,0 +1,43 @@ +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): ... +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..b3f0e2a6c685 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/centrality.pyi @@ -0,0 +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]: ... 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..c614fa487c68 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/kclique.pyi @@ -0,0 +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]: ... 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..8063bcdd5340 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi @@ -0,0 +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 +): ... 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..64c554664e24 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/louvain.pyi @@ -0,0 +1,9 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def louvain_communities( + G, weight: str = "weight", resolution: float = 1, threshold: float = 1e-07, seed: Incomplete | None = None +): ... +def louvain_partitions( + G, weight: str = "weight", resolution: float = 1, threshold: float = 1e-07, seed: Incomplete | None = None +) -> Generator[Incomplete, None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/community/lukes.pyi b/stubs/networkx/networkx/algorithms/community/lukes.pyi new file mode 100644 index 000000000000..bf281313d5c1 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/lukes.pyi @@ -0,0 +1,3 @@ +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..e994d7760705 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/modularity_max.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete + +def greedy_modularity_communities( + G, weight: Incomplete | None = None, resolution: float = 1, cutoff: int = 1, best_n: 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 new file mode 100644 index 000000000000..dff61e455eaa --- /dev/null +++ b/stubs/networkx/networkx/algorithms/community/quality.pyi @@ -0,0 +1,9 @@ +from networkx.exception import NetworkXError + +__all__ = ["modularity", "partition_quality"] + +class NotAPartition(NetworkXError): + def __init__(self, G, collection) -> None: ... + +def modularity(G, communities, weight: str = "weight", resolution: float = 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..27c58b9280df --- /dev/null +++ b/stubs/networkx/networkx/algorithms/components/strongly_connected.pyi @@ -0,0 +1,11 @@ +from collections.abc import Generator, Hashable, Iterable + +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import Graph, _Node + +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[_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 new file mode 100644 index 000000000000..04f5c555e572 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/components/weakly_connected.pyi @@ -0,0 +1,7 @@ +from collections.abc import Generator, Hashable + +from networkx.classes.graph import Graph, _Node + +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/__init__.pyi b/stubs/networkx/networkx/algorithms/connectivity/__init__.pyi new file mode 100644 index 000000000000..4c3ecc33e72d --- /dev/null +++ b/stubs/networkx/networkx/algorithms/connectivity/__init__.pyi @@ -0,0 +1,9 @@ +from .connectivity import * +from .cuts import * +from .disjoint_paths import * +from .edge_augmentation import * +from .edge_kcomponents 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..77918d92334c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/connectivity/connectivity.pyi @@ -0,0 +1,43 @@ +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( + 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..de6cfd051ece --- /dev/null +++ b/stubs/networkx/networkx/algorithms/connectivity/cuts.pyi @@ -0,0 +1,16 @@ +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( + 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..daca82b9c4f1 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/connectivity/disjoint_paths.pyi @@ -0,0 +1,27 @@ +from _typeshed import Incomplete +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( + 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..0608747f127e --- /dev/null +++ b/stubs/networkx/networkx/algorithms/connectivity/edge_augmentation.pyi @@ -0,0 +1,13 @@ +from collections.abc import Generator, Hashable + +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[_Node], + k: int, + avail: tuple[_Node, _Node] | tuple[_Node, _Node, dict[str, int]] | None = None, + weight: str | None = None, + partial: bool = False, +) -> Generator[tuple[_Node, _Node], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi b/stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi new file mode 100644 index 000000000000..b8c4a413b498 --- /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(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 new file mode 100644 index 000000000000..980187eadeef --- /dev/null +++ b/stubs/networkx/networkx/algorithms/connectivity/kcomponents.pyi @@ -0,0 +1,9 @@ +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 new file mode 100644 index 000000000000..e72d0800565a --- /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 + +__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/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..1cbf2030dd6e --- /dev/null +++ b/stubs/networkx/networkx/algorithms/cuts.pyi @@ -0,0 +1,10 @@ +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..f637db85b096 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/cycles.pyi @@ -0,0 +1,15 @@ +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..0ad382b98b3c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/dag.pyi @@ -0,0 +1,17 @@ +from _typeshed import Incomplete + +from networkx.classes.graph import Graph, _Node + +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): ... +def all_topological_sorts(G) -> None: ... +def is_aperiodic(G): ... +def transitive_closure(G, reflexive: bool = False): ... +def transitive_reduction(G): ... +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/distance_measures.pyi b/stubs/networkx/networkx/algorithms/distance_measures.pyi new file mode 100644 index 000000000000..0119b424ec61 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/distance_measures.pyi @@ -0,0 +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): ... 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..73120e1b1ca6 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/euler.pyi @@ -0,0 +1,9 @@ +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..a5ac3895e457 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/__init__.pyi @@ -0,0 +1,11 @@ +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..cffacb633a68 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/capacityscaling.pyi @@ -0,0 +1 @@ +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..efa59ca8daa7 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi @@ -0,0 +1,9 @@ +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/flow/maxflow.pyi b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi new file mode 100644 index 000000000000..fa98e32cf756 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/maxflow.pyi @@ -0,0 +1,12 @@ +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): ... +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..4f441965ae0a --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/mincost.pyi @@ -0,0 +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 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..0039ca0ade8c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/flow/networksimplex.pyi @@ -0,0 +1,39 @@ +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..6d38c6b93654 --- /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: float = 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..e2fd08c037e7 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/graph_hashing.pyi @@ -0,0 +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 +): ... +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..df5f4bcd0530 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/hybrid.pyi @@ -0,0 +1,2 @@ +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..259d9f7735ce --- /dev/null +++ b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi @@ -0,0 +1,23 @@ +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..35caa37ccf19 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi @@ -0,0 +1,17 @@ +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 + +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..7b2e2c3d296d --- /dev/null +++ b/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi @@ -0,0 +1,62 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +__all__ = ["GraphMatcher", "DiGraphMatcher"] + +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..0b525aafef54 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi @@ -0,0 +1,17 @@ +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..a3200872c5e1 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi @@ -0,0 +1,28 @@ +from _typeshed import Incomplete + +from .isomorphvf2 import DiGraphMatcher, GraphMatcher + +__all__ = ["TimeRespectingGraphMatcher", "TimeRespectingDiGraphMatcher"] + +class TimeRespectingGraphMatcher(GraphMatcher): + temporal_attribute_name: Incomplete + delta: Incomplete + def __init__(self, G1, G2, temporal_attribute_name, delta) -> None: ... + def one_hop(self, Gx, Gx_node, neighbors): ... + def two_hop(self, Gx, core_x, Gx_node, neighbors): ... + 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..5783920145b6 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/isomorphism/vf2pp.pyi @@ -0,0 +1,30 @@ +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..5c84c8f6c340 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi @@ -0,0 +1,24 @@ +from _typeshed import Incomplete + +from . import isomorphvf2 as vf2 + +__all__ = ["GraphMatcher", "DiGraphMatcher", "MultiGraphMatcher", "MultiDiGraphMatcher"] + +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..7eccedf802ce --- /dev/null +++ b/stubs/networkx/networkx/algorithms/link_analysis/hits_alg.pyi @@ -0,0 +1,3 @@ +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..69082e00d8b4 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/link_prediction.pyi @@ -0,0 +1,10 @@ +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..e4b46e6c52cf --- /dev/null +++ b/stubs/networkx/networkx/algorithms/mis.pyi @@ -0,0 +1,3 @@ +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..14d8a769c21c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/node_classification.pyi @@ -0,0 +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"): ... 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..37cf06498b4c --- /dev/null +++ b/stubs/networkx/networkx/algorithms/operators/binary.pyi @@ -0,0 +1,18 @@ +from _typeshed import Incomplete +from collections.abc import Hashable +from typing import TypeVar + +from networkx.classes.digraph import DiGraph + +def disjoint_union(G, H): ... +def intersection(G, H): ... +def difference(G, H): ... +def symmetric_difference(G, H): ... + +_X = TypeVar("_X", bound=Hashable, covariant=True) +_Y = TypeVar("_Y", bound=Hashable, covariant=True) +# GT = TypeVar('GT', bound=Graph[_Node]) +# TODO: This does not handle the cases when graphs of different types are passed which is allowed + +def compose(G: DiGraph[_X], H: DiGraph[_Y]) -> DiGraph[_X | _Y]: ... +def union(G: DiGraph[_X], H: DiGraph[_Y], rename: Incomplete = ()) -> DiGraph[_X | _Y]: ... diff --git a/stubs/networkx/networkx/algorithms/operators/product.pyi b/stubs/networkx/networkx/algorithms/operators/product.pyi 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..45878fa549f7 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/operators/unary.pyi @@ -0,0 +1,9 @@ +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: _G, copy: bool = True) -> _G: ... 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..9a3d14db0b75 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -0,0 +1,72 @@ +from _typeshed import Incomplete +from collections.abc import Generator, Mapping, MutableSet, Reversible + +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import _Node + +__all__ = ["check_planarity", "is_planar", "PlanarEmbedding"] + +def is_planar(G) -> bool: ... +def check_planarity(G, counterexample: bool = False): ... + +class Interval: + low: Incomplete + high: Incomplete + def __init__(self, low: Incomplete | None = None, high: Incomplete | None = None) -> None: ... + def empty(self): ... + def copy(self): ... + 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): ... + +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) -> 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(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: _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]: ... 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..5e7903e1956f --- /dev/null +++ b/stubs/networkx/networkx/algorithms/richclub.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +def rich_club_coefficient(G, normalized: bool = True, Q: float = 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..4394432a7645 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/shortest_paths/astar.pyi @@ -0,0 +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"): ... 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..a931da0ec84e --- /dev/null +++ b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi @@ -0,0 +1,6 @@ +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..4c60b9483883 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/shortest_paths/generic.pyi @@ -0,0 +1,26 @@ +from _typeshed import Incomplete +from collections.abc import Generator +from typing import overload + +from networkx.classes.graph import Graph, _Node + +def has_path(G, source, target): ... +@overload +def shortest_path( + G: Graph[_Node], source: _Node, target: _Node, weight: Incomplete | None = None, method: str = "dijkstra" +) -> list[_Node]: ... +@overload +def shortest_path(G: Graph[_Node], target: _Node, method: str = "dijkstra") -> dict[_Node, list[_Node]]: ... +@overload +def shortest_path(G: Graph[_Node], source: _Node, method: str = "dijkstra") -> dict[_Node, list[_Node]]: ... +def shortest_path_length( + 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 = None, method: str | None = None): ... +def all_shortest_paths( + G: Graph[_Node], source: _Node, target: _Node, weight: Incomplete | None = None, method: str = "dijkstra" +) -> Generator[list[_Node], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi new file mode 100644 index 000000000000..706c04a6d62f --- /dev/null +++ b/stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi @@ -0,0 +1,13 @@ +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..43bcb9a502db --- /dev/null +++ b/stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi @@ -0,0 +1,36 @@ +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..f18150d09052 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/similarity.pyi @@ -0,0 +1,74 @@ +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..46b3d643a5a4 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/simple_paths.pyi @@ -0,0 +1,26 @@ +from _typeshed import Incomplete +from collections.abc import Generator, Sequence + +from networkx.classes.graph import Graph, _Node + +__all__ = ["all_simple_paths", "is_simple_path", "shortest_simple_paths", "all_simple_edge_paths"] + +def is_simple_path(G: Graph[_Node], nodes: Sequence[_Node]): ... +def all_simple_paths( + G: Graph[_Node], source: _Node, target: _Node, cutoff: Incomplete | None = None +) -> Generator[list[_Node], None, None]: ... +def all_simple_edge_paths( + G: Graph[_Node], source: _Node, target: _Node, cutoff: Incomplete | None = None +) -> Generator[list[_Node] | list[tuple[_Node, _Node]], None, list[_Node] | None]: ... +def shortest_simple_paths( + G: Graph[_Node], source: _Node, target: _Node, weight: Incomplete | None = None +) -> Generator[list[_Node], None, None]: ... + +class PathBuffer: + paths: Incomplete + sortedpaths: Incomplete + counter: Incomplete + def __init__(self) -> None: ... + def __len__(self): ... + def push(self, cost, path) -> None: ... + def pop(self): ... diff --git a/stubs/networkx/networkx/algorithms/smallworld.pyi b/stubs/networkx/networkx/algorithms/smallworld.pyi new file mode 100644 index 000000000000..baa6acb25a4a --- /dev/null +++ b/stubs/networkx/networkx/algorithms/smallworld.pyi @@ -0,0 +1,8 @@ +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..6c37f812509f --- /dev/null +++ b/stubs/networkx/networkx/algorithms/sparsifiers.pyi @@ -0,0 +1,3 @@ +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..c1f587134fdd --- /dev/null +++ b/stubs/networkx/networkx/algorithms/structuralholes.pyi @@ -0,0 +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 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..1c640e4067b0 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/swap.pyi @@ -0,0 +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): ... 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..caad5b0b1b8a --- /dev/null +++ b/stubs/networkx/networkx/algorithms/traversal/beamsearch.pyi @@ -0,0 +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]: ... 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..731b1b5c18ce --- /dev/null +++ b/stubs/networkx/networkx/algorithms/traversal/breadth_first_search.pyi @@ -0,0 +1,17 @@ +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..f7bdc54f06c4 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/traversal/depth_first_search.pyi @@ -0,0 +1,14 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from networkx.classes.graph import Graph, _Node + +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): ... +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/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..4d4e5bcfe228 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -0,0 +1,76 @@ +from _typeshed import Incomplete +from collections.abc import Iterator +from dataclasses import dataclass + +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: float = 1): ... +def greedy_branching(G, attr: str = "weight", default: float = 1, kind: str = "max", seed: Incomplete | None = None): ... + +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: ... + def remove_nodes_from(self, nbunch) -> 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: ... + +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: float = 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: float = 1, preserve_attrs: bool = False, partition: Incomplete | None = None +): ... +def minimum_branching( + G, attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: Incomplete | None = None +): ... +def maximum_spanning_arborescence( + G, attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: Incomplete | None = None +): ... +def minimum_spanning_arborescence( + G, attr: str = "weight", default: float = 1, preserve_attrs: bool = False, partition: Incomplete | None = None +): ... + +class ArborescenceIterator: + @dataclass + class Partition: + mst_weight: float + partition_dict: dict[Incomplete, Incomplete] + 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) -> Iterator[Incomplete]: ... + 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..88cfc57bd606 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/tree/coding.pyi @@ -0,0 +1,8 @@ +from networkx.exception import NetworkXException + +class NotATree(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..5ab610c6965f --- /dev/null +++ b/stubs/networkx/networkx/algorithms/tree/mst.pyi @@ -0,0 +1,37 @@ +from _typeshed import Incomplete +from collections.abc import Iterator +from dataclasses import dataclass +from enum import Enum + +class EdgePartition(Enum): + 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 +): ... +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: + @dataclass + class Partition: + mst_weight: float + partition_dict: dict[Incomplete, Incomplete] + 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) -> Iterator[Incomplete]: ... + 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..348555a0ad48 --- /dev/null +++ b/stubs/networkx/networkx/algorithms/vitality.pyi @@ -0,0 +1,5 @@ +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..1289c8a1cd55 --- /dev/null +++ b/stubs/networkx/networkx/classes/__init__.pyi @@ -0,0 +1,12 @@ +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 +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..3d488f4b64f8 --- /dev/null +++ b/stubs/networkx/networkx/classes/backends.pyi @@ -0,0 +1,15 @@ +from _typeshed import Incomplete +from collections.abc import Callable + +__all__ = ["_dispatch", "_mark_tests"] + +class PluginInfo: + def __init__(self) -> None: ... + def __bool__(self) -> bool: ... + @property + def items(self): ... + def __contains__(self, name) -> bool: ... + def __getitem__(self, name): ... + +def _dispatch(func: Incomplete | None = None, *, name: Incomplete | None = None) -> Callable[..., Incomplete]: ... +def _mark_tests(items) -> None: ... diff --git a/stubs/networkx/networkx/classes/coreviews.pyi b/stubs/networkx/networkx/classes/coreviews.pyi new file mode 100644 index 000000000000..15afbf5cf573 --- /dev/null +++ b/stubs/networkx/networkx/classes/coreviews.pyi @@ -0,0 +1,54 @@ +from collections.abc import Callable, Iterator, Mapping +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]]): + 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]): ... +class MultiAdjacencyView(AdjacencyView[_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]]): + 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]): ... +class UnionMultiAdjacency(UnionAdjacency[_T, _U, _V]): ... + +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]]): + 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): ... + def __iter__(self): ... + def __getitem__(self, node: _T) -> FilterAtlas[_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 new file mode 100644 index 000000000000..1636f6307c5d --- /dev/null +++ b/stubs/networkx/networkx/classes/digraph.pyi @@ -0,0 +1,28 @@ +from _typeshed import Incomplete +from collections.abc import Iterator + +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]): + 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 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/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..60c231b3adf5 --- /dev/null +++ b/stubs/networkx/networkx/classes/function.pyi @@ -0,0 +1,137 @@ +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", + "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", +] +_U = TypeVar("_U") + +def nodes(G): ... +def edges(G, nbunch: Incomplete | None = None): ... +def degree(G, nbunch: Incomplete | None = None, weight: Incomplete | None = None): ... +def neighbors(G, n): ... +def number_of_nodes(G): ... +def number_of_edges(G): ... +def density(G): ... +def degree_histogram(G): ... +@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: ... +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[_Node], nbunch: _NBunch[_Node]) -> Graph[_Node]: ... +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): ... + +# incomplete: Can "Any scalar value" be enforced? +@overload +def set_node_attributes(G: Graph[Hashable], values: SupportsItems[_Node, Unused], name: str) -> None: ... +@overload +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: SupportsItems[tuple[_Node, _Node], Incomplete], name: str) -> None: ... +@overload +def set_edge_attributes(G: MultiGraph[_Node], values: dict[tuple[_Node, _Node, Incomplete], Incomplete], name: str) -> None: ... +@overload +def set_edge_attributes(G: Graph[Hashable], values, name: None = None) -> None: ... +def get_edge_attributes(G: Graph[_Node], name: str) -> dict[tuple[_Node, _Node], Incomplete]: ... +def 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 = "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 +def selfloop_edges( + 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[_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[_Node], data: str, keys: Literal[False] = False, default: _U | None = None +) -> Generator[tuple[_Node, _Node, _U], None, None]: ... +@overload +def selfloop_edges( + G: Graph[_Node], data: Literal[False], keys: Literal[True], default=None +) -> Generator[tuple[_Node, _Node, int], None, None]: ... +@overload +def selfloop_edges( + 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[_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[_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 new file mode 100644 index 000000000000..011e55862d90 --- /dev/null +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -0,0 +1,89 @@ +from _typeshed import Incomplete +from collections.abc import Callable, Collection, Hashable, Iterable, Iterator, Mapping, MutableMapping +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 + +_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] = ... + 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) -> None: ... + + adj: AdjacencyView[_Node, _Node, dict[str, Incomplete]] + name: str + + 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: ... + 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: ... + 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) -> 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 = "weight", **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 = None, nodes: Iterable[_Node] | None = None + ) -> None: ... + def has_edge(self, u: _Node, v: _Node) -> bool: ... + 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) -> Iterator[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, 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 = None) -> int: ... + @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) -> Iterator[_Node]: ... diff --git a/stubs/networkx/networkx/classes/graphviews.pyi b/stubs/networkx/networkx/classes/graphviews.pyi new file mode 100644 index 000000000000..a356213889b3 --- /dev/null +++ b/stubs/networkx/networkx/classes/graphviews.pyi @@ -0,0 +1,38 @@ +from collections.abc import Callable, Hashable +from typing import TypeVar, overload + +from networkx.classes.digraph import DiGraph +from networkx.classes.graph import Graph, _Edge, _Node +from networkx.classes.multidigraph import MultiDiGraph +from networkx.classes.multigraph import MultiGraph, _MultiEdge + +_G = TypeVar("_G", bound=Graph[Hashable]) +_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[_Node]]) -> MultiDiGraph[_Node]: ... +@overload +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[_Node]]) -> MultiGraph[_Node]: ... +@overload +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] = ... +) -> MultiDiGraph[_Node]: ... +@overload +def subgraph_view( + 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[_Node]], bool] = ... +) -> DiGraph[_Node]: ... +@overload +def subgraph_view( + G: Graph[_Node], filter_node: Callable[[_Node], bool] = ..., filter_edge: Callable[[_Edge[_Node]], bool] = ... +) -> Graph[_Node]: ... +def reverse_view(G: _D) -> _D: ... diff --git a/stubs/networkx/networkx/classes/multidigraph.pyi b/stubs/networkx/networkx/classes/multidigraph.pyi new file mode 100644 index 000000000000..8f90911ec1db --- /dev/null +++ b/stubs/networkx/networkx/classes/multidigraph.pyi @@ -0,0 +1,12 @@ +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 = 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 new file mode 100644 index 000000000000..9462bd64cf64 --- /dev/null +++ b/stubs/networkx/networkx/classes/multigraph.pyi @@ -0,0 +1,21 @@ +from _typeshed import Incomplete +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]): + 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]: ... + 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 new file mode 100644 index 000000000000..ae28f0c060ef --- /dev/null +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -0,0 +1,135 @@ +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 networkx.classes.graph import Graph, _Edge, _NBunch, _Node + +_D = TypeVar("_D") +_U = TypeVar("_U") + +class NodeView(Mapping[_Node, _Node], AbstractSet[_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] = False, default: Incomplete = None) -> NodeView[_Node]: ... + @overload + 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(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]]: ... # type: ignore[override] + def __contains__(self, n: object) -> bool: ... + def __getitem__(self, n: _Node): ... + +class DiDegreeView(Generic[_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: ... + +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: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[_D]: ... + def __contains__(self, e: _Edge[_Node]) -> bool: ... + +class EdgeDataView(OutEdgeDataView[_Node, _D]): ... +class InEdgeDataView(OutEdgeDataView[_Node, _D]): ... + +class OutMultiEdgeDataView(OutEdgeDataView[_Node, _D]): + def __init__( + self, viewer, nbunch: _NBunch[_Node] = None, data: bool = False, keys: bool = False, default: Incomplete | None = None + ) -> None: ... + +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: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[tuple[_Node, _Node]]: ... + def __contains__(self, e: _Edge[_Node]) -> bool: ... # type: ignore[override] + def __getitem__(self, e: _Edge[_Node]) -> dict[str, Incomplete]: ... + @overload + def __call__(self, nbunch: None = None, data: Literal[False] = False, default: Unused = None) -> Self: ... + @overload + def __call__( + self, nbunch: _NBunch[_Node], data: Literal[True], default: None = None + ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ... + @overload + def __call__( + self, nbunch: _NBunch[_Node] = None, *, data: Literal[True], default: None = None + ) -> 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 __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: Unused = None, nbunch: None = None) -> Self: ... + @overload + def data( + self, data: Literal[True] = True, default: None = 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 + ) -> OutEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ... + +class EdgeView(OutEdgeView[_Node]): ... +class InEdgeView(OutEdgeView[_Node]): ... + +class OutMultiEdgeView(OutEdgeView[_Node]): + @overload # type: ignore[override] # Has an additional `keys` keyword argument + def __call__( + self, nbunch: None = None, data: Literal[False] = False, *, keys: Literal[True], default: Unused = None + ) -> Self: ... + @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]): ... +class InMultiEdgeView(OutMultiEdgeView[_Node]): ... diff --git a/stubs/networkx/networkx/convert.pyi b/stubs/networkx/networkx/convert.pyi new file mode 100644 index 000000000000..bb99e7e58bfe --- /dev/null +++ b/stubs/networkx/networkx/convert.pyi @@ -0,0 +1,19 @@ +from _typeshed import Incomplete + +__all__ = [ + "to_networkx_graph", + "from_dict_of_dicts", + "to_dict_of_dicts", + "from_dict_of_lists", + "to_dict_of_lists", + "from_edgelist", + "to_edgelist", +] + +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/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi new file mode 100644 index 000000000000..ffbaf05d2326 --- /dev/null +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -0,0 +1,84 @@ +from _typeshed import Incomplete +from collections.abc import Callable, Collection, Hashable, Iterable +from typing import TypeVar, overload +from typing_extensions import Literal, TypeAlias + +import numpy +from networkx.classes.graph import Graph, _Node + +# 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 +# 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: _Axes[_Node] | None = None, + dtype: numpy.dtype[Incomplete] | None = None, + order: numpy._OrderCF = None, + multigraph_weight: Callable[[list[float]], float] = ..., + weight: str = "weight", + nonedge: float = 0.0, +) -> _DataFrame: ... +@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", + target: str | int = "target", + 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 | list[str | int] | tuple[str | int] | Literal[True] | 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 | 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: Collection[_Node] | None = None, + dtype: numpy.dtype[Incomplete] | None = None, + order: numpy._OrderCF = None, + multigraph_weight: Callable[[list[float]], float] = ..., + 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: 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: ... 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..d84ae0b55131 --- /dev/null +++ b/stubs/networkx/networkx/drawing/layout.pyi @@ -0,0 +1,59 @@ +from _typeshed import Incomplete + +def random_layout(G, center: Incomplete | None = None, dim: int = 2, seed: Incomplete | None = None): ... +def circular_layout(G, scale: float = 1, center: Incomplete | None = None, dim: int = 2): ... +def shell_layout( + G, + nlist: Incomplete | None = None, + rotate: Incomplete | None = None, + scale: float = 1, + center: Incomplete | None = None, + dim: int = 2, +): ... +def bipartite_layout( + G, nodes, align: str = "vertical", scale: float = 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: float = 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: float = 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: 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: float = 1, center: Incomplete | None = None +): ... +def arf_layout( + G, + pos: Incomplete | None = None, + scaling: float = 1, + a: float = 1.1, + etol: float = 1e-06, + dt: float = 0.001, + max_iter: int = 1000, +): ... +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 new file mode 100644 index 000000000000..7327740591a8 --- /dev/null +++ b/stubs/networkx/networkx/drawing/nx_agraph.pyi @@ -0,0 +1,32 @@ +from _typeshed import Incomplete +from collections.abc import Callable, Hashable +from io import TextIOBase +from typing_extensions import TypeAlias + +from networkx.classes.graph import Graph, _Node + +# from pygraphviz.agraph import AGraph as _AGraph +_AGraph: TypeAlias = 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[_Node], prog: str = "neato", root: str | None = None, args: str = "" +) -> dict[_Node, tuple[float, float]]: ... + +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 = "", + suffix: str = "", + path: str | None = None, + show: bool = True, +): ... 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..1fc090b5f0a7 --- /dev/null +++ b/stubs/networkx/networkx/drawing/nx_pylab.pyi @@ -0,0 +1,85 @@ +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: Incomplete | int = 300, + node_color: str = "#1f78b4", + node_shape: str = "o", + alpha: Incomplete | None = None, + cmap: Incomplete | None = None, + vmin: Incomplete | None = None, + vmax: Incomplete | None = None, + ax: Incomplete | None = None, + linewidths: Incomplete | None = None, + edgecolors: Incomplete | None = None, + label: Incomplete | None = None, + margins: Incomplete | None = None, +): ... +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: Incomplete | 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..10f57320828c --- /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: 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): ... +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..870f9627c372 --- /dev/null +++ b/stubs/networkx/networkx/generators/community.pyi @@ -0,0 +1,33 @@ +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..c075d61395bf --- /dev/null +++ b/stubs/networkx/networkx/generators/degree_seq.pyi @@ -0,0 +1,38 @@ +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 +): ... +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..73a9b62da530 --- /dev/null +++ b/stubs/networkx/networkx/generators/directed.pyi @@ -0,0 +1,17 @@ +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: float = 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..509eb94eaa74 --- /dev/null +++ b/stubs/networkx/networkx/generators/ego.pyi @@ -0,0 +1,3 @@ +from _typeshed import Incomplete + +def ego_graph(G, n, radius: float = 1, center: bool = True, undirected: bool = False, distance: Incomplete | None = None): ... diff --git a/stubs/networkx/networkx/generators/expanders.pyi b/stubs/networkx/networkx/generators/expanders.pyi 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..aabc390701ad --- /dev/null +++ b/stubs/networkx/networkx/generators/geometric.pyi @@ -0,0 +1,47 @@ +from _typeshed import Incomplete + +def geometric_edges(G, radius, p: float = 2): ... +def random_geometric_graph( + 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: float = 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, +): ... + +# 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, + theta, + dim: int = 2, + pos: Incomplete | None = None, + weight: Incomplete | None = None, + p: float = 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..060132735097 --- /dev/null +++ b/stubs/networkx/networkx/generators/internet_as_graphs.pyi @@ -0,0 +1,38 @@ +from _typeshed import Incomplete + +__all__ = ["random_internet_as_graph"] + +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..38ee477ceb6a --- /dev/null +++ b/stubs/networkx/networkx/generators/joint_degree_seq.pyi @@ -0,0 +1,6 @@ +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..98fa1110c65d --- /dev/null +++ b/stubs/networkx/networkx/generators/lattice.pyi @@ -0,0 +1,11 @@ +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..4ef477bbc991 --- /dev/null +++ b/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi @@ -0,0 +1,5 @@ +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..1a914e12bc04 --- /dev/null +++ b/stubs/networkx/networkx/generators/random_clustered.pyi @@ -0,0 +1,17 @@ +from collections.abc import Iterable +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: _RandomState = None +) -> MultiGraph[int]: ... +@overload +def random_clustered_graph( + joint_degree_sequence: Iterable[tuple[int, int]], create_using: type[_G], seed: _RandomState = None +) -> _G: ... diff --git a/stubs/networkx/networkx/generators/random_graphs.pyi b/stubs/networkx/networkx/generators/random_graphs.pyi new file mode 100644 index 000000000000..6a075ac2a5e9 --- /dev/null +++ b/stubs/networkx/networkx/generators/random_graphs.pyi @@ -0,0 +1,23 @@ +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: 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/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..e9e6c5618191 --- /dev/null +++ b/stubs/networkx/networkx/generators/spectral_graph_forge.pyi @@ -0,0 +1,3 @@ +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..584dd3221a00 --- /dev/null +++ b/stubs/networkx/networkx/generators/trees.pyi @@ -0,0 +1,5 @@ +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..b932e90af2c2 --- /dev/null +++ b/stubs/networkx/networkx/lazy_imports.pyi @@ -0,0 +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: ... + +def _lazy_import(fullname) -> types.ModuleType | DelayedImportErrorModule: ... 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..14ae63154460 --- /dev/null +++ b/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi @@ -0,0 +1,3 @@ +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..b8aabe9df5ef --- /dev/null +++ b/stubs/networkx/networkx/linalg/graphmatrix.pyi @@ -0,0 +1,10 @@ +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..6f89c4d43507 --- /dev/null +++ b/stubs/networkx/networkx/linalg/laplacianmatrix.pyi @@ -0,0 +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 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..5f4e32f967a7 --- /dev/null +++ b/stubs/networkx/networkx/linalg/modularitymatrix.pyi @@ -0,0 +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): ... 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..901ddbce6728 --- /dev/null +++ b/stubs/networkx/networkx/readwrite/adjlist.pyi @@ -0,0 +1,20 @@ +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..c2345c2ca88d --- /dev/null +++ b/stubs/networkx/networkx/readwrite/edgelist.pyi @@ -0,0 +1,32 @@ +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..08c030021838 --- /dev/null +++ b/stubs/networkx/networkx/readwrite/gexf.pyi @@ -0,0 +1,69 @@ +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" +) -> 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..363de75fa2d2 --- /dev/null +++ b/stubs/networkx/networkx/readwrite/gml.pyi @@ -0,0 +1,29 @@ +from _typeshed import Incomplete +from collections.abc import Generator +from enum import Enum +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): ... + +class Pattern(Enum): + KEYS = 0 + REALS = 1 + INTS = 2 + STRINGS = 3 + DICT_START = 4 + DICT_END = 5 + COMMENT_WHITESPACE = 6 + +class Token(NamedTuple, Generic[_T]): + category: Pattern + value: _T + line: int + position: int + +def generate_gml(G, stringizer: Incomplete | None = None) -> Generator[Incomplete, Incomplete, None]: ... +def write_gml(G, path, stringizer: Incomplete | None = None) -> None: ... 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..6771f6e1c0c1 --- /dev/null +++ b/stubs/networkx/networkx/readwrite/graphml.pyi @@ -0,0 +1,128 @@ +from _typeshed import Incomplete +from collections.abc import Generator +from typing_extensions import Final + +__all__ = [ + "write_graphml", + "read_graphml", + "generate_graphml", + "write_graphml_xml", + "write_graphml_lxml", + "parse_graphml", + "GraphMLWriter", + "GraphMLReader", +] + +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: Final[str] + NS_XSI: Final[str] + NS_Y: Final[str] + SCHEMALOCATION: Final[str] + 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: ... # type: ignore[override] # This incompatible signature is an actual issue in networkx + +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..1bf7db87a68e --- /dev/null +++ b/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi @@ -0,0 +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"}): ... 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..f09488bb692f --- /dev/null +++ b/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi @@ -0,0 +1,22 @@ +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..9336e6f5e6ef --- /dev/null +++ b/stubs/networkx/networkx/readwrite/sparse6.pyi @@ -0,0 +1,6 @@ +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..9bd43b819728 --- /dev/null +++ b/stubs/networkx/networkx/readwrite/text.pyi @@ -0,0 +1,61 @@ +from _typeshed import Incomplete +from collections.abc import Generator +from typing import ClassVar + +__all__ = ["forest_str", "generate_network_text", "write_network_text"] + +class _AsciiBaseGlyphs: + 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: ClassVar[str] + mid: ClassVar[str] + backedge: ClassVar[str] + +class AsciiUndirectedGlyphs(_AsciiBaseGlyphs): + last: ClassVar[str] + mid: ClassVar[str] + backedge: ClassVar[str] + +class _UtfBaseGlyphs: + 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: ClassVar[str] + mid: ClassVar[str] + backedge: ClassVar[str] + +class UtfUndirectedGlyphs(_UtfBaseGlyphs): + last: ClassVar[str] + mid: ClassVar[str] + backedge: ClassVar[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..d70ed9c8a239 --- /dev/null +++ b/stubs/networkx/networkx/relabel.pyi @@ -0,0 +1,27 @@ +from _typeshed import Incomplete +from collections.abc import Hashable, Mapping +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", bound=Hashable) +_Y = TypeVar("_Y", bound=Hashable) + +@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], + first_label: int = 0, + ordering: Literal["default", "sorted", "increasing degree", "decreasing degree"] = "default", + label_attribute: Incomplete | None = 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..9d9fadb46ea5 --- /dev/null +++ b/stubs/networkx/networkx/utils/mapped_queue.pyi @@ -0,0 +1,23 @@ +from _typeshed import Incomplete +from collections.abc import Iterator + +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) -> Iterator[Incomplete]: ... + +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..eb5414bc7bbc --- /dev/null +++ b/stubs/networkx/networkx/utils/misc.pyi @@ -0,0 +1,37 @@ +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): ... +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: _RandomState = 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..921b79a04079 --- /dev/null +++ b/stubs/networkx/networkx/utils/random_sequence.pyi @@ -0,0 +1,10 @@ +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..35ff04993603 --- /dev/null +++ b/stubs/networkx/networkx/utils/rcm.pyi @@ -0,0 +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 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..fe50ede3c4df --- /dev/null +++ b/stubs/networkx/networkx/utils/union_find.pyi @@ -0,0 +1,11 @@ +from _typeshed import Incomplete +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) -> Iterator[Incomplete]: ... + def to_sets(self) -> Generator[Incomplete, Incomplete, None]: ... + def union(self, *objects): ...