Skip to content
Open
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
4 changes: 2 additions & 2 deletions stubs/networkx/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version = "3.6.1"
upstream-repository = "https://github.com/networkx/networkx"
# Requires a version of NumPy with `numpy.typing.NDArray`.
version = "3.7"
upstream-repository = "https://github.com/networkx/networkx"
optional-dependencies = ["numpy>=1.21"]

[tool.stubtest]
Expand Down
1 change: 1 addition & 0 deletions stubs/networkx/networkx/algorithms/bipartite/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from networkx.algorithms.bipartite.basic import *
from networkx.algorithms.bipartite.centrality import *
from networkx.algorithms.bipartite.cluster import *
from networkx.algorithms.bipartite.community import *
from networkx.algorithms.bipartite.covering import *
from networkx.algorithms.bipartite.edgelist import *
from networkx.algorithms.bipartite.extendability import *
Expand Down
4 changes: 3 additions & 1 deletion stubs/networkx/networkx/algorithms/bipartite/cluster.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from collections.abc import Callable, Iterable
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable

__all__ = ["clustering", "average_clustering", "latapy_clustering", "robins_alexander_clustering"]
__all__ = ["butterflies", "clustering", "average_clustering", "latapy_clustering", "robins_alexander_clustering"]

def cc_dot(nu, nv) -> float: ...
def cc_max(nu, nv) -> float: ...
Expand All @@ -23,3 +23,5 @@ clustering = latapy_clustering
def average_clustering(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, mode: str = "dot") -> float: ...
@_dispatchable
def robins_alexander_clustering(G: Graph[_Node]) -> float: ...
@_dispatchable
def butterflies(G: Graph[_Node], nodes: Iterable[_Node] | None = None) -> dict[_Node, int]: ...
16 changes: 16 additions & 0 deletions stubs/networkx/networkx/algorithms/bipartite/community.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from collections.abc import Iterable, Set as AbstractSet

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

__all__ = ["modularity"]

@_dispatchable
def modularity(
G: Graph[_Node],
communities: Iterable[AbstractSet[_Node]],
nodes: Iterable[_Node],
*,
weight: str | None = "weight",
resolution: float = 1,
) -> float: ...
8 changes: 7 additions & 1 deletion stubs/networkx/networkx/algorithms/centrality/closeness.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from _typeshed import Incomplete, SupportsKeysAndGetItem
from collections.abc import Mapping

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -7,7 +8,12 @@ __all__ = ["closeness_centrality", "incremental_closeness_centrality"]

@_dispatchable
def closeness_centrality(
G: Graph[_Node], u: _Node | None = None, distance=None, wf_improved: bool | None = True
G: Graph[_Node],
u: _Node | None = None,
distance=None,
wf_improved: bool | None = True,
*,
sp: Mapping[_Node, Mapping[_Node, float]] | None = None,
) -> dict[_Node, float]: ...
@_dispatchable
def incremental_closeness_centrality(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ from collections.abc import Container, Iterable
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable

__all__ = ["is_partition"]
__all__ = ["is_cover", "is_partition"]

@_dispatchable
def is_partition(G: Graph[_Node], communities: Iterable[Container[_Node]]) -> bool: ...
@_dispatchable
def is_cover(G: Graph[_Node], communities: Iterable[Container[_Node]]) -> bool: ...
25 changes: 18 additions & 7 deletions stubs/networkx/networkx/algorithms/community/leiden.pyi
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
from _typeshed import Incomplete
from collections.abc import Generator
from random import Random
from typing import Literal

from networkx._typing import Seed
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
from numpy.random import RandomState

__all__ = ["leiden_communities", "leiden_partitions"]

@_dispatchable
def leiden_communities(
G: Graph[_Node],
*,
weight: str | None = "weight",
resolution: float = 1,
resolution: float = 1.0,
max_level: int | None = None,
seed: int | RandomState | None = None,
) -> list[Incomplete]: ...
seed: Seed | Random | None = None,
metric: Literal["cpm", "modularity"] = "cpm",
theta: float = 0.01,
) -> list[set[_Node]]: ...
@_dispatchable
def leiden_partitions(
G: Graph[_Node], weight: str | None = "weight", resolution: float = 1, seed: int | RandomState | None = None
): ...
G: Graph[_Node],
*,
weight: str | None = "weight",
metric: Literal["cpm", "modularity"] = "cpm",
resolution: float = 1.0,
seed: Seed | Random | None = None,
theta: float = 0.01,
) -> Generator[list[set[_Node]]]: ...
16 changes: 14 additions & 2 deletions stubs/networkx/networkx/algorithms/community/quality.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from _typeshed import Incomplete
from collections.abc import Iterable
from collections.abc import Iterable, Set as AbstractSet

