summaryrefslogtreecommitdiffstats
path: root/server.py
diff options
context:
space:
mode:
authorGustav Sörnäs <gusso230@student.liu.se>2020-11-12 17:21:00 +0100
committerGustav Sörnäs <gusso230@student.liu.se>2020-11-20 13:39:57 +0100
commit37e518cf9300cf88d71a2a63548be33fb0468cb4 (patch)
treea5893a6ad8788ffb6a68c72fa221d7505b0a4cf7 /server.py
parentb88872bc574ccbebf14c922e0204c8c286cbce48 (diff)
downloadtdde25-37e518cf9300cf88d71a2a63548be33fb0468cb4.tar.gz
report number of iterations
Diffstat (limited to 'server.py')
-rw-r--r--server.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/server.py b/server.py
index bfe5b0f..9024ee2 100644
--- a/server.py
+++ b/server.py
@@ -31,18 +31,18 @@ def shortest_path(body):
target_id = algorithms.get_closest_node_id(nodes, store.Node(-1, body['lat2'], body['lng2']))
start = time.time()
- astar = algorithms.find_shortest_path_astar(nodes,
- source_id,
- target_id)
+ astar, iters = algorithms.find_shortest_path_astar(nodes,
+ source_id,
+ target_id)
stop = time.time()
- print(f"A* {stop-start:.4f}s {algorithms.path_length(nodes, astar)}")
+ print(f"A* {iters} {stop-start:.4f}s {algorithms.path_length(nodes, astar)}")
start = time.time()
- dijkstra = algorithms.find_shortest_path_dijkstra(nodes,
- source_id,
- target_id)
+ dijkstra, iters = algorithms.find_shortest_path_dijkstra(nodes,
+ source_id,
+ target_id)
stop = time.time()
- print(f"Dij {stop-start:.4f}s {algorithms.path_length(nodes, dijkstra)}")
+ print(f"Dij {iters} {stop-start:.4f}s {algorithms.path_length(nodes, dijkstra)}")
response = {"path": [(nodes[node].lat, nodes[node].lng) for node in astar]}
return json.dumps(response)