Fix bug in bellman_ford.py (#1544)

This commit is contained in:
JakobZhao 2019-11-10 17:01:38 +08:00 committed by John Law
parent 4c37eb7d07
commit 82a11d7f31

View File

@ -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"]