diff options
| author | Max Bringemo <maxbr167@student.liu.se> | 2020-11-02 15:54:52 +0100 |
|---|---|---|
| committer | Max Bringemo <maxbr167@student.liu.se> | 2020-11-02 15:54:52 +0100 |
| commit | 5a25e55b0fd59a032c4c85af452bd433427c3890 (patch) | |
| tree | 84252877002e3eec3f58f92d614c225557a21156 /algorithms.py | |
| parent | 58f04e8c6d768fc8b912ec1af44442eebac03595 (diff) | |
| download | tdde25-5a25e55b0fd59a032c4c85af452bd433427c3890.tar.gz | |
finished introductory phase
Diffstat (limited to 'algorithms.py')
| -rw-r--r-- | algorithms.py | 9 |
1 files changed, 6 insertions, 3 deletions
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 [] |
