Search code examples
time-complexitydijkstra

Is there any modified version of Djikstra with O(V+E) complexity?


I am looking to create a modified version of Djikstra to find number of shortest paths from a source to a target vertex. Using arrays, I have O(V^2), using binary heap, I have O(ElgV), and using Fibonacci heap, I have O(E+VlgV). Is there a way to modify it to be O(V+E) instead?


Solution

  • If the graph is acyclic (DAG) it is possible to use topological sorting to achieve O(V+E).