You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The bellman_ford shortest path function doesn't return an error when called with a negative weight cycle even though this means the output is incorrect.
It should throw an error in this case.
The text was updated successfully, but these errors were encountered:
I fear the general answer here is: it's a precondition and adding explicit checks would penalizing all usage of the algorithm.
Does the return value satisfy your expectations?
If there is a negative cycle, then there will be edges in the graph that were not properly minimized. That is, there will be edges (u,v) such that w(u,v) + d[u] < d[v]. The algorithm loops over the edges in the graph one final time to check if all the edges were minimized, returning true if they were and returning false otherwise?
The bellman_ford shortest path function doesn't return an error when called with a negative weight cycle even though this means the output is incorrect.
It should throw an error in this case.
The text was updated successfully, but these errors were encountered: