How do I find the shortest path from every vertex vvv to vertex sss, where v,sâVv,sâVv,s \in V?
-
Let G(V,E)G(V,E)G(V,E) be a directed graph with positive weights on its edges, and let sâVsâVs \in V be a node. Suggest an algorithm that in time O((|V|+|E|)log|V|)O((|V|+|E|)logâ¡|V|)O((|V| + |E|) \log |V|) time algorithm that finds, for every vertex vvv, what is the length of the shortest path vvv to sss?
-
Answer:
Run http://en.wikipedia.org/wiki/Dijkstra's_algorithm in the reverse graph of GGG, where sss is the source. The edges of the shortest path from sss to a node v(vâV)v(vâV)v ( v \in V ) in the reverse graph, will form a shortest path from vvv to sss in the original graph.
Bidhan Roy at Quora Visit the source
Other answers
First reverse the direction of all edges, then use dijkstra algorithm. Dijkstra algorithm computes shortest path from 1 vertex to all other vertexes in the graph in O((|V| + |E|) \log |V| ) . You can then back trace all of those paths to return the answer.
Chan Le
Related Q & A:
- How can I find my employment history on SSS?Best solution by Yahoo! Answers
- How do I find my friend's email address?Best solution by Yahoo! Answers
- How do I find a yahoo user's profile if I have their email address?Best solution by Yahoo! Answers
- How can I find someone's name if I have their address in the US?Best solution by searchenginez.com
- How can I find my career path?Best solution by eHow old
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.