Dijkstra's algorithm

Time complexity: O(E log V).

Result

Examples

How it works

Dijkstra always expands the cheapest cell found so far, spreading out in rings of equal cost. It finds the cheapest path to every cell, the goal included, by exploring in every direction.

When to use it

Shortest paths with costs, when there is no good guess of the distance to the goal.

Other algorithms