Claviro

Shortest Path

Dijkstra's Algorithm

Algorithm
50%

Understanding Shortest Path Algorithms

Dijkstra vs Bellman-Ford

Dijkstra: Greedy, faster, doesn't handle negative weights.

Bellman-Ford: Slower, handles negative weights, detects negative cycles.

Distance Update Rule

d(s,v) = \min_u\{d(s,u) + w(u,v) : (u,v) \in E\}

About this concept

What to notice

Dijkstra greedily selects the closest unvisited node, always finding optimal paths.

Why it matters

Dijkstra powers GPS navigation, network routing, and game pathfinding algorithms.

Think about

How does your phone's maps app find the fastest route to your destination?

Formula & Application

Key Formula

d(s,v) = \min_u\{d(s,u) + w(u,v) : (u,v) \in E\}

Use this formula to calculate the relationship between different variables in this concept.

Example

Finding the shortest route with minimum travel time in a road network.