0% found this document useful (0 votes)
12 views13 pages

Week10 LectureNote Watermark

INTRODUCTION TO ALGORITHM AND ANALYSIS

Uploaded by

SandhyaKastala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
12 views13 pages

Week10 LectureNote Watermark

INTRODUCTION TO ALGORITHM AND ANALYSIS

Uploaded by

SandhyaKastala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 13
Week 10: Lectuve Alotes Topics: Correctness of Bellman Ford Application of Bellman Ford AN pairs shortest path Floyd- Warshall Jonnsen Algorithm Coreetness of Bellman Ford Theorem: 1f G+ LV.E) contains no negotive ~weight cycles then after the Bellman- ford algorithm enecutes, dlv] =\sl4,v)_ for x Frost Let VEN be any verlen, ‘avd consider o slortest path id from 5 40 witty the minimum number of edges. 5 UD . Since p is @ Shortest path, we have SL 9m) 2 $US, Vig) wl) Toi only , Alves Of SlSve), and Als] is unclong eal by Sulsequent relekotions. ~ After \ pass through E, we have dlvJ> (4) - After 2 passes thorough E, we have dlvsJe §lS¥4) - Afley K passes, we hove dlvy]s $(5.Vx Stwee 6 contains no negative- weight cycles, pid simple, Longest Simple path has ¢lvl-1 edges. Detection of negative - weight cycles Corotlary : TE a@ value div] fails to converge ofter W-1 passes, there enists o negative : weight cycle in G teocheble from 8. BAG Shortest paths TP the graph is 0 directed acyelic graph (pad), we Frvat Jopollog ically sort the vertices. Detevmine 4: V> [2 --y Wj such thet (uv) EE > gw) shortest paths enist. Cloim: The asi gument me Slovi) solves the constraints. Consider omy condtratmt a - 1% £Wi; and consider the shortest paths from 540 v; and ve. The triongle Inequality gives us 5 (5.5) £ $15.4) +0045, Simee oe Sl5,v;) and mj = S(5y;), the constraint Hoe t wi is satisfied. Bellmen- Ford ond linear Prograyaming Corollary: The Bellmen- Ford algorithm con solve & System of w diffeverce constveints on nw veriobles in Olmn) time. * Simale- source shortest peths is @ simple LP problem. q i ple LF p * Tw Pact, Bellman ford manimizes Aaa g-- tan subject 40 the constraints Aj- Hie wij and aveo * Bellman Ford also minimizes man; fac} min; fac} Shortest eths Single - source shortest peths: : Non- negative edge weights - by ketra’s algoritin - Ol E+V tog) * General - Bellman Ford - Olve) “DAG - One pasd of Bellman ford olv+e) A\l- pairs shortest paths + Now- wegqative edge weights = Dijketre’s algoritiona limes - OlvE +vtteg¥) A\\- pairs Shortest Porhs Inputs Digroph Qs W.€), where [vlem, wei gt Sonetion pn NOR Outpubs naw motrin of slroviest -poth leng for all inj EN: with edge- tne Lin) Tdea #1. * Run Bellman Ford once From each verter sTiwe + olvte). + Dense rar 7 oly") me Good Hest ty” ” Dynamic Proqowening Consider the nen adjacency matria. A: (94j) of the digraph, and define das" 2 weight of test poth Prom it0j 5 2 weig ot @ shortest Pe ‘om itoj nad used at most m edges. Claim: We have 7 fi if iej bw) dys Pte and Pow matty -- ened, tw ax” » wing {diy wa) Pont Proo? of claim: i) (wt) dys min, { dix voryy , eS s Yo, Relanation | Sor Keo Lion do if day >div +x} Mren dij div * On} NS Note. No- negative weight cycle plies Sli) + at, dies at", oo Motrin Muth plication Compute Ce A.B, wohere CA and B are nxn matrices: » 2 ain Ke) Times Oln') using. the stovdara algorithm - Wwet if we map © -o wiol and “see cee Cy: min, fain + Oxi} Thus, DP, paren 0 0 an Tdentity motrin > Is [= O37 © we (dig), @ of GO The (win, +) mulkiphication i> assoeiative and with the steel vumbers, it forms on algebraic siwcture called o closed semiring Consequently) we con ‘onreis Nee ys Ae ) Peat ~. haa m2) A ae yielding yp +, nen Timer 0 (wen?) = Bln") No better then nx B-F. Improved matrin multiplication algorithm Repeated Squoring : AKL Ak x at Tigtro1 Cownpute BY at ok Oleg m) Squavings- Note: AML ate AM. Time = 6 lv® lan) To detect negative weight Eyles, cheek the diagoral fox negokive veluesain Oln) additonal Hme. f loy d- Warshall Algorithm A\s0 dynomie progremming, out Foster! define eae weight of o shortest path From i 40) with intermediote vertices loelonging jo the set (ue KF Thus, Sli) = caf Algo. cule ay. Flo. d- Warshall Reeurreny et) a) Ue ‘we io 4 K) Cy e mings Coy AR Cie fen iwlemmediote vertices in fun kJ Pseudocede jor Floyd - Worshall b fey keaton 2. be fer tol nan = do for je-Jton ‘. do if Cy > Cet Cry ee relaxation Ss. then ay Cie > Cy Notes: Okey to omit superscripts, sive extra velaxat ons can't hurt Runs in Olas) Hme Simple to code EPR cient in prackeey Transitive ClosureCobje directed graph, Bs iP there enists a pote Prom 40) Core Si 0, othemwise bea: Use Floyd - Wershal), but with (vA) instead of (min, 4): . tr) Leet) led leo Time = Olv3) Theorem: Given @ label lv) for each ven, Teweight eoch edge (wv) €& by 0 (uv) © wluyv) + bly) - bly) Then all paths between the some twovertices are te weighted by the same amount. Prot Let Pewee =e bea path inthe qreph Then we have, wl p)+ z ® Wivin) »'E. LélveNigehby- blvd) er 2 @olp)awlvy) + nly) ‘Tobnson's Algorithn’ Find a verter Yaballing h such thet (wv) 70 for at\ (uw) EE by Using Belienon- ford 40 solve the difherence constraints: hv) -hlu) ¢ wluv) : or determining thot @ negative weight cycle emists. = Time» OlVE) 2 Run dijkstra’s algorithm From each vertex woing .. sTime = OLVE+N? log ¥) $ Reweight each shortest-path length Blp) te prodwe. the shortest -poth lengths wlp) of the original groph + Time solv’) Tota) Hme~ olve + V*teqV)

You might also like