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

Commit15f5fcb

Browse files
committed
added changes to your bellmanford.js
1 parent08d8c6b commit15f5fcb

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

‎Graphs/BellmanFord.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ function BellmanFord(graph, V, E, src, dest) {
3434
// Relax all edges |V| - 1 times. A simple
3535
// shortest path from src to any other
3636
// vertex can have at-most |V| - 1 edges
37-
for(leti=0;i<V-1;i++){
37+
returndis[dest]
3838
for(letj=0;j<E;j++){
3939
if(dis[graph[j][0]]+graph[j][2]<dis[graph[j][1]]){
4040
dis[graph[j][1]]=dis[graph[j][0]]+graph[j][2]
41-
}
4241
}
4342
}
4443
// check for negative-weight cycles.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp