A

AlgoCity Pro

Advanced Pathfinding Visualization Engine

LATENCY40ms

Spatial Network Topology — 20×40

Greedy

Dijkstra's Algorithm

Always picks the unvisited node with the smallest known distance. Guaranteed shortest path for non-negative weights.

Time
O((V + E) log V)
Space
O(V)
Algorithm Logic
1Initialize dist[src] = 0, all others = ∞
2Push (0, src) into min-priority queue
3While PQ not empty:
4 (d, u) = PQ.pop() ← GREEDY CHOICE
5 If d > dist[u]: skip
6 For each neighbor v of u:
7 If dist[u] + w(u,v) < dist[v]:
8 dist[v] = dist[u] + w(u,v)
9 PQ.push(dist[v], v)
Optimal for non-negative weights
Fast with priority queue
Widely used in practice
Implementation Case
GPS navigation, network routing (OSPF), Google Maps