We present an O(nm) algorithm for all-pairs shortest paths computations in a directed graph with n nodes, m arcs, and nonnegative integer arc costs. This matches the complexity bound attained by Thorup [ 31 ] problems undirected graphs. The main insight is that approximately balanced cost functions can be solved similarly to case. finds reduced function O(m √ log ) preprocessing step. Using the...