To find the lengths of shortest paths from a source vertex $s$ in a weighted Directed Acyclic Graph (DAG), the most efficient algorithm utilizes topological sorting.
Since each vertex is processed once in the topological order and each edge is relaxed exactly once (when its source vertex is processed), the edge relaxation phase takes $\Theta(m)$ time.
The total worst-case time complexity is the sum of the complexities of the topological sort and the edge relaxation steps:
Therefore, the fastest algorithm for finding shortest paths in a weighted DAG has a time complexity of $\Theta(n + m)$.
Floyd-Warshall algorithm utilizes __________ to solve the all-pairs shortest paths problem on a directed graph in __________ time.
An all-pairs shortest-paths problem is efficiently solved using :
Match List - I with List - II.
| List - I | List - II |
|---|---|
| (A) Dijkstra’s Algorithms | (I) Find the shortest path between all pairs of vertices in a graph with positive or negative edge weights. |
| (B) Floyd-Warshall Algorithms | (II) Finds the shortest path in a weighted graph with non-negative edge weights. |
| (C) Bellman-frod Algorithms | (III) Grows a spanning tree by repeatedly adding the smallest edge to a neighboring vertex. |
| (D) Prim’s Algorithms | (IV) Finds the shortest paths from a single source in a directed graph with negative edge weights. |
Choose the correct answer from the options given below :