mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-03-19 21:19:47 +00:00
Fix bug in bellman_ford.py (#1544)
This commit is contained in:
parent
4c37eb7d07
commit
82a11d7f31
@ -13,14 +13,14 @@ def BellmanFord(graph, V, E, src):
|
||||
mdist[src] = 0.0
|
||||
|
||||
for i in range(V - 1):
|
||||
for j in range(V):
|
||||
for j in range(E):
|
||||
u = graph[j]["src"]
|
||||
v = graph[j]["dst"]
|
||||
w = graph[j]["weight"]
|
||||
|
||||
if mdist[u] != float("inf") and mdist[u] + w < mdist[v]:
|
||||
mdist[v] = mdist[u] + w
|
||||
for j in range(V):
|
||||
for j in range(E):
|
||||
u = graph[j]["src"]
|
||||
v = graph[j]["dst"]
|
||||
w = graph[j]["weight"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user