Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stubs/networkx/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.5"
version = "3.6"
upstream_repository = "https://github.com/networkx/networkx"
# requires a version of numpy with a `py.typed` file
requires = ["numpy>=1.20"]
Expand Down
1 change: 1 addition & 0 deletions stubs/networkx/networkx/algorithms/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ from networkx.algorithms.mis import *
from networkx.algorithms.moral import *
from networkx.algorithms.non_randomness import *
from networkx.algorithms.operators import *
from networkx.algorithms.perfect_graph import *
from networkx.algorithms.planar_drawing import *
from networkx.algorithms.planarity import *
from networkx.algorithms.polynomials import *
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from _typeshed import Incomplete
from collections.abc import Iterable
from typing_extensions import deprecated

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable

__all__ = ["metric_closure", "steiner_tree"]

@_dispatchable
@deprecated(
"`metric_closure` is deprecated and will be removed in NetworkX 3.8. Use `networkx.all_pairs_shortest_path_length` instead."
)
def metric_closure(G: Graph[_Node], weight="weight"): ...
@_dispatchable
def steiner_tree(G: Graph[_Node], terminal_nodes: Iterable[Incomplete], weight: str = "weight", method: str | None = None): ...
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def approximate_current_flow_betweenness_centrality(
epsilon: float = 0.5,
kmax: int = 10000,
seed: int | RandomState | None = None,
*,
sample_weight: float = 1,
) -> dict[Incomplete, float]: ...
@_dispatchable
def current_flow_betweenness_centrality(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ from networkx.utils.backends import _dispatchable
__all__ = ["subgraph_centrality_exp", "subgraph_centrality", "communicability_betweenness_centrality", "estrada_index"]

@_dispatchable
def subgraph_centrality_exp(G: Graph[_Node]) -> dict[Incomplete, float]: ...
def subgraph_centrality_exp(G: Graph[_Node], *, normalized: bool = False) -> dict[Incomplete, float]: ...
@_dispatchable
def subgraph_centrality(G: Graph[_Node]) -> dict[Incomplete, float]: ...
def subgraph_centrality(G: Graph[_Node], *, normalized: bool = False) -> dict[Incomplete, float]: ...
@_dispatchable
def communicability_betweenness_centrality(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
Expand Down
16 changes: 13 additions & 3 deletions stubs/networkx/networkx/algorithms/cluster.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
from _typeshed import Incomplete
from collections.abc import Iterable
from collections.abc import Generator, Iterable

from networkx.classes.graph import Graph, _Node
from networkx.classes.graph import Graph, _NBunch, _Node
from networkx.utils.backends import _dispatchable

__all__ = ["triangles", "average_clustering", "clustering", "transitivity", "square_clustering", "generalized_degree"]
__all__ = [
"triangles",
"all_triangles",
"average_clustering",
"clustering",
"transitivity",
"square_clustering",
"generalized_degree",
]

@_dispatchable
def triangles(G: Graph[_Node], nodes=None) -> int | dict[Incomplete, int]: ...
@_dispatchable
def all_triangles(G: Graph[_Node], nbunch: _NBunch[_Node] = None) -> Generator[tuple[Incomplete, Incomplete, Incomplete]]: ...
@_dispatchable
def average_clustering(
G: Graph[_Node], nodes: Iterable[_Node] | None = None, weight: str | None = None, count_zeros: bool = True
) -> float: ...
Expand Down
3 changes: 0 additions & 3 deletions stubs/networkx/networkx/algorithms/dag.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ __all__ = [
"dag_longest_path",
"dag_longest_path_length",
"dag_to_branching",
"compute_v_structures",
]

@_dispatchable
Expand Down Expand Up @@ -61,5 +60,3 @@ def dag_longest_path(
def dag_longest_path_length(G: DiGraph[_Node], weight: str | None = "weight", default_weight: int | None = 1) -> int: ...
@_dispatchable
def dag_to_branching(G: DiGraph[_Node]) -> DiGraph[_Node]: ...
@_dispatchable
def compute_v_structures(G: DiGraph[_Node]) -> Generator[tuple[Incomplete, Incomplete, Incomplete]]: ...
4 changes: 2 additions & 2 deletions stubs/networkx/networkx/algorithms/distance_regular.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ __all__ = ["is_distance_regular", "is_strongly_regular", "intersection_array", "
@_dispatchable
def is_distance_regular(G: Graph[_Node]) -> bool: ...
@_dispatchable
def global_parameters(b, c) -> Generator[tuple[Incomplete, Incomplete, Incomplete]]: ...
def global_parameters(b: list[Incomplete], c: list[Incomplete]) -> Generator[tuple[Incomplete, Incomplete, Incomplete]]: ...
@_dispatchable
def intersection_array(G: Graph[_Node]): ...
def intersection_array(G: Graph[_Node]) -> tuple[list[Incomplete], list[Incomplete]]: ...
@_dispatchable
def is_strongly_regular(G: Graph[_Node]) -> bool: ...
21 changes: 17 additions & 4 deletions stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
from _typeshed import Incomplete
from collections.abc import Generator
from collections.abc import Callable, Generator, Hashable, Iterable
from typing import Any

__all__ = ["ISMAGS"]

def are_all_equal(iterable: Iterable[Any]) -> bool: ...
def make_partition(
items: Iterable[Hashable], test: Callable[[Hashable, Hashable], bool], check: bool = True
) -> list[set[Incomplete]]: ...
def node_to_part_ID_dict(partition: Iterable[Iterable[Incomplete]]) -> dict[Incomplete, int]: ...
def color_degree_by_node(G, n_colors, e_colors): ...

class EdgeLookup:
edge_dict: Incomplete
def __init__(self, edge_dict) -> None: ...
def __getitem__(self, edge): ...
def items(self): ...

class ISMAGS:
graph: Incomplete
subgraph: Incomplete
node_equality: Incomplete
edge_equality: Incomplete

def __init__(self, graph, subgraph, node_match=None, edge_match=None, cache=None) -> None: ...
def create_aligned_partitions(self, thing_matcher, sg_things, g_things): ...
def find_isomorphisms(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, Incomplete]: ...
def largest_common_subgraph(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, None]: ...
def analyze_symmetry(self, graph, node_partitions, edge_colors): ...
def analyze_subgraph_symmetry(self) -> dict[Hashable, set[Hashable]]: ...
def is_isomorphic(self, symmetry: bool = False) -> bool: ...
def subgraph_is_isomorphic(self, symmetry: bool = False) -> bool: ...
def isomorphisms_iter(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, None]: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/networkx/networkx/algorithms/non_randomness.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ from networkx.utils.backends import _dispatchable
__all__ = ["non_randomness"]

@_dispatchable
def non_randomness(G: Graph[_Node], k: int | None = None, weight: str | None = "weight"): ...
def non_randomness(G: Graph[_Node], k: int | None = None, weight: str | None = "weight") -> tuple[float, float]: ...
7 changes: 7 additions & 0 deletions stubs/networkx/networkx/algorithms/perfect_graph.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable

__all__ = ["is_perfect_graph"]

@_dispatchable
def is_perfect_graph(G: Graph[_Node]) -> bool: ...
18 changes: 17 additions & 1 deletion stubs/networkx/networkx/algorithms/similarity.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ __all__ = [
"optimize_edit_paths",
"simrank_similarity",
"panther_similarity",
"panther_vector_similarity",
"generate_random_paths",
]

Expand Down Expand Up @@ -93,10 +94,25 @@ def panther_similarity(
path_length: int = 5,
c: float = 0.5,
delta: float = 0.1,
eps=None,
eps: float | None = None,
weight: str | None = "weight",
seed: int | RandomState | None = None,
) -> dict[bytes, bytes]: ...
@_dispatchable
def panther_vector_similarity(
G: Graph[_Node],
source: _Node,
*,
D: int = 10,
k: int = 5,
path_length: int = 5,
c: float = 0.5,
delta: float = 0.1,
eps: float | None = None,
weight: str | None = "weight",
seed: int | RandomState | None = None,
) -> dict[Incomplete, float]: ...
@_dispatchable
def generate_random_paths(
G: Graph[_Node],
sample_size: int,
Expand Down
1 change: 0 additions & 1 deletion stubs/networkx/networkx/algorithms/threshold.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ def eigenvalues(creation_sequence): ...
def random_threshold_sequence(n, p, seed: int | RandomState | None = None): ...
def right_d_threshold_sequence(n: int, m: int) -> list[str]: ...
def left_d_threshold_sequence(n: int, m: int) -> list[str]: ...
def swap_d(cs, p_split=1.0, p_combine=1.0, seed: int | RandomState | None = None): ...
1 change: 1 addition & 0 deletions stubs/networkx/networkx/algorithms/tree/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .branchings import *
from .coding import *
from .decomposition import *
from .distance_measures import *
from .mst import *
from .operations import *
from .recognition import *
10 changes: 10 additions & 0 deletions stubs/networkx/networkx/algorithms/tree/distance_measures.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from _typeshed import Incomplete

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable

__all__ = ["center", "centroid"]

def center(G: Graph[_Node]) -> list[Incomplete]: ...
@_dispatchable
def centroid(G: Graph[_Node]) -> list[Incomplete]: ...
4 changes: 3 additions & 1 deletion stubs/networkx/networkx/algorithms/wiener.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable

__all__ = ["wiener_index", "schultz_index", "gutman_index"]
__all__ = ["wiener_index", "schultz_index", "gutman_index", "hyper_wiener_index"]

@_dispatchable
def wiener_index(G: Graph[_Node], weight: str | None = None) -> float: ...
@_dispatchable
def schultz_index(G: Graph[_Node], weight=None) -> float: ...
@_dispatchable
def gutman_index(G: Graph[_Node], weight=None) -> float: ...
@_dispatchable
def hyper_wiener_index(G: Graph[_Node], weight=None) -> float: ...
4 changes: 3 additions & 1 deletion stubs/networkx/networkx/classes/function.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from _typeshed import Incomplete, SupportsItems, SupportsKeysAndGetItem, Unused
from collections.abc import Generator, Hashable, Iterable, Iterator
from collections.abc import Callable, Generator, Hashable, Iterable, Iterator
from typing import Literal, TypeVar, overload

from networkx import _dispatchable
Expand Down Expand Up @@ -48,6 +48,7 @@ __all__ = [
"number_of_selfloops",
"path_weight",
"is_path",
"describe",
]

_U = TypeVar("_U")
Expand Down Expand Up @@ -171,3 +172,4 @@ def selfloop_edges(
def number_of_selfloops(G: Graph[Hashable]) -> int: ...
def is_path(G: Graph[_Node], path: Iterable[Incomplete]) -> bool: ...
def path_weight(G: Graph[_Node], path, weight) -> int: ...
def describe(G: Graph[_Node], describe_hook: Callable[[Graph[_Node]], dict[str, Incomplete]] | None = None) -> None: ...
3 changes: 3 additions & 0 deletions stubs/networkx/networkx/classes/graph.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class Graph(Collection[_Node]):

def to_directed_class(self) -> type[DiGraph[_Node]]: ...
def to_undirected_class(self) -> type[Graph[_Node]]: ...
# @_dispatchable adds `backend` argument, but this decorated is unsupported constructor type here
# and __init__() ignores this argument
def __new__(cls, incoming_graph_data: _Data[_Node] | None = None, *, backend=None, **attr: Any) -> Self: ...
def __init__(self, incoming_graph_data: _Data[_Node] | None = None, **attr: Any) -> None: ... # attr: key=value pairs
@cached_property
def adj(self) -> AdjacencyView[_Node, _Node, dict[str, Any]]: ...
Expand Down
5 changes: 4 additions & 1 deletion stubs/networkx/networkx/classes/multigraph.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections.abc import Hashable
from functools import cached_property
from typing import Any, ClassVar, overload
from typing_extensions import TypeAlias, TypeVar
from typing_extensions import Self, TypeAlias, TypeVar

from networkx.classes.coreviews import MultiAdjacencyView
from networkx.classes.graph import Graph, _MapFactory, _Node
Expand All @@ -22,6 +22,9 @@ class MultiGraph(Graph[_Node]):
edge_key_dict_factory: ClassVar[_MapFactory]
def to_directed_class(self) -> type[MultiDiGraph[_Node]]: ...
def to_undirected_class(self) -> type[MultiGraph[_Node]]: ...
# @_dispatchable adds `backend` argument, but this decorated is unsupported constructor type here
# and __init__() ignores this argument
def __new__(cls, incoming_graph_data=None, multigraph_input: bool | None = None, *, backend=None, **attr: Any) -> Self: ...
def __init__(self, incoming_graph_data=None, multigraph_input: bool | None = None, **attr: Any) -> None: ...
@cached_property
def adj(self) -> MultiAdjacencyView[_Node, _Node, dict[str, Any]]: ... # data can be any type
Expand Down
1 change: 0 additions & 1 deletion stubs/networkx/networkx/drawing/layout.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ def forceatlas2_layout(
node_mass: Mapping[_Node, float] | None = None,
node_size: Mapping[_Node, float] | None = None,
weight: str | None = None,
dissuade_hubs: bool = False,
linlog: bool = False,
seed: Seed | None = None,
dim: int = 2,
Expand Down
20 changes: 20 additions & 0 deletions stubs/networkx/networkx/drawing/nx_pylab.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,26 @@ def apply_matplotlib_colors(
vmax: float | None = None,
nodes: bool = True,
) -> None: ...

class CurvedArrowTextBase:
arrow: FancyArrowPatch
label_pos: float
labels_horizontal: bool
ax: Axes
x: Incomplete
y: Incomplete
angle: Incomplete
def __init__(
self,
arrow: FancyArrowPatch,
*args,
label_pos: float = 0.5,
labels_horizontal: bool = False,
ax: Axes | None = None,
**kwargs,
) -> None: ...
def draw(self, renderer) -> None: ...

def display(
G: _G,
canvas: Axes | None = None,
Expand Down
10 changes: 9 additions & 1 deletion stubs/networkx/networkx/generators/expanders.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing_extensions import deprecated

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable

Expand All @@ -6,6 +8,7 @@ __all__ = [
"chordal_cycle_graph",
"paley_graph",
"maybe_regular_expander",
"maybe_regular_expander_graph",
"is_regular_expander",
"random_regular_expander_graph",
]
Expand All @@ -17,7 +20,12 @@ def chordal_cycle_graph(p, create_using=None): ...
@_dispatchable
def paley_graph(p, create_using=None): ...
@_dispatchable
def maybe_regular_expander(n, d, *, create_using=None, max_tries=100, seed=None): ...
def maybe_regular_expander_graph(n, d, *, create_using=None, max_tries: int = 100, seed=None): ...
@deprecated(
"`maybe_regular_expander` is a deprecated alias for `maybe_regular_expander_graph`. "
"Use `maybe_regular_expander_graph` instead."
)
def maybe_regular_expander(n, d, *, create_using=None, max_tries: int = 100, seed=None): ...
@_dispatchable
def is_regular_expander(G: Graph[_Node], *, epsilon: float = 0) -> bool: ...
@_dispatchable
Expand Down
Loading