Skip to content

Commit db07a0c

Browse files
authored
Update DijkstraHeap.java
1 parent 2eb8d8b commit db07a0c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Graph Theory/shortestpath/DijkstraHeap.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public static void main (String[] args) throws IOException {
5656
pq.offer(new Vertex(orig, 0));
5757
while (!pq.isEmpty()) {
5858
Vertex curr = pq.poll();
59+
if (curr.cost > dist[curr.index])
60+
continue;
5961
for (Edge next : adj.get(curr.index)) {
6062
if (dist[next.dest] > curr.cost + next.cost) {
6163
dist[next.dest] = curr.cost + next.cost;

0 commit comments

Comments
 (0)