知识卡片
约束图无负环可取最短距为解
把每条差分约束 x_j−x_i≤b_k 变成边 v_i→v_j、权重 b_k,并增设源点 v_0,用 0 权边连向每个变量顶点。若约束图无负环,取 x_i=δ(v_0,v_i),其中 δ 是最短路权。
对约束对应边,最短路三角不等式给出 δ(v_0,v_j)≤δ(v_0,v_i)+b_k,移项恰得 x_j−x_i≤b_k,所以这些距离同时满足全部约束。附加源点保证每个距离有限,而不是把不可达的 ∞ 当作变量值。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 第22章 单源最短路径 · 查看原书依据
Proof We first show that if the constraint graph contains no negative-weight cycles, then equation (22.10) gives a feasible solution. Consider any edge (vi, vj) ∈ E. The triangle inequality implies that δ(v0, vj) ≤ δ(v0, vi) + w(vi, vj), which is equivalent to δ(v0, vj)−δ(v0, vi) ≤ w(vi, vj). Thus, letting xi = δ(v0, vi) and xj = δ(v0, vj) satisfies the difference constraint xj − xi ≤ w(vi, vj) that corresponds to edge (vi, vj).
参考来源
- 位置:《算法导论(第4版)》第22章《单源最短路径》(OEBPS/chapter022.xhtml,文本字符[50000,55000))。
- 结论依据:定理22.9证明段用三角不等式逐边验证差分约束;Art_P650公式图式(22.10)给出整组最短距赋值。
- 原始内容:Proof We first show that if the constraint graph contains no negative-weight cycles, then equation (22.10) gives a feasible solution. Consider any edge ( v i , v j ) ∈ E . The triangle inequality implies that δ( v 0 , v j ) ≤ δ( v 0 , v i ) + w ( v i , v j ), which is equivalent to δ( v 0 , v j )−δ( v 0 , v i ) ≤ w ( v i , v j ). Thus, letting x i = δ( v 0 , v i ) and x j = δ( v 0 , v j ) satisfies the difference constraint x j − x i ≤ w ( v i , v j ) that corresponds to edge ( v i , v j ).
- 公式图核读:`_epub-src/OEBPS/images/Art_P650.jpg` 的式(22.10):x=(δ(v₀,v₁), δ(v₀,v₂), …, δ(v₀,vₙ))。