How do I check if a directed graph is acyclic?

后端 未结 11 1751
野的像风
野的像风 2020-11-30 19:16

How do I check if a directed graph is acyclic? And how is the algorithm called? I would appreciate a reference.

11条回答
  •  独厮守ぢ
    2020-11-30 19:37

    There should not be any back edge while doing DFS.Keep track of already visited nodes while doing DFS,if you encounter a edge between current node and existing node,then graph has cycle.

提交回复
热议问题