diff --git "a/problems/0025.\346\234\200\347\210\261\347\232\204\345\237\216\345\270\202.md" "b/problems/0025.\346\234\200\347\210\261\347\232\204\345\237\216\345\270\202.md" index e7b2c555ea804a714df2317b70afbdc7268a52e6..b4df9a1bdf65d1e64dd0ef23b757bc72f105f109 100644 --- "a/problems/0025.\346\234\200\347\210\261\347\232\204\345\237\216\345\270\202.md" +++ "b/problems/0025.\346\234\200\347\210\261\347\232\204\345\237\216\345\270\202.md" @@ -356,7 +356,7 @@ public class Main { visited[u] = true; // 将该节点标记为已访问 for (int v = 1; v <= n; v++) { - if (!visited[v] && graph[u][v] != Integer.MAX_VALUE) { + if (!visited[v] && graph[u][v] != Integer.MAX_VALUE && dist[u] != Integer.MAX_VALUE) { // 更新未访问节点的最短距离 dist[v] = Math.min(dist[v], dist[u] + graph[u][v]); }