Here is a Spark Graphframes df repsenting a directed graph, there may be some cycles in this graph. How can I detect the cycles in a Graphframe?
For example, here is a graph
| src | dst |
| --- | --- |
| 1 | 2 |
| 2 | 3 |
| 3 | 4 |
| 3 | 1 |
| 4 | 1 |
the cycle in this graph should be {1,2,3} and {1,2,3,4}.



You could use BFS algorithm to find cycles in your graph