From 5a25e55b0fd59a032c4c85af452bd433427c3890 Mon Sep 17 00:00:00 2001 From: Max Bringemo Date: Mon, 2 Nov 2020 15:54:52 +0100 Subject: finished introductory phase --- algorithms.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'algorithms.py') diff --git a/algorithms.py b/algorithms.py index 1a62118..de954f4 100644 --- a/algorithms.py +++ b/algorithms.py @@ -1,5 +1,6 @@ import math + def length_haversine(p1, p2): lat1 = p1.lat lng1 = p1.lng @@ -10,14 +11,16 @@ def length_haversine(p1, p2): dlng = lng2 - lng1 a = math.sin(dlat / 2) ** 2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlng / 2) ** 2 c = 2 * math.asin(math.sqrt(a)) - - return 6372797.560856 * c # return the distance in meters + + return 6372797.560856 * c # return the distance in meters + def get_closest_node_id(nodes, source_node): """ Search through all nodes and return the id of the node that is closest to 'source_node'. """ pass + def find_shortest_path(nodes, source_id, target_id): """ Return the shortest path using Dijkstra's algortihm. """ - return [] \ No newline at end of file + return [] -- cgit v1.2.1