Dijkstra’s Algorithm

Relaxation of an edge: if some path has a shorter distance than another path that start and end at the same point, remove the path that is longer.

Claim: Dijkstra's algorithm has the triangle inequality hold.

$$ \delta(a,b)\leq \delta(a,c)+\delta(c,b) $$

graph LR;
A-->B
A-->C
C-->B

Claim: Subpath of a shortest path is a shortest path.

Claim: The relaxation operation on some edge $(u,\, v)$ guarantees that $d[v] \geq \delta(u,\,v)$ where $d$ represents the distance.

Proof: By induction on number of relaxation steps.

By Claim 1,

$\delta(s, v) \leq \delta(s, u) + \delta(u,v)$

$\leq d[u] + w(u,v)$

$=d[v]$

Shortest Path in DAGs

  1. Topologically sort DAG
  2. Pass through once in topological order of relaxing all edges at once

Dijkstra’s

Find the shortest path greedily from explored set.

$D(G,W,S)$

  1. Initialize
  2. Explored → $S$
  3. Unexplored → $\{V-S\}$
while unexplored is not empty
	(u, v) = extract minimum from unexplored
	relax(u, v)
	explored = explored.append(v)
	unexplored = unexplored.pop(v)
	for each edge of v
		update priority queue

Fibonacci heap: $O(V\log V + E)$

$\Theta(\log V)$ extract-min

$O(1)$ extact-key