Skip to content

Commit 2757b63

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 1d74c6e commit 2757b63

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

searches/dijkstra.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
1010
Doctests include a small example graph.
1111
"""
12+
1213
from __future__ import annotations
1314

1415
import heapq
1516
from typing import Dict, Iterable, List, Tuple, Any
1617

1718

18-
def dijkstra(graph: Dict[Any, Iterable[Tuple[Any, float]]], source: Any) -> Tuple[Dict[Any, float], Dict[Any, Any]]:
19+
def dijkstra(
20+
graph: Dict[Any, Iterable[Tuple[Any, float]]], source: Any
21+
) -> Tuple[Dict[Any, float], Dict[Any, Any]]:
1922
"""Compute shortest path distances from source to all reachable nodes.
2023
2124
Args:
@@ -51,11 +54,11 @@ def dijkstra(graph: Dict[Any, Iterable[Tuple[Any, float]]], source: Any) -> Tupl
5154
while pq:
5255
d, u = heapq.heappop(pq)
5356
# Skip stale entries
54-
if d != dist.get(u, float('inf')):
57+
if d != dist.get(u, float("inf")):
5558
continue
5659
for v, w in graph.get(u, []):
5760
nd = d + float(w)
58-
if nd < dist.get(v, float('inf')):
61+
if nd < dist.get(v, float("inf")):
5962
dist[v] = nd
6063
prev[v] = u
6164
heapq.heappush(pq, (nd, v))

0 commit comments

Comments
 (0)