I implemented a Bellman-Ford algorithm solution with a queue, and I compared its performance with Dijkstra's algorithm. They were pretty close, and it was a surprise to me because the complexity of Bellman-Ford is O (NM). I know that complexity is the worst case scenario, but the result was unexpected. I was looking for some information about Bellman-Ford, and I only found this statement in Sedgewick, Algorithms in Java. "On real networks, the Bellman-Ford algorithm typically runs in linear time." Could you give me an explanation of the performance behavior of the Bellman-Ford algorithm?
source share