diff --git a/u10/najkratsia_cesta.py b/u10/najkratsia_cesta.py index b7adddf..c63f423 100644 --- a/u10/najkratsia_cesta.py +++ b/u10/najkratsia_cesta.py @@ -38,5 +38,14 @@ def shortest_path(number_of_nodes, connections): boli[teraz] = True + # check susedov + for sused, weight in susedy[teraz]: + new_dist = distancii[teraz] + weight + new_path = paths[teraz] + [sused] - return paths[number_of_nodes - 1] + if new_dist < distancii[sused]: + distancii[sused] = new_dist # update dist + path + paths[sused] = new_path + + + return paths[number_of_nodes - 1] \ No newline at end of file