How it works
How it works
Keep tentative distances, always expand the nearest unvisited node, and relax each of its neighbors.
Priority queue
A min-heap makes selecting the closest node efficient, giving O((V plus E) log V) time.
Limitations
It requires non-negative weights; for graphs with negative edges use Bellman-Ford instead.