Skip to content

Commit 84c78c6

Browse files
authored
Extract NetworkX types from docstrings (#13458)
1 parent 9da1df6 commit 84c78c6

File tree

171 files changed

+1378
-842
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+1378
-842
lines changed

stubs/networkx/networkx/algorithms/__init__.pyi

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ from networkx.algorithms.bipartite import (
3030
)
3131
from networkx.algorithms.boundary import *
3232
from networkx.algorithms.bridges import *
33+
from networkx.algorithms.broadcasting import *
3334
from networkx.algorithms.centrality import *
3435
from networkx.algorithms.chains import *
3536
from networkx.algorithms.chordal import *
@@ -116,6 +117,7 @@ from networkx.algorithms.sparsifiers import *
116117
from networkx.algorithms.structuralholes import *
117118
from networkx.algorithms.summarization import *
118119
from networkx.algorithms.swap import *
120+
from networkx.algorithms.time_dependent import *
119121
from networkx.algorithms.traversal import *
120122
from networkx.algorithms.tree.branchings import (
121123
ArborescenceIterator as ArborescenceIterator,
@@ -132,4 +134,5 @@ from networkx.algorithms.tree.recognition import *
132134
from networkx.algorithms.triads import *
133135
from networkx.algorithms.vitality import *
134136
from networkx.algorithms.voronoi import *
137+
from networkx.algorithms.walks import *
135138
from networkx.algorithms.wiener import *
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
from networkx.classes.graph import Graph, _Node
12
from networkx.utils.backends import _dispatchable
23

34
@_dispatchable
4-
def maximum_independent_set(G): ...
5+
def maximum_independent_set(G: Graph[_Node]): ...
56
@_dispatchable
6-
def max_clique(G): ...
7+
def max_clique(G: Graph[_Node]): ...
78
@_dispatchable
8-
def clique_removal(G): ...
9+
def clique_removal(G: Graph[_Node]): ...
910
@_dispatchable
10-
def large_clique_size(G): ...
11+
def large_clique_size(G: Graph[_Node]): ...
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from _typeshed import Incomplete
2-
1+
from networkx.classes.graph import Graph, _Node
32
from networkx.utils.backends import _dispatchable
3+
from numpy.random import RandomState
44

55
@_dispatchable
6-
def average_clustering(G, trials: int = 1000, seed: Incomplete | None = None): ...
6+
def average_clustering(G: Graph[_Node], trials: int = 1000, seed: int | RandomState | None = None): ...
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Iterable
23

4+
from networkx.classes.graph import Graph, _Node
35
from networkx.utils.backends import _dispatchable
46

57
@_dispatchable
6-
def local_node_connectivity(G, source, target, cutoff: Incomplete | None = None): ...
8+
def local_node_connectivity(G: Graph[_Node], source: _Node, target: _Node, cutoff: int | None = None): ...
79
@_dispatchable
8-
def node_connectivity(G, s: Incomplete | None = None, t: Incomplete | None = None): ...
10+
def node_connectivity(G: Graph[_Node], s: _Node | None = None, t: _Node | None = None): ...
911
@_dispatchable
10-
def all_pairs_node_connectivity(G, nbunch: Incomplete | None = None, cutoff: Incomplete | None = None): ...
12+
def all_pairs_node_connectivity(G: Graph[_Node], nbunch: Iterable[Incomplete] | None = None, cutoff: int | None = None): ...
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from _typeshed import Incomplete
2-
1+
from networkx.classes.graph import Graph, _Node
32
from networkx.utils.backends import _dispatchable
3+
from numpy.random import RandomState
44

55
@_dispatchable
6-
def diameter(G, seed: Incomplete | None = None): ...
6+
def diameter(G: Graph[_Node], seed: int | RandomState | None = None): ...
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
from _typeshed import Incomplete
2-
1+
from networkx.classes.graph import Graph, _Node
32
from networkx.utils.backends import _dispatchable
43

54
@_dispatchable
6-
def min_weighted_dominating_set(G, weight: Incomplete | None = None): ...
5+
def min_weighted_dominating_set(G: Graph[_Node], weight: str | None = None): ...
76
@_dispatchable
8-
def min_edge_dominating_set(G): ...
7+
def min_edge_dominating_set(G: Graph[_Node]): ...
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
from networkx.classes.graph import Graph, _Node
12
from networkx.utils.backends import _dispatchable
23

34
@_dispatchable
4-
def k_components(G, min_density: float = 0.95): ...
5+
def k_components(G: Graph[_Node], min_density: float = 0.95): ...
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
from networkx.classes.graph import Graph, _Node
12
from networkx.utils.backends import _dispatchable
23

34
@_dispatchable
4-
def min_maximal_matching(G): ...
5+
def min_maximal_matching(G: Graph[_Node]): ...
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
from _typeshed import Incomplete
22

3+
from networkx.classes.graph import Graph, _Node
34
from networkx.utils.backends import _dispatchable
5+
from numpy.random import RandomState
46

57
@_dispatchable
6-
def randomized_partitioning(G, seed: Incomplete | None = None, p: float = 0.5, weight: Incomplete | None = None): ...
8+
def randomized_partitioning(
9+
G: Graph[_Node], seed: int | RandomState | None = None, p: float = 0.5, weight: str | None = None
10+
): ...
711
@_dispatchable
8-
def one_exchange(G, initial_cut: Incomplete | None = None, seed: Incomplete | None = None, weight: Incomplete | None = None): ...
12+
def one_exchange(
13+
G: Graph[_Node], initial_cut: set[Incomplete] | None = None, seed: int | RandomState | None = None, weight: str | None = None
14+
): ...
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
from networkx.classes.graph import Graph, _Node
12
from networkx.utils.backends import _dispatchable
23

34
@_dispatchable
4-
def ramsey_R2(G): ...
5+
def ramsey_R2(G: Graph[_Node]): ...
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Iterable
23

4+
from networkx.classes.graph import Graph, _Node
35
from networkx.utils.backends import _dispatchable
46

57
@_dispatchable
6-
def metric_closure(G, weight: str = "weight"): ...
8+
def metric_closure(G: Graph[_Node], weight="weight"): ...
79
@_dispatchable
8-
def steiner_tree(G, terminal_nodes, weight: str = "weight", method: Incomplete | None = None): ...
10+
def steiner_tree(G: Graph[_Node], terminal_nodes: Iterable[Incomplete], weight: str = "weight", method: str | None = None): ...
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,51 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Callable
23

4+
from networkx.classes.digraph import DiGraph
5+
from networkx.classes.graph import Graph, _Node
36
from networkx.utils.backends import _dispatchable
7+
from numpy.random import RandomState
48

59
@_dispatchable
6-
def christofides(G, weight: str = "weight", tree: Incomplete | None = None): ...
10+
def christofides(G: Graph[_Node], weight: str | None = "weight", tree: Graph[_Node] | None = None): ...
711
@_dispatchable
812
def traveling_salesman_problem(
9-
G, weight: str = "weight", nodes: Incomplete | None = None, cycle: bool = True, method: Incomplete | None = None, **kwargs
13+
G: Graph[_Node],
14+
weight: str = "weight",
15+
nodes=None,
16+
cycle: bool = True,
17+
method: Callable[..., Incomplete] | None = None,
18+
**kwargs,
1019
): ...
1120
@_dispatchable
12-
def asadpour_atsp(G, weight: str = "weight", seed: Incomplete | None = None, source: Incomplete | None = None): ...
21+
def asadpour_atsp(
22+
G: DiGraph[_Node], weight: str | None = "weight", seed: int | RandomState | None = None, source: str | None = None
23+
): ...
1324
@_dispatchable
14-
def greedy_tsp(G, weight: str = "weight", source: Incomplete | None = None): ...
25+
def greedy_tsp(G: Graph[_Node], weight: str | None = "weight", source=None): ...
1526
@_dispatchable
1627
def simulated_annealing_tsp(
17-
G,
28+
G: Graph[_Node],
1829
init_cycle,
19-
weight: str = "weight",
20-
source: Incomplete | None = None,
21-
# docstring says int, but it can be a float and does become a float mid-equation if alpha is also a float
22-
temp: float = 100,
23-
move: str = "1-1",
24-
max_iterations: int = 10,
25-
N_inner: int = 100,
26-
alpha: float = 0.01,
27-
seed: Incomplete | None = None,
30+
weight: str | None = "weight",
31+
source=None,
32+
temp: int | None = 100,
33+
move="1-1",
34+
max_iterations: int | None = 10,
35+
N_inner: int | None = 100,
36+
alpha=0.01,
37+
seed: int | RandomState | None = None,
2838
): ...
2939
@_dispatchable
3040
def threshold_accepting_tsp(
31-
G,
41+
G: Graph[_Node],
3242
init_cycle,
33-
weight: str = "weight",
34-
source: Incomplete | None = None,
35-
threshold: float = 1,
36-
move: str = "1-1",
37-
max_iterations: int = 10,
38-
N_inner: int = 100,
39-
alpha: float = 0.1,
40-
seed: Incomplete | None = None,
43+
weight: str | None = "weight",
44+
source=None,
45+
threshold: int | None = 1,
46+
move="1-1",
47+
max_iterations: int | None = 10,
48+
N_inner: int | None = 100,
49+
alpha=0.1,
50+
seed: int | RandomState | None = None,
4151
): ...
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
from _typeshed import Incomplete
22

3+
from networkx.classes.graph import Graph, _Node
34
from networkx.utils.backends import _dispatchable
45

56
__all__ = ["treewidth_min_degree", "treewidth_min_fill_in"]
67

78
@_dispatchable
8-
def treewidth_min_degree(G): ...
9+
def treewidth_min_degree(G: Graph[_Node]): ...
910
@_dispatchable
10-
def treewidth_min_fill_in(G): ...
11+
def treewidth_min_fill_in(G: Graph[_Node]): ...
1112

1213
class MinDegreeHeuristic:
1314
count: Incomplete
15+
1416
def __init__(self, graph) -> None: ...
1517
def best_node(self, graph): ...
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
from _typeshed import Incomplete
2-
1+
from networkx.classes.graph import Graph, _Node
32
from networkx.utils.backends import _dispatchable
43

54
@_dispatchable
6-
def min_weighted_vertex_cover(G, weight: Incomplete | None = None): ...
5+
def min_weighted_vertex_cover(G: Graph[_Node], weight: str | None = None): ...
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Iterable
23

4+
from networkx.classes.graph import Graph, _Node
35
from networkx.utils.backends import _dispatchable
46

57
@_dispatchable
68
def average_degree_connectivity(
7-
G, source: str = "in+out", target: str = "in+out", nodes: Incomplete | None = None, weight: Incomplete | None = None
9+
G: Graph[_Node], source="in+out", target="in+out", nodes: Iterable[Incomplete] | None = None, weight: str | None = None
810
): ...
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Iterable
23

4+
from networkx.classes.graph import Graph, _Node
35
from networkx.utils.backends import _dispatchable
46

57
@_dispatchable
68
def degree_assortativity_coefficient(
7-
G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None
9+
G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable[Incomplete] | None = None
810
): ...
911
@_dispatchable
1012
def degree_pearson_correlation_coefficient(
11-
G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None
13+
G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable[Incomplete] | None = None
1214
): ...
1315
@_dispatchable
14-
def attribute_assortativity_coefficient(G, attribute, nodes: Incomplete | None = None): ...
16+
def attribute_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None): ...
1517
@_dispatchable
16-
def numeric_assortativity_coefficient(G, attribute, nodes: Incomplete | None = None): ...
18+
def numeric_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None): ...
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
1-
from _typeshed import Incomplete
1+
from _typeshed import Incomplete, SupportsGetItem
2+
from collections.abc import Iterable
23

