| Purpose | Finds the shortest path from a single source vertex to all other vertices in a weighted graph. | Finds the shortest paths between all pairs of vertices in a weighted graph. |
| Input | A graph (directed or undirected) with non-negative edge weights and a single source vertex. | A graph (directed or undirected) with edge weights (can handle negative weights but no negative cycles). |
| Output | Shortest path distances from one source vertex to all other vertices. | Shortest path distances between every pair of vertices. |
| Algorithm Type | Greedy algorithm. | Dynamic programming algorithm. |
| Time Complexity | Using a priority queue (min-heap): O((V + E) log V), where V is the number of vertices and E is the number of edges. | O(V³), since it examines all pairs of vertices for every vertex. |
| Graph Requirements | Works only with non-negative edge weights (because it uses a greedy approach). | Can handle negative edge weights, but no negative weight cycles are allowed. |
| Use Case | When you need shortest paths from a single source vertex. | When you need shortest paths between all pairs of vertices. |
| Path Reconstruction | Can store predecessor information during execution to reconstruct single-source shortest paths. | Can be extended to store path information for reconstructing any shortest path. |