<DS/>DS_VISUALIZER
FoundationsOOPArraysLinked ListStacksQueuesTreesGraphsHashingStrings
exploreExplore
homechevron_rightTopicschevron_rightGraphschevron_rightShortest Path
route

GRAPHS · SHORTEST PATH

Shortest Path

Cheapest routes: greedy, brute-force, and all-pairs.

Choose an algorithm

routearrow_outward

Dijkstra

Lock in the closest node, relax its edges.

O((V+E) log V)O(V)◍ 0/6
sync_problemarrow_outward

Bellman–Ford

Relax all edges V−1 times; handles negatives.

O(V·E)O(V)◍ 0/6
grid_4x4arrow_outward

Floyd–Warshall

All pairs, one matrix, three loops.

O(V³)O(V²)◍ 0/6