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

sjo

parent dc383a71
No related branches found
No related tags found
No related merge requests found
......@@ -75,22 +75,25 @@ def init_table():
res_arr.append(results(i, inf, False, None))
def rec_func(node, counter, global_fra):
print('in recfunc')
counter += node.time
print(f'node: {node.node}, node_time: {node.time}, time_count: {counter}')
if node.node == global_fra:
return counter
else:
print(node.prev)
node = [a for a in res_arr if a.node == node.prev][0]
rec_func(node, counter, global_fra)
def calculate_shortest_path(b, i, a, global_fra):
print('in calculate')
res_a = [a for a in res_arr if a == a.node]
print(f'curr_node: {b.node}, edge_time: {i}, curr_neig_node: {a.node}, curr_neig_prev: {a.prev}, global_fra: {global_fra}')
def calculate_shortest_path(current_node, time, current_neighbour, slutt):
print('\nin calculate')
res_a = [c for c in res_arr if c.node == current_neighbour.node][0]
print(f'curr_node: {current_node.node}, edge_time: {time}, curr_neig_node: {current_neighbour.node}, curr_neig_prev: {current_neighbour.prev}, dist to curr_neig: {res_a.time}, global_fra: {slutt}')
count_a = 0
count_a = rec_func(a, count_a, global_fra)
count_a = rec_func(current_neighbour, count_a, slutt)
count_b = 0
count_b = rec_func(b, count_b, global_fra)
count_b += i
count_b = rec_func(current_node, count_b, slutt)
count_b += time
if count_b < count_a:
return True
else:
......@@ -102,13 +105,12 @@ queue = []
def dijkstras(slutt, fra, start):
global round
round +=1
print('runde: ', round, ' queue: ', queue)
print('runde: ', round, ' queue: ', queue, 'start: ', start)
current_node = [b for b in res_arr if b.node == fra][0]
print(current_node.node)
for tmp_edge in edge_arr:
if tmp_edge.fra == fra:
current_neighbour = [a for a in res_arr if a.node == tmp_edge.til][0]
if current_neighbour:
if current_neighbour.visited == False:
print(f'fra: {fra}, a: {current_neighbour.visited}, til {tmp_edge.til}')
if start == fra:
......@@ -119,7 +121,7 @@ def dijkstras(slutt, fra, start):
if tmp_edge.til == slutt:
current_node.visited = True
queue.pop(0)
dijkstras(start, slutt, slutt)
dijkstras(slutt, slutt, start)
else:
queue.append(tmp_edge.til)
......@@ -140,7 +142,7 @@ def dijkstras(slutt, fra, start):
else:
queue.pop(0)
current_node.visited = True
dijkstras(start,queue[0],slutt)
dijkstras(slutt,queue[0],start)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment