Skip to content

Commit 615179c

Browse files
committed
fix: all unit tests pass again
1 parent 2468f37 commit 615179c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/igraph_ctypes/paths.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Functions related to shortest or widest paths in a graph."""
22

3-
from typing import Iterable, Optional
3+
from typing import Iterable, Literal, Optional
44

55
from .enums import Connectedness, NeighborMode
66
from .graph import Graph
@@ -34,7 +34,7 @@ def shortest_path(
3434
target: VertexLike,
3535
mode: NeighborMode = NeighborMode.OUT,
3636
weights: Optional[Iterable[float]] = None,
37-
method: str = "dijkstra",
37+
method: Literal["auto", "dijkstra", "bellman_ford"] = "dijkstra",
3838
) -> IntArray:
3939
"""Finds a single shortest path between two vertices in a graph.
4040
@@ -46,15 +46,15 @@ def shortest_path(
4646
weights: list of weights for each edge in the graph, or ``None`` to treat
4747
the edges as unweighted
4848
method: the method to use for finding shortest paths when the graph is
49-
weighted. May be one of `"dijkstra"` (Dijkstra's algorithm) or
50-
`"bellman-ford"` (Bellman-Ford algorithm).
49+
weighted. May be one of `"auto"` (pick the best method), `"dijkstra"`
50+
(Dijkstra's algorithm) or `"bellman_ford"` (Bellman-Ford algorithm).
5151
5252
Returns:
5353
the IDs of the vertices along the shortest path
5454
"""
5555
# TODO(ntamas): handle epath?
56-
if weights is None:
57-
vpath, _ = get_shortest_path(graph, source, target, mode)
56+
if method == "auto":
57+
vpath, _ = get_shortest_path(graph, source, target, weights, mode)
5858
elif method == "dijkstra":
5959
vpath, _ = get_shortest_path_dijkstra(graph, source, target, weights, mode)
6060
elif method in ("bellman-ford", "bellman_ford"):

0 commit comments

Comments
 (0)