4+
from networkx.classes.graph import Graph, _Node
35
from networkx.utils.backends import _dispatchable
46

57
@_dispatchable
6-
def attribute_mixing_dict(G, attribute, nodes: Incomplete | None = None, normalized: bool = False): ...
8+
def attribute_mixing_dict(
9+
G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None, normalized: bool = False
10+
): ...
711
@_dispatchable
812
def attribute_mixing_matrix(
9-
G, attribute, nodes: Incomplete | None = None, mapping: Incomplete | None = None, normalized: bool = True
13+
G: Graph[_Node],
14+
attribute: str,
15+
nodes: Iterable[Incomplete] | None = None,
16+
mapping: SupportsGetItem[Incomplete, Incomplete] | None = None,
17+
normalized: bool = True,
1018
): ...
1119
@_dispatchable
1220
def degree_mixing_dict(
13-
G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None, normalized: bool = False
21+
G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes=None, normalized: bool = False
1422
): ...
1523
@_dispatchable
1624
def degree_mixing_matrix(
17-
G,
25+
G: Graph[_Node],
1826
x: str = "out",
1927
y: str = "in",
20-
weight: Incomplete | None = None,
21-
nodes: Incomplete | None = None,
28+
weight: str | None = None,
29+
nodes: Iterable[Incomplete] | None = None,
2230
normalized: bool = True,
23-
mapping: Incomplete | None = None,
31+
mapping: SupportsGetItem[Incomplete, Incomplete] | None = None,
2432
): ...
2533
@_dispatchable
2634
def mixing_dict(xy, normalized: bool = False): ...
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Iterable
23

