《算法入门》(英文版)Lecture 18 Prof. Erik Demaine

Introduction to algorithms 6.046J/18,401J/SMA5503 Lecture 18 Prof erik demaine
Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 18 Prof. Erik Demaine

Negative-weight cycles Recall: If a graph G=(V, E) contains a negative weight cycle then some shortest paths may not exist Example: <0 Bellman-Ford algorithm: Finds all shortest-pat lengths from a sources e y to all ve yor determines that a negative-weight cycle exists c 2001 by Charles E Leiserson Introduction to Algorithms Day 31 L18.2
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 31 L18.2 Negative-weight cycles Recall: If a graph G = (V, E) contains a negativeweight cycle, then some shortest paths may not exist. Example: uu vv … < 0 Bellman-Ford algorithm: Finds all shortest-path lengths from a source s ∈ V to all v ∈ V or determines that a negative-weight cycle exists

Bellman- Ford algorithm ds]du+ w(u, v) relaxation then dlv]←+w(al,y)∫step for each edge(l2y)∈E do if dv>du+w(u, v) then report that a negative-weight cycle exists At the end dv=8(s, v). Time=O(VE) c 2001 by Charles E Leiserson Introduction to Agorithms Day31L18.3
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 31 L18.3 Bellman-Ford algorithm d[s] ← 0 for each v ∈ V – {s} do d[v] ← ∞ for i ← 1 to |V| – 1 do for each edge (u, v) ∈ E do if d[v] > d[u] + w(u, v) then d[v] ← d[u] + w(u, v) for each edge (u, v) ∈ E do if d[v] > d[u] + w(u, v) then report that a negative-weight cycle exists initialization At the end, d[v] = δ(s, v). Time = O(VE). relaxation step

Example of bellman-Ford AB C E B 0 E D c 2001 by Charles E Leiserson Introduction to Agorithms Day 31 L18.4
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 31 L18.4 Example of Bellman-Ford AA BB EE CC DD –1 4 1 2 –3 2 5 3 ABCDE 0 ∞∞∞∞ ∞ 0 ∞ ∞ ∞

Example of Bellman-Ford AB C E B 2 000 E D c 2001 by Charles E Leiserson Introduction to Agorithms Day 31 L18.5
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 31 L18.5 –1∞ 0 –1 ∞∞∞ Example of Bellman-Ford AA BB EE CC DD –1 4 1 2 –3 2 5 3 ABCDE 0 ∞∞∞∞ 0 ∞ ∞ ∞

Example of bellman-Ford AB C E B 000 E)0-14∞ D 4 c 2001 by Charles E Leiserson Introduction to Agorithms Day 31 L18.6
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 31 L18.6 –1∞ 0 –1 ∞∞∞ Example of Bellman-Ford AA BB EE CC DD –1 4 1 2 –3 2 5 3 ABCDE 0 ∞∞∞∞ 0 ∞ 4 ∞ 0 –1 4 ∞∞

Example of bellman-Ford AB C E B 000 E)0-14∞ 0-12∞ D c 2001 by Charles E Leiserson Introduction to Agorithms Day 31 L18.7
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 31 L18.7 4 0 –1 2 ∞ ∞ 2 –1∞ 0 –1 ∞∞∞ Example of Bellman-Ford AA BB EE CC DD –1 4 1 2 –3 2 5 3 ABCDE 0 ∞∞∞∞ 0 ∞ ∞ 0 –1 4 ∞∞

Example of bellman-Ford AB C E B 000 E)0-14∞ 0-12∞ D c 2001 by Charles E Leiserson Introduction to Agorithms Day 31 L18.8
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 31 L18.8 –1∞ Example of Bellman-Ford AA BB EE CC DD –1 4 1 2 –3 2 5 3 0 ∞ 2 ∞ 0 –1 2 ∞ ∞ 0 –1 ∞∞∞ ABCDE 0 ∞∞∞∞ 0 –1 4 ∞∞

