将有向循环图转换为无环图
What to Learn?
学什么?
How to detect a cycle in a Directed graph?
如何在有向图中检测周期 ?
In the following graph,
在下图中,
![Cycle Detection in a Directed Graph](https://www.includehelp.com/data-structure-tutorial/images/cycle-detection-in-a-directed-graph-1.jpg)
It has a cycle 0-1-2-3-0
它具有一个周期0-1-2-3-0
(1-2-3-4-1 is not cycle since edge direction is 1->4, not 4->1)
( 1-2-3-4-1不是循环的,因为边缘方向是1-> 4 ,而不是4-> 1 )
Algorithm:
算法:
Here we use a recursive method to detect a cycle in a graph.
在这里,我们使用