From b35f002e1a453a12d104bbba6cd6ca354d18fcb6 Mon Sep 17 00:00:00 2001 From: jullinator Date: Thu, 30 Aug 2018 19:21:53 +0200 Subject: leaflet updated --- test_dijkstra.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'test_dijkstra.py') 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') + -- cgit v1.2.1