from networkx.classes.graph import Graph, _Node
from networkx.exception import NetworkXError
from networkx.utils.backends import _dispatchable
from networkx.utils.decorators import argmap

__all__ = ["modularity", "partition_quality"]
__all__ = ["constant_potts_model", "overlapping_modularity", "modularity", "partition_quality"]

class NotAPartition(NetworkXError):
def __init__(self, G: Graph[_Node], collection) -> None: ...
Expand All @@ -25,3 +25,15 @@ def modularity(
) -> float: ...
@_dispatchable
def partition_quality(G: Graph[_Node], partition: Iterable[Incomplete]) -> tuple[float, float]: ...
@_dispatchable
def constant_potts_model(
G: Graph[_Node],
communities: Iterable[AbstractSet[_Node]],
weight: str | None = "weight",
node_weight: str | None = "node_weight",
resolution: float = 1,
) -> float: ...
@_dispatchable
def overlapping_modularity(
G: Graph[_Node], communities: Iterable[AbstractSet[_Node]], *, weight: str | None = "weight", resolution: float = 1
) -> float: ...
2 changes: 2 additions & 0 deletions stubs/networkx/networkx/algorithms/dag.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ 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, _NodeData, _EdgeData]) -> DiGraph[_Node, _NodeData, _EdgeData]: ...
@_dispatchable
def antichain_width(G: DiGraph[_Node]) -> int: ...
10 changes: 9 additions & 1 deletion stubs/networkx/networkx/algorithms/distance_measures.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ from networkx.utils.backends import _dispatchable
_WeightFunction: TypeAlias = Callable[..., int]

