diff options
| author | jullinator <justus.karlsson@hotmail.se> | 2018-08-30 19:21:53 +0200 |
|---|---|---|
| committer | jullinator <justus.karlsson@hotmail.se> | 2018-08-30 19:21:53 +0200 |
| commit | b35f002e1a453a12d104bbba6cd6ca354d18fcb6 (patch) | |
| tree | 0bb717527fc3f0f35c535dc1fcc65d84dec0c145 /test_dijkstra.py | |
| parent | e3b6cb5c1cf67286409ae5f9789f203e6beddff1 (diff) | |
| download | tdde25-b35f002e1a453a12d104bbba6cd6ca354d18fcb6.tar.gz | |
leaflet updated
Diffstat (limited to 'test_dijkstra.py')
| -rw-r--r-- | test_dijkstra.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/test_dijkstra.py b/test_dijkstra.py index 4f54b4e..a0f315c 100644 --- a/test_dijkstra.py +++ b/test_dijkstra.py @@ -1,14 +1,15 @@ -import Graph +import notebooks.Graph as 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] +def dijkstra(adjacency_list, source_id, target_id): + """ To be implemented by students. `adjacency_list` is a dictionary with structure: + {node_id: [...(neighbor_id, weight)]}. + Function should return (distance, path). Path should be a list of the nodes in the shortest path + **including** the source_id and target_id. If no shortest path is found, it should return (infinity, []) """ + + return math.inf, [source_id] if __name__ == '__main__': @@ -16,4 +17,5 @@ if __name__ == '__main__': Graph.test_dijkstra(dijkstra) print('Passed ALL tests!') except AssertionError: - print('Failed one or more tests')
\ No newline at end of file + print('Failed one or more tests') + |
