Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Algorithm like Bellman-Ford, only for multiple start, single destination?

Algorithms like the Bellman-Ford algorithm and Dijkstra's algorithm exist to find the shortest path from a single starting vertex on a graph to every other vertex. However, in the program I'm writing, the starting vertex changes a lot more often than the destination vertex does. What algorithm is there that does the reverse--that is, given a single destination vertex, to find the shortest path from every starting vertex?

like image 543
flarn2006 Avatar asked Feb 27 '15 19:02

flarn2006


People also ask

Which one is better Dijkstra or Bellman-Ford?

Our results show that Dijkstra is better than the Bellman-Ford interms of execution time and more efficient for solving the shortest path issue, but the algorithm of Dijkstra work with non-negative edge weights.

Can the Bellman-Ford algorithm be used to find all pairs shortest path?

Using Bellman Ford we can generate all pairs shortest paths if we run the bellman ford algorithm from each node and then get the shortest paths to all others, but the worse case time complexity of this algorithm will be O(V * V * E) and if we have complete graph this complexity will be O (V^4), where V is the number of ...

What is the Bellman-Ford algorithm for finding single source shortest paths?

The Bellman-Ford algorithm is a single-source shortest path algorithm. This means that, given a weighted graph, this algorithm will output the shortest distance from a selected node to all other nodes. It is very similar to the Dijkstra Algorithm.


1 Answers

Just reverse all the edges, and treated destination as start node. Problem solved.

like image 177
Pham Trung Avatar answered Sep 22 '22 17:09

Pham Trung