南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)单源最短路径算法

计算机问题求解一论题3-8 单源最短通路算法 2018年10月30日
计算机问题求解 – 论题3-8 - 单源最短通路算法 2018年10月30日

什么是最短通路问题: In a shortest-paths problem,we are given a weighted,directed graph G=(V,E),with weight function w:ER mapping edges to real-valued weights.The weight w(p)of path p=(vo.v1...v)is the sum of the weights of its constituent edges: 问题1: k w(p)=w(-1,). 输入是什么?输出是 i=1 什么? We define the shortest-path weight 8(u,v)from u to v by min()ithere isa pathfrom o otherwise A shortest path from vertex u to vertex v is then defined as any path p with weight w(p)=8u,)
什么是最短通路问题?

问题2 单源最短略问题的解必定是一棵树? A shortest-paths tree rooted at s is a directed subgraph G'=(V',E), where V'C V and E'C E,such that 1.V'is the set of vertices reachable from s in G, 2.G'forms a rooted tree with root s,and 3.for all vV,the unique simple path froms to v in G'is a shortest path froms to v in G. 由.T决定的 Vπ={v∈V:w.π≠NTL}U{s}· 最短路径树: E元={v.π,v)∈E:v∈Vπ-{s}
由.π决定的 最短路径树:

单源最短路问题具有最佳子结构性 Lemma 24.1 (Subpaths of shortest paths are shortest paths) Given a weighted,directed graph G=(V.E)with weight function w:E->R, let p =(vo,v1,....vk)be a shortest path from vertex vo to vertex vk and,for any i and j such that0≤i≤j≤k,let Pij=(i,vi+l,,vi)be the subpath of p from vertex vi to vertex vj.Then,Pij is a shortest path from vi to vj. Proof If we decompose path p into vv,then we have that w(p)=w(Poi)+w(Pij)+w(pik).Now,assume that there is a path p;from vi to with weight w(p(.Then,is a path from v to vk whose weight w(poi)+w(p)+w(pjk)is less than w(p),which contradicts the assumption that p is a shortest path from vo to vk
单源最短路问题具有最佳子结构性

S 问题3: 简单的greedy策略不能正确解决最短通路 问题!为什么?
s 2 6 1 7 v 问题3: 简单的greedy策略不能正确解决最短通路 问题! 为什么?

问题4: 具有负值权的回路对于单源 最短通路问题的解有什么影 响?非负值权的回路呢?

问题5: 在本章中介绍的算法基本 思路是一样的,那是什么?

预估”与“修正” INITIALIZE-SINGLE-SOURCE(G,S) 1 for each vertex v G.V 2 3 v.d=·. ).π=NIL RELAX(u,v,w) 4s.d=0 -ifv.d>u.d+w(u,v) 2 '>v.d u.d+w(u.v) 3 V.π=2u 2 ⑤ (6 RLAX(u.V) RELAX(u.v.Wv) ⑦ ⑤ 2 (a) (b)
“预估”与“修正

6 (a) (b (c) BELLMAN-FORD(G,w,s) 6 1 INITIALIZE-SINGLE-SOURCE(G,S) 2 for i 1to |G.V]-1 3 for each edge (u.v)G.E (d) (e) 遍历顺序 RELAX(u,v,w) 5 for each edge (u,v)G.E (t,x),(1,y),(亿,z,(x,t),y,x),y,z,(3,x),(3,S),(s,1,(s,y)6 if v.d>u.d+w(u,v) 7 return FALSE 8 return TRUE
遍历顺序

问题6: Relax中的“修正”到底在 干什么?
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)动态规划.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)B树.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)递归及其数学基础.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)组合与计数.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)算法的效率.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)算法正确性.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)离散概率基础.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)概率分析与随机算法.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)排序与选择.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)堆与堆排序.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)基本数据结构.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)分治法与递归.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)Hashing方法.pptx
- 《计算机问题求解》课程教学资源(参考教材)Computer Algorithms - Introduction to Design and Analysis.pdf
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)有限与无限.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)函数.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)集合及其运算.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)关系及其基本性质.pptx
- 《计算机问题求解》课程教学资源(阅读材料)Computational Thinking:What and Why?.pdf
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)数据与数据结构.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)图中的匹配与覆盖.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)图的基本概念.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)图的计算机表示以及遍历.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)图的连通度.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)多源最短路径算法.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)平面图与图着色.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)搜索树.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)旅行问题.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)最大流算法.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)树.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)用于动态等价关系的数据结构.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)矩阵计算.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)贪心算法.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)线性规划.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)群论初步.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)置换群与拉格朗日定理(OLD).pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)群同态基本定理与正规子群.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)串匹配.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)密码算法.pptx
- 南京大学:《计算机问题求解》课程教学资源(PPT课件讲稿)数论基础.pptx