networkx: improve the distance_measures module (#14461)

This commit is contained in:
Ali Hamdan
2025-07-26 16:23:49 +02:00
committed by GitHub
parent 4860c36f01
commit afc1faa86b
@@ -1,5 +1,4 @@
from _typeshed import Incomplete
from collections.abc import Callable
from collections.abc import Callable, Mapping
from typing_extensions import TypeAlias
from networkx.classes.graph import Graph, _Node
@@ -22,27 +21,43 @@ __all__ = [
@_dispatchable
def eccentricity(
G: Graph[_Node], v: _Node | None = None, sp=None, weight: str | _WeightFunction | None = None
) -> Incomplete | dict[Incomplete, Incomplete]: ...
G: Graph[_Node],
v: _Node | None = None,
sp: Mapping[_Node, Mapping[_Node, int]] | None = None,
weight: str | _WeightFunction | None = None,
) -> int | dict[_Node, int]: ... # TODO: overload on v: dict if v is None else int
@_dispatchable
def diameter(G: Graph[_Node], e=None, usebounds: bool = False, weight: str | _WeightFunction | None = None): ...
def diameter(
G: Graph[_Node], e: Mapping[_Node, int] | None = None, usebounds: bool = False, weight: str | _WeightFunction | None = None
) -> int: ...
@_dispatchable
def harmonic_diameter(G, sp=None, *, weight: str | _WeightFunction | None = None) -> float: ...
def harmonic_diameter(
G: Graph[_Node], sp: Mapping[_Node, Mapping[_Node, int]] | None = None, *, weight: str | _WeightFunction | None = None
) -> float: ...
@_dispatchable
def periphery(
G: Graph[_Node], e=None, usebounds: bool = False, weight: str | _WeightFunction | None = None
) -> list[Incomplete]: ...
G: Graph[_Node], e: Mapping[_Node, int] | None = None, usebounds: bool = False, weight: str | _WeightFunction | None = None
) -> list[_Node]: ...
@_dispatchable
def radius(G: Graph[_Node], e=None, usebounds: bool = False, weight: str | _WeightFunction | None = None): ...
def radius(
G: Graph[_Node], e: Mapping[_Node, int] | None = None, usebounds: bool = False, weight: str | _WeightFunction | None = None
) -> int: ...
@_dispatchable
def center(G: Graph[_Node], e=None, usebounds: bool = False, weight: str | _WeightFunction | None = None) -> list[Incomplete]: ...
def center(
G: Graph[_Node], e: Mapping[_Node, int] | None = None, usebounds: bool = False, weight: str | _WeightFunction | None = None
) -> list[_Node]: ...
@_dispatchable
def barycenter(G, weight: str | _WeightFunction | None = None, attr=None, sp=None) -> list[Incomplete]: ...
def barycenter(
G: Graph[_Node],
weight: str | _WeightFunction | None = None,
attr: str | None = None,
sp: Mapping[_Node, Mapping[_Node, int]] | None = None,
) -> list[_Node]: ...
@_dispatchable
def resistance_distance(
G: Graph[_Node], nodeA=None, nodeB=None, weight: str | None = None, invert_weight: bool = True
) -> float | dict[Incomplete, float]: ...
G: Graph[_Node], nodeA: _Node | None = None, nodeB: _Node | None = None, weight: str | None = None, invert_weight: bool = True
) -> float | dict[_Node, float]: ... # TODO: overload on the nodes: float if both are specified else dict
@_dispatchable
def effective_graph_resistance(G, weight: str | None = None, invert_weight: bool = True) -> float: ...
def effective_graph_resistance(G: Graph[_Node], weight: str | None = None, invert_weight: bool = True) -> float: ...
@_dispatchable
def kemeny_constant(G, *, weight: str | None = None) -> float: ...
def kemeny_constant(G: Graph[_Node], *, weight: str | None = None) -> float: ...