Do we always have to run Bellman-Ford N-1 times?

67 Views Asked by At

This is more a theoretical question because I can see this question being asked in an exam. Assuming we have a directed graph G(V,E) with |V| = 10 and we want to know the shortest path from S to all other 9 vertices. Assuming we know that the longest path from S has length 5 do we still have to run Bellman-Ford 9 times or can we run it 5 times and conclude that we have found the shortest path ?

When trying it on an example it worked but it could also just be luck and there might me some edgecase I am missing.

0

There are 0 best solutions below