[networkx] Update to 3.6 (#15086)

This commit is contained in:
Semyon Moroz
2025-11-26 14:00:34 +01:00
committed by GitHub
parent d38b648723
commit 9960107707
27 changed files with 152 additions and 64 deletions
+1 -1
View File
@@ -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"]
@@ -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 *
@@ -1,5 +1,6 @@
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
@@ -7,6 +8,9 @@ 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): ...
@@ -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(
@@ -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
+13 -3
View File
@@ -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: ...
@@ -21,7 +21,6 @@ __all__ = [
"dag_longest_path",
"dag_longest_path_length",
"dag_to_branching",
"compute_v_structures",
]
@_dispatchable
@@ -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]]: ...
@@ -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: ...
@@ -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]: ...
@@ -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]: ...
@@ -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: ...
@@ -12,6 +12,7 @@ __all__ = [
"optimize_edit_paths",
"simrank_similarity",
"panther_similarity",
"panther_vector_similarity",
"generate_random_paths",
]
@@ -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,
@@ -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,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 *
@@ -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]: ...
@@ -1,7 +1,7 @@
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: ...
@@ -9,3 +9,5 @@ def wiener_index(G: Graph[_Node], weight: str | None = None) -> float: ...
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: ...
+3 -1
View File
@@ -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
@@ -48,6 +48,7 @@ __all__ = [
"number_of_selfloops",
"path_weight",
"is_path",
"describe",
]
_U = TypeVar("_U")
@@ -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: ...
@@ -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]]: ...
@@ -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
@@ -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
@@ -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,
@@ -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,
@@ -1,3 +1,5 @@
from typing_extensions import deprecated
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
@@ -6,6 +8,7 @@ __all__ = [
"chordal_cycle_graph",
"paley_graph",
"maybe_regular_expander",
"maybe_regular_expander_graph",
"is_regular_expander",
"random_regular_expander_graph",
]
@@ -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
@@ -1,4 +1,5 @@
from _typeshed import Incomplete
from typing_extensions import deprecated
from networkx.utils.backends import _dispatchable
@@ -20,6 +21,7 @@ __all__ = [
"extended_barabasi_albert_graph",
"powerlaw_cluster_graph",
"random_lobster",
"random_lobster_graph",
"random_shell_graph",
"random_powerlaw_tree",
"random_powerlaw_tree_sequence",
@@ -27,40 +29,43 @@ __all__ = [
]
@_dispatchable
def fast_gnp_random_graph(n, p, seed=None, directed: bool = False): ...
def fast_gnp_random_graph(n, p, seed=None, directed: bool = False, *, create_using=None): ...
@_dispatchable
def gnp_random_graph(n, p, seed=None, directed: bool = False): ...
def gnp_random_graph(n, p, seed=None, directed: bool = False, *, create_using=None): ...
binomial_graph = gnp_random_graph
erdos_renyi_graph = gnp_random_graph
@_dispatchable
def dense_gnm_random_graph(n, m, seed=None): ...
def dense_gnm_random_graph(n, m, seed=None, *, create_using=None): ...
@_dispatchable
def gnm_random_graph(n, m, seed=None, directed: bool = False): ...
def gnm_random_graph(n, m, seed=None, directed: bool = False, *, create_using=None): ...
@_dispatchable
def newman_watts_strogatz_graph(n, k, p, seed=None): ...
def newman_watts_strogatz_graph(n, k, p, seed=None, *, create_using=None): ...
@_dispatchable
def watts_strogatz_graph(n, k, p, seed=None): ...
def watts_strogatz_graph(n, k, p, seed=None, *, create_using=None): ...
@_dispatchable
def connected_watts_strogatz_graph(n, k, p, tries: int = 100, seed=None): ...
def connected_watts_strogatz_graph(n, k, p, tries: int = 100, seed=None, *, create_using=None): ...
@_dispatchable
def random_regular_graph(d, n, seed=None): ...
def random_regular_graph(d, n, seed=None, *, create_using=None): ...
@_dispatchable
def barabasi_albert_graph(n, m, seed=None, initial_graph=None) -> Graph[Incomplete]: ...
def barabasi_albert_graph(n, m, seed=None, initial_graph=None, *, create_using=None) -> Graph[Incomplete]: ...
@_dispatchable
def dual_barabasi_albert_graph(n, m1, m2, p, seed=None, initial_graph=None) -> Graph[Incomplete]: ...
def dual_barabasi_albert_graph(n, m1, m2, p, seed=None, initial_graph=None, *, create_using=None) -> Graph[Incomplete]: ...
@_dispatchable
def extended_barabasi_albert_graph(n, m, p, q, seed=None) -> Graph[Incomplete]: ...
def extended_barabasi_albert_graph(n, m, p, q, seed=None, *, create_using=None) -> Graph[Incomplete]: ...
@_dispatchable
def powerlaw_cluster_graph(n, m, p, seed=None): ...
def powerlaw_cluster_graph(n, m, p, seed=None, *, create_using=None): ...
@_dispatchable
def random_lobster(n, p1, p2, seed=None): ...
def random_lobster_graph(n, p1, p2, seed=None, *, create_using=None): ...
@_dispatchable
def random_shell_graph(constructor, seed=None): ...
@deprecated("`random_lobster` is a deprecated alias for `random_lobster_graph`. Use `random_lobster_graph` instead.")
def random_lobster(n, p1, p2, seed=None, *, create_using=None): ...
@_dispatchable
def random_powerlaw_tree(n, gamma: float = 3, seed=None, tries: int = 100): ...
def random_shell_graph(constructor, seed=None, *, create_using=None): ...
@_dispatchable
def random_powerlaw_tree(n, gamma: float = 3, seed=None, tries: int = 100, *, create_using=None): ...
@_dispatchable
def random_powerlaw_tree_sequence(n, gamma: float = 3, seed=None, tries: int = 100): ...
@_dispatchable
def random_kernel_graph(n, kernel_integral, kernel_root=None, seed=None): ...
def random_kernel_graph(n, kernel_integral, kernel_root=None, seed=None, *, create_using=None): ...
@@ -9,6 +9,7 @@ __all__ = [
"diamond_graph",
"dodecahedral_graph",
"frucht_graph",
"generalized_petersen_graph",
"heawood_graph",
"hoffman_singleton_graph",
"house_graph",
@@ -63,6 +64,8 @@ def pappus_graph(): ...
@_dispatchable
def petersen_graph(create_using=None): ...
@_dispatchable
def generalized_petersen_graph(n: int, k: int, *, create_using=None): ...
@_dispatchable
def sedgewick_maze_graph(create_using=None): ...
@_dispatchable
def tetrahedral_graph(create_using=None): ...
@@ -1,29 +1,8 @@
from typing import overload
from typing_extensions import deprecated
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
__all__ = ["node_link_data", "node_link_graph"]
@overload
@deprecated(
"""\
The `link` argument is deprecated and will be removed in version `3.6`.
Use the `edges` keyword instead."""
)
def node_link_data(
G: Graph[_Node],
*,
link: str | None,
source: str = "source",
target: str = "target",
name: str = "id",
key: str = "key",
edges: str | None = None,
nodes: str = "nodes",
): ...
@overload
def node_link_data(
G: Graph[_Node],
*,
@@ -31,7 +10,7 @@ def node_link_data(
target: str = "target",
name: str = "id",
key: str = "key",
edges: str | None = None,
edges: str = "edges",
nodes: str = "nodes",
): ...
@_dispatchable
@@ -45,7 +24,6 @@ def node_link_graph(
target: str = "target",
name: str = "id",
key: str = "key",
edges: str | None = None,
edges: str = "edges",
nodes: str = "nodes",
link: str | None = None,
): ...
+1 -1
View File
@@ -59,6 +59,6 @@ class PythonRandomInterface:
def create_py_random_state(random_state: _RandomState = None): ...
def nodes_equal(nodes1, nodes2) -> bool: ...
def edges_equal(edges1, edges2) -> bool: ...
def edges_equal(edges1, edges2, *, directed: bool = False) -> bool: ...
def graphs_equal(graph1, graph2) -> bool: ...
def _clear_cache(G: Graph[_Node]) -> None: ...
@@ -1,5 +1,9 @@
from _typeshed import Incomplete
from collections.abc import Iterable
__all__ = [
"powerlaw_sequence",
"is_valid_tree_degree_sequence",
"zipf_rv",
"cumulative_distribution",
"discrete_sequence",
@@ -8,6 +12,7 @@ __all__ = [
]
def powerlaw_sequence(n, exponent: float = 2.0, seed=None): ...
def is_valid_tree_degree_sequence(degree_sequence: Iterable[Incomplete]) -> tuple[bool, str]: ...
def zipf_rv(alpha, xmin: int = 1, seed=None) -> int: ...
def cumulative_distribution(distribution): ...
def discrete_sequence(n, distribution=None, cdistribution=None, seed=None): ...