Beruflich Dokumente
Kultur Dokumente
Given a weighted directed graph (G(V,E),w), we G(V,E),w) define the weight of a path
weighted graph ((G=(V,E),w), find a shortest path ((G=(V,E),w), from a given source vertex s V to each vertex
p = v0 , v1 , , vk
v V
w( p) =
w (v
i=1
Other variants 0f this problem Single-destination shortest-paths problem: Find a Singleshortestshortest path to a given destination t for each vertex v. Single-pair shortest-path problem: For given Singleshortestvertices u and v, find a shortest path from u to v All-pairs shortest-paths problem: For all pairs of Allshortestvertices (u,v), find a shortest path from u to v. u,v)
i1
,vi )
We define the shortest-path weight ( u, v ) of shortestfrom u to v as min { w ( p ) : u p v } if a path from u to v ( u, v ) = otherwise A shortest path is one of shortest path weight.
Optimal Substructure
Lemma 24.1(Page 582). Given a weighted directed graph (G=(V,E),w). Let p = v1 , v 2 , , v k be a (G=(V,E),w) shortest path from v1 to vk, then for every i,j s.t. s.t. 1 i j k, the subpath p ij = v i , , v j is a shortest path from vi to vj. Proof:
p1 i ij jk v1 vi v j vk p p
A shortest path exists iff there are no reachable negative cycles. Each node v contains a field d[v] which is an upper bound d[v] of (s,v) (s,v)
predecessor
v that is either a vertex or NIL. The algorithms given in this chapter will NIL. set the predecessor [ v ] so that [ v ] points to the previous vertex on the shortest path from source s to v. In this way, the shortest path is represented.
We thus have a predecessor subgraph
[ ]
where
G = (V , E ) V = {v V : [ v] NIL} { s} E = {( [ v] , v ) E : v V { s}}
Relaxation
G = (V , E )
where
V = {v V : [ v ] NIL} { s}
E = {( [ v] , v ) E : v V { s}}
Properties
Two Single-Source Shortest Paths Single Bellman-Ford A dynamic programming alg Bellman Dijkstra A greedy algorithm which works only when weight function is non-negative non-
xi v i V
Lemma. Let Ax b be a linear system of difference constraints. Then, if x=a is a solution, then so is a+(1,1,,1) for every real +(1,1, .
v0 ,
and the