Floyd-Warshall
Në shqip përdoret i njëjti emër.
ShpjegimiSQ
Floyd-Warshall gjen rrugën më të shkurtër mes çdo çifti nyjesh me tre cikle të ndërthurura — O(V³). I thjeshtë për t'u shkruar dhe ideal për grafe të vogla (deri në disa qindra nyje).
EnglishEN
Floyd-Warshall finds the shortest path between every pair of nodes with three nested loops — O(V³). Simple to write and ideal for small graphs (up to a few hundred nodes).
Si ta mendosh
Si tabela e distancave mes të gjitha qyteteve në fund të një atlasi.
Lexoje në anglisht
Like the distance table between every pair of cities at the back of an atlas.
Shembull kodipython
for k in range(n):
for i in range(n):
for j in range(n):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])