什么是最短通路问题: 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
单源最短路问题具有最佳子结构性
问题5: 在本章中介绍的算法基本思路 是一样的,那是什么? Bellman-Ford算法、DAG算法、Dijkstra算法 松弛+有序的松弛
Bellman-Ford算法、DAG算法、Dijkstra算法 松弛+有序的松弛
Lemma 24.10(Triangle inequality) Let G =(V,E)be a weighted,directed graph with weight function w:E-R and source vertex s.Then,for all edges (u,v)EE,we have 8(s,v)≤6(s,W+w(u,v) 这是最短的路 这是某条路径 的权重 的权重而已
这是最短的路 的权重 这是某条路径 的权重而已
RELAX(u,v,w) 1 if v.d u.d+w(u,v) 2 v.d u.d+w(u,v) 3 V.π=u u.d 当我们有u.d这么一个预估值后,v.d这个预估值必须小于u.d+wu,v)(三角不等式), 如果relaxl时不小于(一定有错,焦虑中!),修正v.d为u.d+w(u,) 修正后的V.d未必就是最终的解,但一定满足当时的三角不等式
s u v 当我们有u.d这么一个预估值后,v.d这个预估值必须小于u.d+w(u,v)(三角不等式), 如果relax时不小于(一定有错,焦虑中!),修正v.d为u.d+w(u,v) 修正后的v.d未必就是最终的解,但一定满足当时的三角不等式 u.d v.d