__all__ = [
"centroid",
"eccentricity",
"diameter",
"harmonic_diameter",
Expand Down Expand Up @@ -51,7 +52,7 @@ def barycenter(
G: Graph[_Node],
weight: str | _WeightFunction | None = None,
attr: str | None = None,
sp: Mapping[_Node, Mapping[_Node, int]] | None = None,
sp: Mapping[_Node, Mapping[_Node, float]] | None = None,
) -> list[_Node]: ...
@_dispatchable
def resistance_distance(
Expand All @@ -61,3 +62,10 @@ def resistance_distance(
def effective_graph_resistance(G: Graph[_Node], weight: str | None = None, invert_weight: bool = True) -> float: ...
@_dispatchable
def kemeny_constant(G: Graph[_Node], *, weight: str | None = None) -> float: ...
@_dispatchable
def centroid(
G: Graph[_Node],
weight: str | _WeightFunction | None = None,
attr: str | None = None,
sp: Mapping[_Node, Mapping[_Node, float]] | None = None,
) -> list[_Node]: ...
3 changes: 2 additions & 1 deletion stubs/networkx/networkx/algorithms/flow/boykovkolmogorov.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from _typeshed import Incomplete

from networkx.algorithms.flow.utils import _CapacityFunc
from networkx.classes.digraph import DiGraph
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -11,7 +12,7 @@ def boykov_kolmogorov(
G: Graph[_Node],
s: _Node,
t: _Node,
capacity: str = "capacity",
capacity: str | _CapacityFunc[_Node] = "capacity",
residual: Graph[_Node] | None = None,
value_only: bool = False,
cutoff: float | None = None,
Expand Down
3 changes: 2 additions & 1 deletion stubs/networkx/networkx/algorithms/flow/dinitz_alg.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from _typeshed import Incomplete

from networkx.algorithms.flow.utils import _CapacityFunc
from networkx.classes.digraph import DiGraph
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -11,7 +12,7 @@ def dinitz(
G: Graph[_Node],
s: _Node,
t: _Node,
capacity: str = "capacity",
capacity: str | _CapacityFunc[_Node] = "capacity",
residual: Graph[_Node] | None = None,
value_only: bool = False,
cutoff: float | None = None,
Expand Down
3 changes: 2 additions & 1 deletion stubs/networkx/networkx/algorithms/flow/edmondskarp.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from _typeshed import Incomplete

from networkx.algorithms.flow.utils import _CapacityFunc
from networkx.classes.digraph import DiGraph
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -11,7 +12,7 @@ def edmonds_karp(
G: Graph[_Node],
s: _Node,
t: _Node,
capacity: str = "capacity",
capacity: str | _CapacityFunc[_Node] = "capacity",
residual: Graph[_Node] | None = None,
value_only: bool = False,
cutoff: float | None = None,
Expand Down
3 changes: 2 additions & 1 deletion stubs/networkx/networkx/algorithms/flow/gomory_hu.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from _typeshed import Incomplete
from collections.abc import Callable

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

Expand All @@ -11,5 +12,5 @@ default_flow_func = edmonds_karp

@_dispatchable
def gomory_hu_tree(
G: Graph[_Node], capacity: str = "capacity", flow_func: Callable[..., Incomplete] | None = None
G: Graph[_Node], capacity: str | _CapacityFunc[_Node] = "capacity", flow_func: Callable[..., Incomplete] | None = None
) -> Graph[Incomplete]: ...
9 changes: 5 additions & 4 deletions stubs/networkx/networkx/algorithms/flow/maxflow.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from _typeshed import Incomplete
from collections.abc import Callable

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

Expand All @@ -14,7 +15,7 @@ def maximum_flow(
flowG: Graph[_Node],
_s: _Node,
_t: _Node,
capacity: str = "capacity",
capacity: str | _CapacityFunc[_Node] = "capacity",
flow_func: Callable[..., Incomplete] | None = None,
**kwargs,
) -> tuple[int | float, dict[Incomplete, Incomplete]]: ...
Expand All @@ -23,7 +24,7 @@ def maximum_flow_value(
flowG: Graph[_Node],
_s: _Node,
_t: _Node,
capacity: str = "capacity",
capacity: str | _CapacityFunc[_Node] = "capacity",
flow_func: Callable[..., Incomplete] | None = None,
**kwargs,
) -> int | float: ...
Expand All @@ -32,7 +33,7 @@ def minimum_cut(
flowG: Graph[_Node],
_s: _Node,
_t: _Node,
capacity: str = "capacity",
capacity: str | _CapacityFunc[_Node] = "capacity",
flow_func: Callable[..., Incomplete] | None = None,
**kwargs,
) -> tuple[int | float, tuple[set[Incomplete], set[Incomplete]]]: ...
Expand All @@ -41,7 +42,7 @@ def minimum_cut_value(
flowG: Graph[_Node],
_s: _Node,
_t: _Node,
capacity: str = "capacity",
capacity: str | _CapacityFunc[_Node] = "capacity",
flow_func: Callable[..., Incomplete] | None = None,
**kwargs,
) -> int | float: ...
3 changes: 2 additions & 1 deletion stubs/networkx/networkx/algorithms/flow/preflowpush.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from _typeshed import Incomplete

from networkx.algorithms.flow.utils import _CapacityFunc
from networkx.classes.digraph import DiGraph
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -11,7 +12,7 @@ def preflow_push(
G: Graph[_Node],
s: _Node,
t: _Node,
capacity: str = "capacity",
capacity: str | _CapacityFunc[_Node] = "capacity",
residual: Graph[_Node] | None = None,
global_relabel_freq: float = 1,
value_only: bool = False,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from _typeshed import Incomplete

from networkx.algorithms.flow.utils import _CapacityFunc
from networkx.classes.digraph import DiGraph
from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -11,7 +12,7 @@ def shortest_augmenting_path(
G: Graph[_Node],
s: _Node,
t: _Node,
capacity: str = "capacity",
capacity: str | _CapacityFunc[_Node] = "capacity",
residual: Graph[_Node] | None = None,
value_only: bool = False,
two_phase: bool = False,
Expand Down
13 changes: 10 additions & 3 deletions stubs/networkx/networkx/algorithms/flow/utils.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from _typeshed import Incomplete
from typing import overload
from collections.abc import Callable
from typing import Any, TypeAlias, overload
from typing_extensions import Never, deprecated

from networkx.classes.graph import Graph, _Node
Expand Down Expand Up @@ -29,11 +30,17 @@ class GlobalRelabelThreshold:

@overload
@deprecated("MultiGraph and MultiDiGraph not supported (yet).")
def build_residual_network(G: MultiGraph[_Node], capacity, *, backend: str | None = None, **backend_kwargs) -> Never: ...
def build_residual_network(
G: MultiGraph[_Node], capacity: str | _CapacityFunc[_Node], *, backend: str | None = None, **backend_kwargs
) -> Never: ...
@overload
def build_residual_network(G: Graph[_Node], capacity, *, backend: str | None = None, **backend_kwargs): ...
def build_residual_network(
G: Graph[_Node], capacity: str | _CapacityFunc[_Node], *, backend: str | None = None, **backend_kwargs
): ...

@_dispatchable
def detect_unboundedness(R, s, t) -> None: ...
@_dispatchable
def build_flow_dict(G: Graph[_Node], R): ...

_CapacityFunc: TypeAlias = Callable[[_Node, _Node, dict[str, Any]], float]
2 changes: 2 additions & 0 deletions stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ class ISMAGS:
def subgraph_is_isomorphic(self, symmetry: bool = False) -> bool: ...
def isomorphisms_iter(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete]: ...
def subgraph_isomorphisms_iter(self, symmetry: bool = True): ...
def is_monomorphic(self, symmetry: bool = False) -> bool: ...
def monomorphisms_iter(self, symmetry: bool = True) -> Generator[dict[Hashable, Hashable]]: ...
13 changes: 0 additions & 13 deletions stubs/networkx/networkx/algorithms/isomorphism/isomorph.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from _typeshed import Incomplete
from collections.abc import Callable
from typing_extensions import deprecated

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -9,22 +8,10 @@ __all__ = ["could_be_isomorphic", "fast_could_be_isomorphic", "faster_could_be_i

@_dispatchable
def could_be_isomorphic(G1: Graph[_Node], G2: Graph[_Node], *, properties: str = "dtc") -> bool: ...
@deprecated("`graph_could_be_isomorphic` is a deprecated alias for `could_be_isomorphic`. Use `could_be_isomorphic` instead.")
def graph_could_be_isomorphic(G1: Graph[_Node], G2: Graph[_Node]) -> bool: ...
@_dispatchable
def fast_could_be_isomorphic(G1: Graph[_Node], G2: Graph[_Node]) -> bool: ...
@deprecated(
"`fast_graph_could_be_isomorphic` is a deprecated alias for `fast_could_be_isomorphic`. "
"Use `fast_could_be_isomorphic` instead."
)
def fast_graph_could_be_isomorphic(G1: Graph[_Node], G2: Graph[_Node]) -> bool: ...
@_dispatchable
def faster_could_be_isomorphic(G1: Graph[_Node], G2: Graph[_Node]) -> bool: ...
@deprecated(
"`faster_graph_could_be_isomorphic` is a deprecated alias for `faster_could_be_isomorphic`. "
"Use `faster_could_be_isomorphic` instead."
)
def faster_graph_could_be_isomorphic(G1: Graph[_Node], G2: Graph[_Node]) -> bool: ...
@_dispatchable
def is_isomorphic(
G1: Graph[_Node],
Expand Down
Loading
Loading