blob: 4f54b4e3612ffd61c6e8ef0f6f1ce027b0baaab5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import Graph
from collections import defaultdict
from heapq import heappush, heappop
import math
def dijkstra(adjacency_list, source, target):
""" To be implemented by students. `adjacency_list` is a dictionary with values: (vertice, weight).
Function should return (distance, path). Path should be a list of the vertices in the shortest path
**including** the source and target. If no shortest path is found, it should return (infinity, []) """
return math.inf, [source]
if __name__ == '__main__':
try:
Graph.test_dijkstra(dijkstra)
print('Passed ALL tests!')
except AssertionError:
print('Failed one or more tests')
|