知识卡片
邻接顺序可改变BFS树
同层存在多条最短路径时,邻接表的遍历顺序会改变哪个顶点先发现目标,从而改变树父节点;但 BFS 算出的距离不受该顺序影响。
复现实验若要比较树形,应固定邻接顺序。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 第20章 基本图算法 · 查看原书依据
The results of breadth-first search may depend upon the order in which the neighbors of a given vertex are visited in line 12: the breadth-first tree may vary, but the distances d computed by the algorithm do not. (See Exercise 20.2-5.)
参考来源
- 位置:《算法导论(第4版)》第20章《基本图算法》(OEBPS/chapter020.xhtml,文本字符[15000,20000))。
- 结论依据:原文明确区分树形可变与距离不变。
- 原始内容:The results of breadth-first search may depend upon the order in which the neighbors of a given vertex are visited in line 12: the breadth-first tree may vary, but the distances d computed by the algorithm do not. (See Exercise 20.2-5.)