Step through the algorithm and watch the distance table update when a shorter path is found
Dijkstra's algorithm finds the shortest path from a source node to every other node in a weighted graph. It works by always processing the unvisited node with the smallest known distance.
Key insight: A node's distance may be updated multiple times before it is visited. Each update means a shorter path was found through a different route. Once a node is visited, its shortest distance is finalised and never changes.
Time complexity: O(V²) with a simple array, or O((V + E) log V) with a priority queue, where V = vertices and E = edges.