知识卡片
DAG最长路可反号转最短路
DAG 里的最长路径可把每条边权取负,再运行拓扑序最短路;原图最大权路径对应新图最小权路径。
由于 DAG 无环,反号不会引入负环。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 第22章 单源最短路径 · 查看原书依据
You can find a critical path by either negating the edge weights and running DAG-SHORTEST-PATHS, or running DAG-SHORTEST-PATHS, but replacing “∞” by “−∞” in line 2 of INITIALIZE-SINGLE-SOURCE and “>” by “<” in the RELAX procedure.
参考来源
- 位置:《算法导论(第4版)》第22章《单源最短路径》(OEBPS/chapter022.xhtml,文本字符[25000,35000))。
- 结论依据:第22.2节关键路径段给出取反边权后运行DAG-SHORTEST-PATHS,或把∞和比较方向反转的等价做法;DAG前提来自同段。
- 原始内容:You can find a critical path by either negating the edge weights and running D AG -S HORTEST -P ATHS , or running D AG -S HORTEST -P ATHS , but replacing “∞” by “−∞” in line 2 of I NITIALIZE -S INGLE -S OURCE and “>” by “<” in the R ELAX procedure.