Shortest-path algorithms are useful for certain types of graphs. For the graph below, which algorithm should be used to solve the single-source shortest path problem?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Relevant wiki: Shortest Path Algorithms
This graph is a directed graph with negative edge weights. There are no negative weight cycles, so shortest paths will be well defined. However, since there are negative edge weights, Dijkstra's algorithm cannot be used.
Floyd-Warshall and Johnson's algorithm are for all-pairs shortest path algorithms.