Skip to content

Commit

Permalink
fix: weight parameter type for networkx.algorithms.shortest_paths (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Sunglasses authored Sep 17, 2024
1 parent 0015ce8 commit eb7df6d
Showing 1 changed file with 35 additions and 26 deletions.
61 changes: 35 additions & 26 deletions stubs/networkx/networkx/algorithms/shortest_paths/weighted.pyi
Original file line number Diff line number Diff line change
@@ -1,63 +1,72 @@
from _typeshed import Incomplete
from collections.abc import Generator
from collections.abc import Callable, Generator
from typing import Any
from typing_extensions import TypeAlias

from networkx.utils.backends import _dispatch

# type alias for the weight function
_WeightFunction: TypeAlias = Callable[[Any, Any, dict[str, Any]], float | None]

@_dispatch
def dijkstra_path(G, source, target, weight: str = "weight"): ...
def dijkstra_path(G, source, target, weight: str | _WeightFunction = "weight"): ...
@_dispatch
def dijkstra_path_length(G, source, target, weight: str = "weight"): ...
def dijkstra_path_length(G, source, target, weight: str | _WeightFunction = "weight"): ...
@_dispatch
def single_source_dijkstra_path(G, source, cutoff: Incomplete | None = None, weight: str = "weight"): ...
def single_source_dijkstra_path(G, source, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight"): ...
@_dispatch
def single_source_dijkstra_path_length(G, source, cutoff: Incomplete | None = None, weight: str = "weight"): ...
def single_source_dijkstra_path_length(G, source, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight"): ...
@_dispatch
def single_source_dijkstra(
G, source, target: Incomplete | None = None, cutoff: Incomplete | None = None, weight: str = "weight"
G, source, target: Incomplete | None = None, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight"
): ...
@_dispatch
def multi_source_dijkstra_path(G, sources, cutoff: Incomplete | None = None, weight: str = "weight"): ...
def multi_source_dijkstra_path(G, sources, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight"): ...
@_dispatch
def multi_source_dijkstra_path_length(G, sources, cutoff: Incomplete | None = None, weight: str = "weight"): ...
def multi_source_dijkstra_path_length(G, sources, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight"): ...
@_dispatch
def multi_source_dijkstra(
G, sources, target: Incomplete | None = None, cutoff: Incomplete | None = None, weight: str = "weight"
G, sources, target: Incomplete | None = None, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight"
): ...
@_dispatch
def dijkstra_predecessor_and_distance(G, source, cutoff: Incomplete | None = None, weight: str = "weight"): ...
def dijkstra_predecessor_and_distance(G, source, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight"): ...
@_dispatch
def all_pairs_dijkstra(G, cutoff: Incomplete | None = None, weight: str = "weight") -> Generator[Incomplete, None, None]: ...
def all_pairs_dijkstra(
G, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight"
) -> Generator[Incomplete, None, None]: ...
@_dispatch
def all_pairs_dijkstra_path_length(
G, cutoff: Incomplete | None = None, weight: str = "weight"
G, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight"
) -> Generator[Incomplete, None, None]: ...
@_dispatch
def all_pairs_dijkstra_path(G, cutoff: Incomplete | None = None, weight: str = "weight") -> Generator[Incomplete, None, None]: ...
def all_pairs_dijkstra_path(
G, cutoff: Incomplete | None = None, weight: str | _WeightFunction = "weight"
) -> Generator[Incomplete, None, None]: ...
@_dispatch
def bellman_ford_predecessor_and_distance(
G, source, target: Incomplete | None = None, weight: str = "weight", heuristic: bool = False
G, source, target: Incomplete | None = None, weight: str | _WeightFunction = "weight", heuristic: bool = False
): ...
@_dispatch
def bellman_ford_path(G, source, target, weight: str = "weight"): ...
def bellman_ford_path(G, source, target, weight: str | _WeightFunction = "weight"): ...
@_dispatch
def bellman_ford_path_length(G, source, target, weight: str = "weight"): ...
def bellman_ford_path_length(G, source, target, weight: str | _WeightFunction = "weight"): ...
@_dispatch
def single_source_bellman_ford_path(G, source, weight: str = "weight"): ...
def single_source_bellman_ford_path(G, source, weight: str | _WeightFunction = "weight"): ...
@_dispatch
def single_source_bellman_ford_path_length(G, source, weight: str = "weight"): ...
def single_source_bellman_ford_path_length(G, source, weight: str | _WeightFunction = "weight"): ...
@_dispatch
def single_source_bellman_ford(G, source, target: Incomplete | None = None, weight: str = "weight"): ...
def single_source_bellman_ford(G, source, target: Incomplete | None = None, weight: str | _WeightFunction = "weight"): ...
@_dispatch
def all_pairs_bellman_ford_path_length(G, weight: str = "weight") -> Generator[Incomplete, None, None]: ...
def all_pairs_bellman_ford_path_length(G, weight: str | _WeightFunction = "weight") -> Generator[Incomplete, None, None]: ...
@_dispatch
def all_pairs_bellman_ford_path(G, weight: str = "weight") -> Generator[Incomplete, None, None]: ...
def all_pairs_bellman_ford_path(G, weight: str | _WeightFunction = "weight") -> Generator[Incomplete, None, None]: ...
@_dispatch
def goldberg_radzik(G, source, weight: str = "weight"): ...
def goldberg_radzik(G, source, weight: str | _WeightFunction = "weight"): ...
@_dispatch
def negative_edge_cycle(G, weight: str = "weight", heuristic: bool = True): ...
def negative_edge_cycle(G, weight: str | _WeightFunction = "weight", heuristic: bool = True): ...
@_dispatch
def find_negative_cycle(G, source, weight: str = "weight"): ...
def find_negative_cycle(G, source, weight: str | _WeightFunction = "weight"): ...
@_dispatch
def bidirectional_dijkstra(G, source, target, weight: str = "weight"): ...
def bidirectional_dijkstra(G, source, target, weight: str | _WeightFunction = "weight"): ...
@_dispatch
def johnson(G, weight: str = "weight"): ...
def johnson(G, weight: str | _WeightFunction = "weight"): ...

0 comments on commit eb7df6d

Please sign in to comment.