Dijkstra’s algorithm starts with distance zero at the source and repeatedly settles the unsettled node with the smallest tentative distance. It relaxes neighbors whenever a shorter route appears.
A settled distance stays final only when edge weights are nonnegative. Negative edges require a different algorithm.
When to use
Use it for least-cost paths when edge weights cannot be negative.