summaryrefslogtreecommitdiffstats
path: root/algorithms.py
diff options
context:
space:
mode:
authorStefan Hansson <steha708@edu.liu.se>2020-12-16 09:20:12 +0100
committerNewbyte <steha708@liu.se>2020-12-16 09:20:12 +0100
commitdd50eb5818501eb45cdde745cf239ac12b13a04e (patch)
tree1ff5da81c859b65b3883226a1507914c0ba4ec87 /algorithms.py
parenta11a7b4cde5834781aa57e7f9c9a8a3a309d6411 (diff)
downloadtdde25-dd50eb5818501eb45cdde745cf239ac12b13a04e.tar.gz
Implement mode of transport
Diffstat (limited to 'algorithms.py')
-rw-r--r--algorithms.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/algorithms.py b/algorithms.py
index 3bd9f5e..df2f874 100644
--- a/algorithms.py
+++ b/algorithms.py
@@ -77,8 +77,6 @@ def get_closest_node(nodes, source_node):
min_value = None
for node in nodes:
- print(source_node)
- print(node)
length = length_haversine(source_node, node)
if (min_node is None or length < min_value):
@@ -88,7 +86,7 @@ def get_closest_node(nodes, source_node):
return min_node
-def find_shortest_path(nodes, source_id, target_id, transport_mode: str):
+def find_shortest_path(nodes, source_id, target_id):
""" Return the shortest path using Dijkstra's algortihm. """
# queue contains multiple (walk_dist, (node_0, node_1, ... node_n))-tuples
# where (node_0, node_1, ... node_n) is a walk to node_n
@@ -112,9 +110,7 @@ def find_shortest_path(nodes, source_id, target_id, transport_mode: str):
# consider all our neighbours
end_node = nodes[walk_end]
- relevant_neighbours = get_relevant_neighbours(end_node, transport_mode)
-
- for neighbour in relevant_neighbours:
+ for neighbour in end_node.neighbours:
if neighbour in visited:
# there exists a shorter walk to neighbour
continue