最好的算法用于在向图检测周期 [英] Best algorithm for detecting cycles in a directed graph

查看:123
本文介绍了最好的算法用于在向图检测周期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这篇关于最好的算法用于在向图检测周期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