How do I check if a directed graph is acyclic?

后端 未结 11 1752
野的像风
野的像风 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

    You can use inversion of finding cycle from my answer here https://stackoverflow.com/a/60196714/1763149

    def is_acyclic(graph):
        return not has_cycle(graph)
    

提交回复
热议问题