Skip to content

Commit 82a11d7

Browse files
JakobMusikpoyea
authored andcommitted
Fix bug in bellman_ford.py (#1544)
1 parent 4c37eb7 commit 82a11d7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: graphs/bellman_ford.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ def BellmanFord(graph, V, E, src):
1313
mdist[src] = 0.0
1414

1515
for i in range(V - 1):
16-
for j in range(V):
16+
for j in range(E):
1717
u = graph[j]["src"]
1818
v = graph[j]["dst"]
1919
w = graph[j]["weight"]
2020

2121
if mdist[u] != float("inf") and mdist[u] + w < mdist[v]:
2222
mdist[v] = mdist[u] + w
23-
for j in range(V):
23+
for j in range(E):
2424
u = graph[j]["src"]
2525
v = graph[j]["dst"]
2626
w = graph[j]["weight"]

0 commit comments

Comments
 (0)