L18-shortestPaths

Why does dijkstra work triangle inequality upper

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: om s to v breadth-first search breadth-first search breadth-first search breadth first search input: output: smallest # of edges from s to v bfs(G, a) bfs(G, a) bfs(G, a) a bfs(G, a) 1 a 1 b d bfs(G, a) 1 a 1 2 2 b d c e bfs(G, a) 1 2 1 2 2 a b d c e f bfs(G, a) 1 2 1 2 2 a b d 3 3 c e f g h bfs(G, a) 1 2 1 2 2 3 3 a 3 b d c e f g h bfs(G, a) breadth first search bfs theorem :1" /;/< =)")" < *( -%0#*%0# &%'"+,(#*. • 3 L19 v ∈ < 0+ %#$ (#3> 0+ &%'" 2%1 20* v ?)* 2%1 #(* 4(-" ()* (+ v >"*. Dijkstra(G = (V, E ), s) 1 for all v ⇤ V 2 do du ⇥ 3 ⇥u nil 4 ds 0 5Q makequeue(V ) use du as key 6 while Q ⌅= ⇧ 7 do u extractmin(Q) 8 for each v ⇤ Adj (u) 9 do if dv > du + w(u, v ) 10 then dv du + w(u, v ) 11 ⇥v u 12 decreasekey(Q, v ) &'$()*#% $0,"4*"$ 6,%G2 A)#$0,"4*"$ "H%-G3" 0# ?((IB . @/!( = , 1 , ) ) !"# "%42 % ∈ = − {) } $" > A% B ← ∞ > A) B ← C <...
View Full Document

This note was uploaded on 02/25/2014 for the course CS 4102 taught by Professor Horton during the Spring '10 term at UVA.

Ask a homework question - tutors are online