This repository has been archived on 2025-06-18. You can view files and clone it, but cannot push or open issues or pull requests.
Files
skolavdf/dev-prg/Dijkstra/dijkstra.py
Jakub Rybníček 5a5812c0c7 Create dijkstra.py
2024-01-19 00:00:22 +01:00

25 lines
645 B
Python

# Pokus byl...
graph = [
[0,0,0,1,0],
[4,0,0,0,0],
[2,5,0,0,0],
[3,0,1,0,1],
[6,3,2,9,0]
]
while True:
i = 0
print("-------")
lastBiggestVal = 0
lastBiggestNode = -1
for j in range(0, 5):
if i == j or graph[i][j] < 1:
continue
if lastBiggestVal < graph[i][j]:
lastBiggestVal = graph[i][j]
lastBiggestNode = j
print("Source: {}, Destination: {}, Value: {}".format(i, j, graph[i][j]))
if lastBiggestNode < 0:
break
i = lastBiggestNode
print("Continue to Destination: {} with Value: {}".format(lastBiggestNode, lastBiggestVal))