Bellman-Ford runs for at most n−1 iterations to relax all edges, ensuring the shortest paths are found. After this, it performs one more check to detect negative weight cycles. In contrast, Dijkstra’s algorithm relies on a greedy approach, assuming all edge weights are positive. If a graph contains negative weights or negative cycles, Dijkstra may produce incorrect results or enter an infinite loop in some implementations, leading to unexpected behavior
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)