summaryrefslogtreecommitdiffstats
path: root/test_dijkstra.py
diff options
context:
space:
mode:
Diffstat (limited to 'test_dijkstra.py')
-rw-r--r--test_dijkstra.py18
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')
+