✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.
Shortest paths with negative weights
Assume we are running Floyd-Warshall on a graph that has no negative cycle. The algorithm keeps a matrix whose entry dist[u][v] is the current estimate of the distance from u to v, and its outer loop runs over the vertices in the order 1, 2, …, |V|. Once the iteration for vertex k has finished, what does dist[u][v] hold?