kahn算法

Searching…

zhuanlan.zhihu.com

拓扑排序之Kahn算法 - 知乎专栏

Jul 20, 2023 · 从上不难看出,Kahn算法不仅可以帮助我们方便地给出有向图拓扑排序的结果;还可以帮助我们判定一个有向图是否为一个有向无环图。 该算法基本步骤如下所示: 统计每个顶点的入度,统计每个顶点指出的边的终点集合

oi-wiki.org

拓扑排序 - OI Wiki

6 days ago · 求字典序最大/最小的拓扑排序 将Kahn 算法中的队列替换成最大堆/最小堆实现的优先队列即可,此时总的时间复杂度为 (l o g 𝑉) O (E + V log V) .

cloud.tencent.com

Video — click to view

Jan 13, 2026 · 拓扑排序是解决任务依赖关系的关键算法,适用于课程安排、任务调度等场景。 本文详解Kahn算法和DFS实现,通过图解和代码示例讲解拓扑排序原理,并分析5道经典例题。 掌握拓扑排序能有效处理DAG图中的依赖关系,检测循环依赖,是算法学习和面试必备技能。

ezool.net

秒懂 Kahn 算法 - 编程 - ezool.net

Feb 28, 2025 · Kahn 算法是一种高效且直观的拓扑排序方法,通过拆除依赖来解决任务调度、依赖解析和死锁检测等问题。本文用“依赖拆除”的比喻,带你彻底理解它的原理,并提供 Python 伪代码示例。

leetcodethehardway.com

Kahn's Algorithm - LeetCode The Hard Way

Kahn's Algorithm is a simple and elegant algorithm that works by repeatedly finding nodes with no incoming edges and adding them to the sorted order. The algorithm maintains a queue of nodes that have no incoming edge...

www.bilibili.com

Video — click to view

视频中我们以图例演示了Kahn 算法的完整执行流程,并用 Python 代码进行了简要实现和讲解。 最后还分析了算法的时间复杂度 O (V + E)。 无论你是算法学习者,还是工程实践者,都能从中获得清晰的理解和实用的技巧。

www.techiedelight.com

Kahn's Topological Sort Algorithm | Techie Delight

Sep 12, 2025 · In this post, Kahn’s topological sort algorithm is introduced, which provides an efficient way to print the topological order. Kahn’s topological sort algorithm works by finding vertices with no incomin...

doc.vercel.app

1.Kahn算法 | 数据结构与算法之美

1.Kahn算法 Kahn算法实际上用的是贪心算法思想,思路非常简单、好懂。 定义数据结构的时候,如果s需要先于t执行,那就添加一条s指向t的边。 所以,如果某个顶点入度为0, 也就表示,没有任何顶点必须先于这个顶点执行,那么这个顶点就可以执行了。