= k w ( p ) w v ( , v ) i 1 i Single Single- - - PDF document

k w p w v v i 1 i single single destination shortest
SMART_READER_LITE
LIVE PREVIEW

= k w ( p ) w v ( , v ) i 1 i Single Single- - - PDF document

Single Single- -Source Shortest Paths Source Shortest Paths Single Single- -Source Shortest Paths Problem: Source Shortest Paths Problem: Given a Given a weighted graph ((G=( ((G=(V,E),w V,E),w), ), find a shortest path find a shortest


slide-1
SLIDE 1

1

Single Single-

  • Source Shortest Paths

Source Shortest Paths

Def.

  • Def. Given a weighted directed graph

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

  • f a

a path path as the sum of the weights of it as the sum of the weights of it’ ’s constituent edges, s constituent edges, i.e., as i.e., as We define the We define the shortest shortest-

  • path

path weight weight

  • f
  • f

from from u u to to v v as as A A shortest shortest path path is one of shortest path weight. is one of shortest path weight.

1

, , ,

k

p v v v = …

1 1

( ) ( , )

k i i i

w p w v v

− =

= ∑ { } { }

min ( ) : ( , )

p

w p u v if a path from u to v u v

  • therwise

δ      → ∃ → ∃ = ∞ 

( , ) u v δ

Single Single-

  • Source Shortest Paths Problem:

Source Shortest Paths Problem: Given a Given a weighted graph weighted graph ((G=( ((G=(V,E),w V,E),w), ), find a shortest path find a shortest path from a given source vertex to each vertex from a given source vertex to each vertex

s V ∈ v V ∈

  • Single

Single-

  • destination shortest

destination shortest-

  • paths problem:

paths problem: Find a Find a shortest path to a given destination shortest path to a given destination t t for each for each vertex vertex v v. .

  • Single

Single-

  • pair shortest

pair shortest-

  • path problem:

path problem: For given For given vertices vertices u u and and v v, find a shortest path from , find a shortest path from u u to to v v

  • All

All-

  • pairs shortest

pairs shortest-

  • paths problem:

paths problem: For all pairs of For all pairs of vertices vertices ( (u,v u,v) ), find a shortest path from , find a shortest path from u u to to v v. . Other variants 0f this problem Other variants 0f this problem

Optimal Substructure Optimal Substructure

Lemma 24.1(Page 582). Given a weighted directed Lemma 24.1(Page 582). Given a weighted directed graph graph (G=( (G=(V,E),w V,E),w) ). Let be a . Let be a shortest path from shortest path from v v1

1 to

to v vk

k, then for every

, then for every i,j i,j s.t s.t. . , the , the subpath subpath is is a shortest path from a shortest path from v vi

i to

to v vj

j.

. Proof: Proof:

1 2

, , ,

k

p v v v = … 1 i j k ≤ ≤ ≤ ≤ ≤

, ,

ij i j

p v v = …

1

1

ij jk i

p p p i j k

v v v v  →  →  →  →  → Single Single-

  • Source Shortest Paths

Source Shortest Paths

A shortest path exists A shortest path exists iff iff there are no there are no reachable negative cycles. Each node reachable negative cycles. Each node v v contains a field contains a field d[v d[v] ] which is an upper bound which is an upper bound

  • f
  • f δ

δ(s,v (s,v) )

Single Single-

  • Source Shortest Paths

Source Shortest Paths

The shortest path is not unique. The shortest path is not unique.

Shortest Path Representation Shortest Path Representation

For each vertex For each vertex , we maintain a , we maintain a predecessor predecessor that is either a vertex or that is either a vertex or NIL

  • NIL. The algorithms given in this chapter will

. The algorithms given in this chapter will set the predecessor so that points set the predecessor so that points to the previous vertex on the shortest path from to the previous vertex on the shortest path from source source s s to to v

  • v. In this way, the shortest path is

. In this way, the shortest path is represented. represented. We thus have a We thus have a predecessor predecessor subgraph subgraph where where

v V ∈ [ ] [ ]

v π

[ ] [ ]

v π

[ ] [ ]

v π

( ) ( )

, G V E

π π π π π

= [ ] [ ] { } { }

: V v V v NIL s

π

π = ∈ = ∈ ≠ ∪

[ ] [ ] ( ) ( ) { }

{ }

, : E v v E v V s

π π π π

π = ∈ = ∈ ∈ −

slide-2
SLIDE 2

2

Shortest Path Tree Shortest Path Tree

The algorithms we will consider will compute The algorithms we will consider will compute a shortest path tree a shortest path tree where where

( ) ( )

, G V E

π π π π π

= [ ] [ ] { } { }

: V v V v NIL s

π

π = ∈ = ∈ ≠ ∪

[ ] [ ] ( ) ( ) { }

{ }

, : E v v E v V s

π π π π

π = ∈ = ∈ ∈ −

Relaxation Relaxation Properties Properties Two Single Two Single-

  • Source Shortest Paths

Source Shortest Paths

  • Bellman

Bellman-

  • Ford

Ford – – A dynamic programming A dynamic programming alg alg

  • Dijkstra

Dijkstra – – A greedy algorithm which works A greedy algorithm which works

  • nly when weight function is
  • nly when weight function is non

non-

  • negative

negative

Bellman Bellman-

  • Ford Algorithm

Ford Algorithm

Single Single-

  • Source Shortest Paths in

Source Shortest Paths in DAGs DAGs

slide-3
SLIDE 3

3

Single Single-

  • Source Shortest Paths in

Source Shortest Paths in DAGs DAGs

Dijkstra Dijkstra’ ’s s Algorithm Algorithm Dijkstra Dijkstra’ ’s s Algorithm Algorithm Dijkstra Dijkstra’ ’s s Algorithm Algorithm

Linear System of Difference Constraints Linear System of Difference Constraints

  • Lemma. Let be a linear system of
  • Lemma. Let be a linear system of

difference constraints. Then, if difference constraints. Then, if x=a x=a is a is a solution, then so is solution, then so is a a+λ +λ(1 (1,1 ,1 +λ +λ(1 (1,1 ,1, ,… …,1) ,1) for every real for every real λ λ. .

Ax b ≥ Weighted Directed Graph Weighted Directed Graph Associated with a Linear System of Associated with a Linear System of Difference Constraints Difference Constraints

i i

x v V ↔ ∈ ↔ ∈

( ) ( )

,

j i k i j k

x x b edge v v

  • f weight b

− ≤ − ≤ ↔

We add an additional vertex , and the We add an additional vertex , and the edges edges

v

( ) ( )

0, i i

v v x ∀

slide-4
SLIDE 4

4

Weighted Directed Graph Associated with a Weighted Directed Graph Associated with a Linear System of Difference Constraints Linear System of Difference Constraints