algorithm - Distance between two nodes in weighted directed graph -
which algorithm optimized searching shortest distance between 2 nodes in positive weighted directed graph?
i know dijkstra option calculates src nodes. same floyd-warshall.
one additional issue. need distance node source , destination.
for example:
src - f, dest - f need calculate 2.45 in example, not 0 dijkstra get. can modify dijkstra? i've implemented 1 http://www.vogella.com/tutorials/javaalgorithmsdijkstra/article.html
graph http://www.math.cornell.edu/~numb3rs/blanco/net_dif.png
if algorithm find shortest path 1 vertex another, , b algorithm find shortest paths between vertex , other nodes, proven fact optimal complexity of not better optimal complexity of b. i.e. cannot compute path single vertex, have compute paths other nodes. in simple words, how can sure found shortest path if don't know paths other nodes?
however, though there exist no algorithm complexity better algorithm b, particular implementation of might made more optimized implementation of b, constant factor. in case of positive edges, can halt dijkstra algorithm when destination vertex relaxed. might still have process vertices in worst case.
this optimization wouldn't possible in case have negative edges, dijkstra algorithm cannot handle case either. need bellman–ford algorithm case.
floyd-warshall overkill here, don't need paths vertices others. dijkstra way go, think. if looking optimal complexity, can use heap-based implementation, or fibonacci heaps. complexities cases given in wiki page dijkstra algorithm. stated that:
this [dijkstra fibonacci heaps] asymptotically fastest known single-source shortest-path algorithm arbitrary directed graphs unbounded non-negative weights.
so shouldn't bother find asymptotically better algorithm.
Comments
Post a Comment