Plus courts chemins : d´efinition
Un plus court chemin entre deux sommets uet vest un chemin p
de u`a vde poids w(p) le plus faible possible
(u,v) est le poids d’un plus court chemin de u`a v:
(u,v)=min{w(p)|pest un chemin de u`a v}
(S’il n’y a pas de chemin entre uet v,(u,v)=1par d´efinition)
Exemples :
648 Chapter 24 Single-Source Shortest Paths
(a) (b) (c)
0
6
6
7212 4
3
53
s
tx
yz
39
5 11
0
6
6
7212 4
3
53
s
tx
yz
39
5 11
0
6
6
7212 4
3
53
s
tx
yz
39
5 11
Figure 24.2 (a) Aweighted,directedgraphwithshortest-pathweightsfromsources.(b) The
shaded edges form a shortest-paths tree rooted at the source s.(c) Another shortest-paths tree with
the same root.
Shortest paths are not necessarily unique, and neither are shortest-paths trees. For
example, Figure 24.2 shows a weighted, directed graph and two shortest-paths trees
with the same root.
Relaxation
The algorithms in this chapter use the technique of relaxation.Foreachvertex
!2V,wemaintainanattribute!:d,whichisanupperboundontheweightof
ashortestpathfromsourcesto !.Wecall!:dashortest-path estimate.We
initialize the shortest-path estimates and predecessors by the following ‚.V /-time
procedure:
INITIALIZE-SINGLE-SOURCE.G; s/
1for each vertex !2G:V
2!:dD1
3!:"DNIL
4s:dD0
After initialization, we have !:"DNIL for all !2V,s:dD0,and!:dD1for
!2V!fsg.
The process of relaxing an edge .u; !/consists of testing whether we can im-
prove the shortest path to !found so far by going through uand, if so, updat-
ing !:dand !:".Arelaxationstep
1may decrease the value of the shortest-path
1
The use of the term is historical. The outcome of a relaxation step can be viewed as a relaxation
of the constraint !:d"u: dCw.u;!/,which,bythetriangleinequality(Lemma24.10),mustbe
satisfied if u:dDı.s; u/ and !:dDı.s; !/.Thatis,if!:d"u:dCw.u; !/,thereisno“pressure”
It may seem strange that the term “relaxation” is used for an operation that tightens an upper bound.
so the constraint is “relaxed.”
to satisfy this constraint,