Dijkstra's algorithm is a greedy algorithm that finds the shortest path from a source vertex to all other vertices in a weighted graph with non-negative edge weights. It's one of the most fundamental algorithms in graph theory and is widely used in network routing, GPS navigation, and social network analysis.
Algorithm Overview
The algorithm works by:
1. Starting from the source vertex with distance 0
2. Using a priority queue to always process the vertex with the minimum distance
3. Relaxing edges to update distances to neighboring vertices
4. Marking vertices as processed once their shortest distance is determined
Key Properties
Greedy Choice: Always selects the unprocessed vertex with minimum distance
Optimal Substructure: The shortest path to any vertex contains shortest paths to intermediate vertices
Non-negative Weights: Only works with graphs having non-negative edge weights
Single Source: Finds shortest paths from one source to all other vertices