4+
from networkx.classes.graph import Graph, _Node
35
from networkx.utils.backends import _dispatchable
46

57
@_dispatchable
68
def average_neighbor_degree(
7-
G, source: str = "out", target: str = "out", nodes: Incomplete | None = None, weight: Incomplete | None = None
9+
G: Graph[_Node],
10+
source: str | None = "out",
11+
target: str | None = "out",
12+
nodes: Iterable[Incomplete] | None = None,
13+
weight: str | None = None,
814
): ...
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
from _typeshed import Incomplete
2-
from collections.abc import Generator
2+
from collections.abc import Generator, Iterable
33

4+
from networkx.classes.graph import Graph, _Node
45
from networkx.utils.backends import _dispatchable
56

67
@_dispatchable
7-
def node_attribute_xy(G, attribute, nodes: Incomplete | None = None) -> Generator[Incomplete, None, None]: ...
8+
def node_attribute_xy(
9+
G: Graph[_Node], attribute, nodes: Iterable[Incomplete] | None = None
10+
) -> Generator[Incomplete, None, None]: ...
811
@_dispatchable
912
def node_degree_xy(
10-
G, x: str = "out", y: str = "in", weight: Incomplete | None = None, nodes: Incomplete | None = None
13+
G: Graph[_Node], x: str = "out", y: str = "in", weight: str | None = None, nodes: Iterable[Incomplete] | None = None
1114
) -> Generator[Incomplete, None, None]: ...
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from networkx.classes.graph import Graph, _Node
12
from networkx.utils.backends import _dispatchable
23

