Finding all cycles in a directed graph

前端 未结 17 2636
渐次进展
渐次进展 2020-11-22 05:47

How can I find (iterate over) ALL the cycles in a directed graph from/to a given node?

For example, I want something like this:

A->B->A
A->B         


        
17条回答
  •  猫巷女王i
    2020-11-22 06:23

    I found this page in my search and since cycles are not same as strongly connected components, I kept on searching and finally, I found an efficient algorithm which lists all (elementary) cycles of a directed graph. It is from Donald B. Johnson and the paper can be found in the following link:

    http://www.cs.tufts.edu/comp/150GA/homeworks/hw1/Johnson%2075.PDF

    A java implementation can be found in:

    http://normalisiert.de/code/java/elementaryCycles.zip

    A Mathematica demonstration of Johnson's algorithm can be found here, implementation can be downloaded from the right ("Download author code").

    Note: Actually, there are many algorithms for this problem. Some of them are listed in this article:

    http://dx.doi.org/10.1137/0205007

    According to the article, Johnson's algorithm is the fastest one.

提交回复
热议问题