Chapter 24 - SHEN'S CLASS NOTES Chapter 24 Single Source...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
SHEN’S CLASS NOTES Chapter 24 Single Source Shortest Paths As we have defined earlier, given a weighted graph G(V, E), directed or undirected, the weight of a path p = < v 0 , v 1 , v 2 , …, v k > is the sum of all edge weights on the path: w ( p ) = = k i 1 w ( v i -1 , v i ). We define the shortest path weight from u to v by δ ( u , v ) = otherwise } to from path a is | ) ( { v u p p w Min A path  p ( u v ) is  a shortest path  if  w ( p ( u v )) =  δ ( u , v ) . Definition 1  The   single-source shortest-paths   problem is to  find a shortest path from a given source  s    V to each vertex  v   V. Definition 2  The  single-pair shortest-paths  problem is to find  a shortest path  p ( u v ) for given vertices  u  and  v . 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
SHEN’S CLASS NOTES The single-pair shortest-paths problem seems easier than the  single-source shortest-paths problem, but actually, no known  algorithm exists that can solve the single-pair shortest-paths  problem faster in worst case.  Definition 3  The   all-pair shortest-paths   problem is to find a  shortest path  p ( u v ) from every vertex  u  to every other vertex  v . This chapter discusses the single-source shortest-paths problem  only.   We   will   discuss   the   Bellman-Ford   algorithm   and   the  Dijkstra’s algorithm.  Both   algorithms  follow   a  greedy  approach.   Both  algorithms  maintain an attribute   d [ v ] for every vertex which is an upper  bound on the weight of a shortest path from source  s  to vertex  v So,  d [ v ] is called a shortest path estimate.  Initially,  d [ v ] is set to   for every vertex except  s , and  d [ s ] = 0.  Then the algorithms improve the estimates step by step until the  shortest paths are obtained. For each vertex  v , both algorithms  also use a pointer  π ( v ) to point to the predecessor from which  d [ v ]   is   obtained.   This   pointer   is   called   v ’s   father   pointer.  Initially,   π ( v )   =   nil.   The   following   piece   of   code   is   the  initialization used by both algorithms.  2
Background image of page 2
Initialize-Single-Source (G,  s ) 1 for  each vertex  v   V[G] 2   do  { d [ v 3   π ( v nil 4     } 5 d [ s 0 Relaxation Relaxation is a simple operation used by both algorithms to  improve the shortest path estimates. The piece of code for this  operation is as follows. Relax( u v w ) 1 if  d [ v ] >  d [ u ] +  w ( u v ) 2   then  {  d [ v   d [ u ] +  w ( u v ) 3   π ( v u 4   } The essence of Relax( u v w ) is that if vertex  v  can get a shorter  path through vertex  u , then replace the  d [ v ] by the shorter one 
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/12/2008 for the course CS 592 taught by Professor Shen during the Fall '05 term at University of Missouri-Kansas City .

Page1 / 16

Chapter 24 - SHEN'S CLASS NOTES Chapter 24 Single Source...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online