Sie sind auf Seite 1von 4

Single-Source Shortest Paths SingleDef.

Given a weighted directed graph (G(V,E),w), we G(V,E),w) define the weight of a path

Single-Source Shortest Paths Problem: Given a Single-

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

as the sum of the weights of its constituent edges, it k i.e., as

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

Single-Source Shortest Paths Single-

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)

Single-Source Shortest Paths Single-

predecessor

Shortest Path Representation For each vertex v V , we maintain a

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

[ ]

The shortest path is not unique.

where

G = (V , E ) V = {v V : [ v] NIL} { s} E = {( [ v] , v ) E : v V { s}}

Shortest Path Tree


The algorithms we will consider will compute a shortest path tree

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-

Bellman-Ford Algorithm Bellman-

Single-Source Shortest Paths in DAGs Single-

Single-Source Shortest Paths in DAGs Single-

Dijkstras Algorithm Dijkstra

Dijkstras Algorithm Dijkstra

Dijkstras Algorithm Dijkstra

Linear System of Difference Constraints

Weighted Directed Graph Associated with a Linear System of Difference Constraints


x j xi bk edge ( vi , v j ) of weight bk

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, .

We add an additional vertex edges v , v x 0 i i

v0 ,

and the

Weighted Directed Graph Associated with a Linear System of Difference Constraints

Das könnte Ihnen auch gefallen