As we mentioned, Johnson's algorithm is optimal for sparse graphs. On the other hand, if the graph is complete, our algorithm will work no faster than other standard all-pairs algorithms. What will be its time complexity in the case of complete graphs?
Denote ∣ and .