Skip to content
Snippets Groups Projects
Commit cf328862 authored by Jacob Theisen's avatar Jacob Theisen
Browse files

mamma mia

parent 4065fbc7
No related branches found
No related tags found
No related merge requests found
......@@ -74,11 +74,23 @@ def init_table():
for i in range(num_of_nodes):
res_arr.append(results(i, inf, False, None))
total_counter_time = 0
def rec_func(i, a):
def rec_func(node, counter, global_fra):
counter += node.time
if node.fra == global_fra:
return counter
else:
rec_func(node.prev, counter, global_fra)
def calculate_shortest_path(b, i, a, global_fra):
count_a = 0
count_a = rec_func(a, count_a, global_fra)
count_b = 0
count_b = rec_func(b, count_b, global_fra)
count_b += i
if count_b < count_a:
return True
else:
return False
......@@ -99,7 +111,9 @@ def dijkstras(global_fra, fra, til):
else:
queue.append(i.til)
elif a.visited == True:
rec_func(i.time, a)
b = [b for b in res_arr if b.node == i.fra][0]
if calculate_shortest_path(b, i.time, a, global_fra):
a.prev = i.fra
if fra == til:
for i in res_arr:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment