Skip to content

Commit 30b5455

Browse files
committed
Update dijkstra_2.py
1 parent a71618f commit 30b5455

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

graphs/dijkstra_2.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ def print_dist(dist, v):
99

1010

1111
def min_dist(mdist, vset, v):
12+
"""
13+
Finds the vertex with minimum distance that hasn't been visited yet.
14+
>>> min_dist([0, 4, 2, float('inf')], [True, False, False, False], 4)
15+
2
16+
>>> min_dist([0, 4, 2, 1], [True, False, True, False], 4)
17+
3
18+
>>> min_dist([0, 4, 2, 1], [True, True, True, True], 4)
19+
-1
20+
>>> min_dist([float('inf'), float('inf')], [False, False], 2)
21+
-1
22+
"""
1223
min_val = float("inf")
1324
min_ind = -1
1425
for i in range(v):

0 commit comments

Comments
 (0)