0
$\begingroup$

If I have a directed graph with $n$ weighted edges, is it possible to prove that Dijkstra's single-source shortest path algorithm takes $\Omega(n\log n)$ in the worst case?

I know heaps reduce Dijkstra's algorithm to $Ο(m \log n)$ and can be stored in an array. Rooted, binary, as complete as possible tree with all nodes satisfy Heap property: node <= all children of node.. Is this the right direction?

**I have an implementation that runs $O( (n + m)\log n),ドル could it work?

David Richerby
82.6k26 gold badges146 silver badges240 bronze badges
asked Dec 12, 2014 at 15:21
$\endgroup$
1
  • $\begingroup$ 1. It's standard convention to use $n$ to denote the number of vertices and $m$ the number of edges. Can you edit your question accordingly? As it stands this risks tripping up many people. 2. What precisely do you mean by $\Omega(n \log n)$? When there are two variables, big-O notation can potentially be misleading/misinterpreted unless you're very precise about what you mean. $\endgroup$ Commented Dec 13, 2014 at 6:07

1 Answer 1

1
$\begingroup$

Let $m$ be the number of vertices and $n$ the number of edges. The best you can get is $O(n + m \log m)$ by using a Fibonacci heap.

A Fibonacci heap allows decreasing the key of an element in amortized constant time. For each edge in the graph, Dijkstra's algorithm executes at most one decrease key operation. All these operations take time $O(n)$ in total. On top of that we have $m$ minimum extractions, which take time $O(m \log m)$ in total. Therefore the final complexity is $O(n + m \log m)$.

answered Dec 12, 2014 at 22:13
$\endgroup$
2
  • 3
    $\begingroup$ It is somewhat weird to denote the number of vertices by $m$ and the number of edges by $n$. I have totally misunderstood your answer at the first glance. $\endgroup$ Commented Dec 13, 2014 at 2:22
  • 1
    $\begingroup$ I originally had the notation like that, but then I noticed that in the question it is the other way around, so I edited it because I thought it would be better to be consistent with the notation of the question. $\endgroup$ Commented Dec 13, 2014 at 10:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.