From d091eb7420a1c1977d6979bb75f1f10733bd7190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=9C=97=E7=89=9B?= <1528553614@qq.com> Date: Tue, 28 May 2024 09:57:47 +0000 Subject: [PATCH] =?UTF-8?q?update=20problems/0025.=E6=9C=80=E7=88=B1?= =?UTF-8?q?=E7=9A=84=E5=9F=8E=E5=B8=82.md.=20Java=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=9A=84dijkstra=E7=AE=97=E6=B3=95=EF=BC=9A=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=9C=80=E7=9F=AD=E8=B7=9D=E7=A6=BB=EF=BC=8C=E8=BF=98=E9=9C=80?= =?UTF-8?q?=E5=88=A4=E6=96=AD=20=E5=BD=93=E5=89=8D=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=8F=AF=E8=BE=BE=20dist[u]=20!=3D=20Integer?= =?UTF-8?q?.MAX=5FVALUE=EF=BC=8C=E5=90=A6=E5=88=99dist=E4=BC=9A=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蜗牛 <1528553614@qq.com> --- ...\234\200\347\210\261\347\232\204\345\237\216\345\270\202.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e7b2c55..b4df9a1 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]); } -- Gitee