(-single – q
Problems:
source
single –
shortest paths pair shortest
problems path problem
MONDAY, JAN 25th
cnn.in!!
single – –
–
shortest paths problem
source
vertex Find shortest path
s
from
fix
source
all other V EV pinning
F u t@ 4p’
E. 4Ei
–
–
4
s
to
,
Optimal
problem subproblem s .
contains
within
i t
–
An optimal solution
to a
Example
shortest
path
k
Example
optimal problem :
solutions to
finding
from it.
45 1mm4mmx4
huge’
subproblem : find short’t path from i to j
Lemmy
Formally :
p”
For
a
path i s
also a path ”
shortest
– Then : pi; is
t’ of subpath
pi ,
proofing suppose
pi ;
( by contradiction)
j hunt
p!; is then
shorter path than Pi;
.
”
Sub path
of
shortest
let anyi,;s.t.
=(v
.
wlpii.la wlpu )
shortest
path from 4MhY4m44wmg4
,
. .,
path
from
Y
to Yc .
ha .,
;;
,k
%)
be shortest Isi-jEk,letpi;=(vi.Viti… .,Vil
.
i to
.
I
-Notation
Thursday
,
Jan .
2 8th
S
source
vertex
shortest path from u to r
flu y Tian
–
of predecessor
–
weight ,
–
dat
-Initialization
f-or VEV
–
Tifr] = NULL
o f
currently upper
best –
path
of
best- known
path
s to v
r bound
in
–
currently
known shortest ffs, v1 )
shortest from
froms v t o
–
weight 8 ( will
3h”u’
3 v &
g. 3
dfv) = TIEN=”
28
Idm=
s.
3
d(
s]
=o
Hs v1
=6 ,
-Lemma
Let p= Cro,v
RELAX
( a ir )
(Path –
Relaxation)
if dful DID
1 –
%)
be shortest
path
t whirl s d
= T, Cv )
dful t whirl = U
from S Suppose
which
.. .,
— –
Vo to v – y .
a sequence of
.
.
.
calls to
subsequence Iii:: Ii:::i”” ”
RELAX
includes the
happens “””””” “‘
das
z
Sls, v1
-Lemma
Let p= Cro ,v. .
(Path –
Relaxation)
proof: claim :
.- 5=0,4 ik
,
jth call to
.
from S —
Vo to
.
%) v — Y.
be shortest
path
After
d(Vj)= f(s,v;)
RELAX
…
,
,
÷÷÷÷÷÷÷÷÷÷÷:÷÷:÷÷::÷:÷:÷:÷i’n o :c.÷ :”
”
. I.H
das =D Culture” ” I.Step dlr;] E day ] t w Cri ,
RELAX (air)
if dad twice, v1 a
dad
.
)=
flsivj
–
)
y-
Tl
Cv] = U
CI
.
-i
f
Sls, v;) :.
Assume
Ith RELAX call to
H.)
= =
,-
Vj
–
s
Vj
after j
d(Vj , l
,
–
N; ) (SVji)tw(, )
do
Iweighted Directed Acyclic Graph ( weighted BAG)
Algorithm
i n
Topo .
• – V
C
Obtain topological ordering using DFS
of vertices
order
ordering , if I Curlee
l .
•
bc
de
For
all edges Cu
2 .
For each vertex u EV
inn Topo. fixed
c- E : RELAX Him
-Algorithm
Obtain using
in
proof :-:i:÷:÷I÷: :
1.
topological DFS
ordering in Topo.
o f order
ve rtice s in
our long seq.
of
‘ callsto relax will be ,
subsequence
‘
of correctness ( FVEV find )
÷
.
.
–
ftp.III relaxation
.
shortest s- V path .
fr
om
path lemma
let v
be arbitrary and suppose is (Vo , Vi , . . – Nk)
.
-complexity
( I.
)
O(m)
0 m callsto
ntm RELAX
DFS
2.
: