U10fix5
This commit is contained in:
parent
09f655e794
commit
c278454a61
@ -26,17 +26,20 @@ def shortest_path(number_of_nodes, connections):
|
|||||||
if j in path[i]:
|
if j in path[i]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
new_dist = dist[i] + length
|
newdist = dist[i] + length
|
||||||
new_path = path[i] + [j]
|
newpath = path[i] + [j]
|
||||||
|
|
||||||
bet = False
|
bet = False
|
||||||
if dist[j] is None:
|
if dist[j] is None:
|
||||||
bet = True
|
bet = True
|
||||||
elif new_dist < dist[j]:
|
elif newdist < dist[j]:
|
||||||
bet = True
|
bet = True
|
||||||
|
elif newdist == dist[j]:
|
||||||
|
if newpath < path[j]:
|
||||||
|
bet = True
|
||||||
if bet:
|
if bet:
|
||||||
dist[j] = new_dist
|
dist[j] = newdist
|
||||||
path[j] = new_path
|
path[j] = newpath
|
||||||
change = True
|
change = True
|
||||||
|
|
||||||
return path[end]
|
return path[end]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user