AI can make mistakes. Check important information.

Dijkstra's algorithm

Dijkstra finds the cheapest path from one source to every node in a graph with non-negative edge weights. Green arrows form the final shortest-path tree; grey edges were never the best option, and each node's height is its distance from A.