Bellman-Ford vs Dijkstra: Under what circumstances is Bellman-Ford better?

Bellman-Ford algorithm is a single-source shortest path algorithm, so when you have negative edge weight then it can detect negative cycles in a graph. The only difference between the two is that Bellman-Ford is also capable of handling negative weights whereas Dijkstra Algorithm can only handle positives. From wiki However, Dijkstra’s algorithm greedily selects the … Read more

A* Algorithm for very large graphs, any thoughts on caching shortcuts?

You should be able to make it much faster by trading off optimality. See Admissibility and optimality on wikipedia. The idea is to use an epsilon value which will lead to a solution no worse than 1 + epsilon times the optimal path, but which will cause fewer nodes to be considered by the algorithm. … Read more

How does a Breadth-First Search work when looking for Shortest Path?

Technically, Breadth-first search (BFS) by itself does not let you find the shortest path, simply because BFS is not looking for a shortest path: BFS describes a strategy for searching a graph, but it does not say that you must search for anything in particular. Dijkstra’s algorithm adapts BFS to let you find single-source shortest … Read more

Why doesn’t Dijkstra’s algorithm work for negative weight edges?

Recall that in Dijkstra’s algorithm, once a vertex is marked as “closed” (and out of the open set) – the algorithm found the shortest path to it, and will never have to develop this node again – it assumes the path developed to this path is the shortest. But with negative weights – it might … Read more