最好的算法用于在向图检测周期最好的、算法、周期

2023-09-10 22:22:29 作者:專業賣萌20年

什么是最有效的算法有向图中检测所有周期?

What is the most efficient algorithm for detecting all cycles within a directed graph?

我有向图重新presenting的需要作业调度要执行,作业作为一个节点和一个依赖作为一个边缘。我需要检测该图形,导致循环依赖于一个周期的错误情况。

I have a directed graph representing a schedule of jobs that need to be executed, a job being a node and a dependency being an edge. I need to detect the error case of a cycle within this graph leading to cyclic dependencies.

推荐答案

的Tarjan的强烈连接组件算法具有 O(| E | + | V |)。时间复杂度

有关其他算法,见强连通分量的维基百科。

For other algorithms, see Strongly connected components on Wikipedia.