Example of bellman-Ford AB C E B人、2 000 E)0-14∞ 0-12∞ D 0-12∞1 c 2001 by Charles E Leiserson Introduction to Agorithms Day 31 L18.9
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 31 L18.9 –1∞ Example of Bellman-Ford AA BB EE CC DD –1 4 1 2 –3 2 5 3 0 2 ∞ 0 –1 2 ∞ ∞ 0 –1 ∞∞∞ ABCDE 0 ∞∞∞∞ 0 –1 4 ∞∞ 1 0 –1 2 ∞ 1

Example of bellman-Ford AB C E B 000 E 14∞ 12∞ D 0000 12∞1 c 2001 by Charles E Leiserson Introduction to Agorithms Day 31 L18.10
© 2001 by Charles E. Leiserson Introduction to Algorithms Day 31 L18.10 ∞1 0 –1 2 1 1 –1∞ Example of Bellman-Ford AA BB EE CC DD –1 4 1 2 –3 2 5 3 0 2 0 –1 2 ∞ ∞ 0 –1 ∞∞∞ ABCDE 0 ∞∞∞∞ 0 –1 4 ∞∞ 1 0 –1 2 ∞ 1
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《算法入门》(英文版)Lecture 17 Prof. Erik Demaine.pdf
- 《算法入门》(英文版)Lecture 16 Prof. Charles E. Leiserson.pdf
- 《算法入门》(英文版)Lecture 15 Prof. Charles E. Leiserson.pdf
- 《算法入门》(英文版)Lecture 14 Prof. Charles E. Leiserson.pdf
- 《算法入门》(英文版)Lecture 13 Prof. Erik Demaine.pdf
- 《算法入门》(英文版)Lecture 12 Prof. Erik Demaine.pdf
- 《算法入门》(英文版)Lecture 11 Prof. Erik Demaine.pdf
- 《算法入门》(英文版)Lecture 10 Prof. Erik Demaine.pdf
- 《算法入门》(英文版)Lecture 9 Prof. Charles E. Leiserson.pdf
- 《算法入门》(英文版)Lecture 8 Prof. Charles E. Leiserson.pdf
- 《算法入门》(英文版)Lecture 7 Prof. Charles E. Leiserson.pdf
- 《算法入门》(英文版)Lecture 6 Prof. Erik Demaine.pdf
- 《算法入门》(英文版)Lecture 5 Prof. Erik Demaine.pdf
- 《算法入门》(英文版)Lecture 4 Prof. Charles E. Leiserson.pdf
- 《算法入门》(英文版)Lecture 3 Prof. Erik Demaine.pdf
- 《算法入门》(英文版)Lecture 2 Prof. Erik Demaine.pdf
- 《算法入门》(英文版)Lecture 1 Prof. Charles E. Leiserson.pdf
- 《城市设计实例—步行商业》杭州湖滨旅游商贸特色街区.ppt
- 《教育心理学》(英文版)Theories Operant Conditioning.ppt
- 《教育心理学》(英文版)Theories:Operant Conditioning.ppt
- 《算法入门》(英文版)Lecture 19 Prof. Erik Demaine.pdf
- 《算法入门》(英文版)Lecture 20 Prof. Erik Demaine.pdf
- 《算法入门》(英文版)Lecture 21 Prof. Charles E. Leiserson.pdf
- 《算法入门》(英文版)Lecture 22 Prof. Charles E. Leiserson.pdf
- 《算法入门》(英文版)Lecture 23 Prof. Charles E. Leiserson.pdf
- 《加快林业建设—缓解气候变化》讲义.ppt
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)Alkene/Alkyne Hydrozirconation.pdf
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)Olefin functionalization via metal promoted Nu attack.pdf
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)Murai has described the synthesis.pdf
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)π-Trimethylenemethane cyclization.pdf
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)Functionalization of terminal olefins.pdf
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)Course Overviewweek1.pdf
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)Ligand Exchange Mechanisms.pdf
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)C-C Bond Formation.pdf
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)Sonogashira:in situ, metal assisted deprotonation.pdf
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)Wilkinson's original.pdf
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)Substrate-directed hydrogenations with.pdf
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)Monohydride catalysts.pdf
- 哈佛大学:《有机过渡金属化学》英文教学资源(讲义)The Holy Grail of Catalysis.pdf
- 《建筑施工图的绘制》第五讲 建筑图纸的表达.ppt