知识卡片
Kruskal用并查集避环
Kruskal 按边权升序扫描。
- 若两端点属于不同并查集,就收下该边并合并集合;
- 若已属于同一集合,加入会成环,直接跳过。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 第21章 最小生成树 · 查看原书依据
The for loop in lines 6–9 examines edges in order of weight, from lowest to highest. The loop checks, for each edge (u, v), whether the endpoints u and v belong to the same tree. If they do, then the edge (u, v) cannot be
参考来源
- 位置:《算法导论(第4版)》第21章《最小生成树》(OEBPS/chapter021.xhtml,文本字符[15000,20000))。
- 结论依据:原文伪代码先排序,再用 FIND-SET 判端点是否在同一树,收边后 UNION。
- 原始内容:The for loop in lines 6–9 examines edges in order of weight, from lowest to highest. The loop checks, for each edge ( u , v ), whether the endpoints u and v belong to the same tree. If they do, then the edge ( u , v ) cannot be