知识卡片
最短路前驱指针可重建路径
算法为每个顶点记录前驱π;结束且正确时,从目标沿前驱回溯到源点,可按反向顺序输出最短路。
运行中π还可能变化,不能把中间前驱子图当最终结果。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 第22章 单源最短路径 · 查看原书依据
Thus, given a vertex v for which v.π ≠ NIL, the procedure PRINT-PATH(G, s, v) from Section 20.2 prints a shortest path from s to v. In the midst of executing a shortest-paths algorithm, however, the π values might not indicate shortest paths.
参考来源
- 位置:《算法导论(第4版)》第22章《单源最短路径》(OEBPS/chapter022.xhtml,文本字符[10000,15000))。
- 结论依据:第22.1节明确前驱链在算法完成时可用PRINT-PATH输出最短路,运行中π值仍可能变化而非最短路。
- 原始内容:Thus, given a vertex v for which v .π ≠ NIL , the procedure P RINT -P ATH ( G , s , v ) from Section 20.2 prints a shortest path from s to v . In the midst of executing a shortest-paths algorithm, however, the π values might not indicate shortest paths.