34
@_dispatchable
4-
def find_asteroidal_triple(G): ...
5+
def find_asteroidal_triple(G: Graph[_Node]): ...
56
@_dispatchable
6-
def is_at_free(G): ...
7+
def is_at_free(G: Graph[_Node]): ...

stubs/networkx/networkx/algorithms/bipartite/__init__.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ from networkx.algorithms.bipartite.centrality import *
33
from networkx.algorithms.bipartite.cluster import *
44
from networkx.algorithms.bipartite.covering import *
55
from networkx.algorithms.bipartite.edgelist import *
6+
from networkx.algorithms.bipartite.extendability import *
67
from networkx.algorithms.bipartite.generators import *
78
from networkx.algorithms.bipartite.matching import *
89
from networkx.algorithms.bipartite.matrix import *
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Iterable
23

4+
from networkx.classes.graph import Graph, _Node
35
from networkx.utils.backends import _dispatchable
46

57
@_dispatchable
6-
def color(G): ...
8+
def color(G: Graph[_Node]): ...
79
@_dispatchable
8-
def is_bipartite(G): ...
10+
def is_bipartite(G: Graph[_Node]): ...
911
@_dispatchable
10-
def is_bipartite_node_set(G, nodes): ...
12+
def is_bipartite_node_set(G: Graph[_Node], nodes): ...
1113
@_dispatchable
12-
def sets(G, top_nodes: Incomplete | None = None): ...
14+
def sets(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None): ...
1315
@_dispatchable
14-
def density(B, nodes): ...
16+
def density(B: Graph[_Node], nodes): ...
1517
@_dispatchable
16-
def degrees(B, nodes, weight: Incomplete | None = None): ...
18+
def degrees(B: Graph[_Node], nodes, weight: str | None = None): ...

0 commit comments

Comments
 (0)