dijkstra: fix invalid stats

This commit is contained in:
Marco Thomas
2022-07-27 18:18:44 +02:00
parent 8a0a59c222
commit d29c08a411
2 changed files with 4 additions and 8 deletions

View File

@@ -52,17 +52,13 @@ class Dijkstra():
# start at destination
sequence.append(dest)
total_time = 0
total_co2 = 0
# go through all possibilities until we're back at start
while start not in sequence:
current = self.table[sequence[-1]] # last element of list
prev = current["prev"]
total_time += current["distance"][0]
total_co2 += current["distance"][1]
sequence.append(prev)
sequence.reverse()
print(sequence)
print("Total Time:", total_time)
print("Total CO2:", total_co2)
print("Total Time:", self.table[dest]["distance"][0])
print("Total CO2:", self.table[dest]["distance"][1])