diff --git a/shortest_path.py b/shortest_path.py index a68742fadcc31e7e51f52b2099ec3d772e0039fd..a5067d6c67d44678e294718a20f1d60a9cdbc706 100644 --- a/shortest_path.py +++ b/shortest_path.py @@ -43,7 +43,9 @@ def bellman_ford(table, s): a, b, cab = table[j][0], table[j][1], table[j][2] if (dist[a] != math.inf and dist[b] > dist[a]+cab): print("Cycle négatif détecté") - return -1, -1 + dist = [math.inf] * nb_nodes + dist[s] = 0 + path = [-1] * nb_nodes return dist, path