Johnson’s algorithm

Make a table of the cheapest fares between every pair of towns. This method suits a large map with few direct roads. Some roads can even pay you to travel.

Use Bellman–Ford to find a price adjustment at every vertex. The adjusted edges become nonnegative. Run Dijkstra from each town and convert distances back to original prices.

With linear minimum selection, time is O(V³ + VE). An empty table reports a negative cycle.