Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitecd99c9

Browse files
committed
Fix issue in dijkstra for empty matrix
1 parente59c2d9 commitecd99c9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

‎src/graphs/shortest-path/dijkstra.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@
112112
visited[current.node]=true;
113113
current=unvisited.extract();
114114
}
115-
returndistance[dest].distance;
115+
if(distance[dest]){
116+
returndistance[dest].distance||Infinity;
117+
}
118+
returnInfinity;
116119
};
117120

118121
})();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp