

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The concept of shortest paths in directed graphs, focusing on dijkstra's algorithm. It covers the basics of directed graphs, shortest path networks, and the existence and properties of shortest paths. The document also provides an overview of dijkstra's algorithm, its proof of correctness, and related topics such as priority queues and heaps.
Typology: Slides
1 / 3
This page cannot be seen from the preview
Don't miss anything!


s
3
t
2
6
7
4
5
(^2318)
2
9
14 15
5
30 20
44
11 16
6
19
6
1
3
8
2
6
7
4
5
Directed graph: G = (V, E).
n^
V = set of vertices or nodes. n^
V = set of edges or arcs.
n^
n = |V|, m = |E|. n^
Directed path: s - 2 - 3 - 5 - t.
-^
simple
n^
Directed cycle: 5 - 4 - 3 - 5.
3
communication
Network
telephone exchanges,computers, satellites
Nodes
Arcs
cables, fiber optics,microwave relays
Flow
voice, video,packets
circuits
gates, registers,processors
wires
current
mechanical
joints
rods, beams, springs
heat, energy
hydraulic
reservoirs, pumpingstations, lakes
pipelines
fluid, oil
financial
stocks, currency
transactions
money
transportation
airports, rail yards,street intersections
highways, railbeds,airway routes
freight,vehicles,passengers
Shortest path network: (V, E, s, t, c).
n^
Directed graph (V, E). n^
Source s
V, sink t
n^
Arc costs c(v, w). n^
Cost of path = sum of arc costs in path.
Cost of path s - 2 - 3 - 5 - t
s
3
t
2
6
7
4
5
(^2318)
2
9
14 15
5
30 20
44
11 16
6
19
6
5
Shortest path problem. (CLR 25.1-25.2)
n^
Shortest path network (V, E, s, t, c). n^
Find shortest directed path from s to t.
Assumptions.
n^
Network contains directed path from s to every other node. n^
Network does not contain a negative cost cycle.
Application.
n^
Online directions.
3 4
5
-6 7
Existence. If some path from s to v contains a negative cost cycle,there does not exist a shortest path. Otherwise, there exists a shortests-v that is simple.
If negative cycle, can produce arbitrarily negative path bytraversing cycle enough times.
⇐
If no negative cycle, can remove cycles without increasing cost.
s
v
C c(C) < 0
7
Optimal substructure property. All sub-paths of shortest paths areshortest paths.
n^
Let P
1
be x-y sub-path of shortest s-v path P.
n^
Let P
2
be any x-y path.
n^
c(P
c(P
), otherwise P 2
not shortest s-v path.
Triangle inequality.
n^
Let d*(v, w) be the length of the shortest path from v to w. n^
Then, d*(v, w)
d(v, x) + d(x, w)
v
w
x
s
v
2 P
1
y
x
Upon termination.
n^
π
(v) = distance of shortest s-v path.
n^
pred(v) gives shortest path.
for each v
π
(v)
pred(v)
nil
π
(s)
φ
init(Q)for each v
insert(v, Q)
while (Q
φ
v = delete-min(Q)S
{v}
for each w s.t (v,w)
if
π
(w) >
π
(v) + c(v,w)
π
(w)
← π
(v) + c(v,w)
pred(w)
v
Dijkstra’s Algorithm
decrease-key