Suppose given a weighted directed graph $G=(V,E)$. We want, for each $v\in V$ find a path $P$ from other vertices to $v$ such that weight of $P$ is minimzed.

I can solve this by running Johnson's algorithm on $G$ and doing a linear traverse of matrix to find out for each $v$ minimum weight shortest path from other to $v$ in $O(n^3)$. But my problem is are there any lower bound that show us we can't do better in $\Omega(n^3)$?


1 Answer 1


If you want a simple path: You cannot solve this in $O(n^3)$ time (unless $P=NP$).

If you allow the path to be non-simple: No. Read about all-pairs shortest paths.

  • $\begingroup$ According to exercise 24.1.5 from CLRS book we can solve it by Bellma- Ford algorithm. $\endgroup$
    – Ahmad
    Nov 16, 2021 at 13:29
  • $\begingroup$ Now can we conclude that, we can solve it in $O(n^3)$ or not? $\endgroup$
    – Ahmad
    Nov 16, 2021 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.