Beruflich Dokumente
Kultur Dokumente
http://ocw.mit.edu
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
Lecture 18
Dijkstra
Lecture Overview
Single-source single-target Dijkstra
Bidirectional search
Goal directed search - potentials and landmarks
Readings
Wagner, Dorothea, and Thomas Willhalm. "Speed-Up Techniques for Shortest-Path
Computations." In Lecture Notes in Computer Science: Proceedings of the 24th Annual
Symposium on Theoretical Aspects of Computer Science. Berlin/Heidelberg, MA: Springer,
2007. ISBN: 9783540709176. Read up to section 3.2.
DIJKSTRA Demo
4
B
19
15
11
13
C
A C E B D
7 12 18 22
D B E C A
4 13 15 22
E
E C A D B
5 12 13 16
Lecture 18
Bi-Directional Search
Note: Speedup techniques covered here do not change worst-case behavior, but reduce the
number of visited vertices in practice.
backward search
forward search
Bi-D Search
Alternate forward search from s
backward search from t
(follow edges backward)
df (u) distances for forward search
db (u) distances for backward search
Algorithm terminates when some vertex w has been processed, i.e., deleted from the queue
of both searches, Qf and Qb
u
3
s
5
w
Lecture 18
Subtlety: After search terminates, nd node x with minimum value of df (x) + db (x). x may
Find shortest path from s to x using f and shortest path backwards from t to x using b .
Forward
3
df (s) = 0
df (u) = 6
Backward
3
df (t) = 10
df (s) = 0
db (s) = 10
df (w) = 5
db(t) = 0
5
db (w) = 5
df (u) = 3
s
df (s) = 0
df (w) = 5
db(u) = 6
db(u) = 3
Backward
3
t db(t) = 0
w db (w) = 5
Forward
df (w) = 5
df (u) = 3
df (u) = 6
db(u) = 3 3
df (s) = 0
Backward
df (u) = 3
Forward
df (u) = 3
db(u) = 6
5
db(u) = 3
df (u) = 6
t
5
db(t) = 0
df (t) = 10
db (w) = 5
df (w) = 5
Lecture 18
df (u ) + db (u ) = 6 + 3 = 9
df (w) + db (w) = 5 + 5 = 10
Goal-Directed Search or A
Modify edge weights with potential function over vertices.
w (u, v) = w (u, v) (u) + (v)
Search toward target:
v
increase
go uphill
5
decrease
go downhill
Correctness
w(p) = w(p) t (s) + t (t)
So shortest paths are maintained in modied graph with w weights.
p
Figure 6: Modifying Edge Weights
To apply Dijkstra, we need w(u, v) 0 for all (u, v).
Landmarks
(l)
Small set of landmarks LCV . For all uV, lL, pre-compute (u, l).
Potential t (u) =
(u, l) = (t, l) for each l.
(l)
CLAIM: t is feasible.
Lecture 18
Feasibility
(l)
(l)
(l)
max t (u)
lL
is also feasible
by the -inequality