Warning
The documentation for retworkx has migrated to:
https://qiskit.org/documentation/retworkx
These docs will no longer be updated.
retworkx.digraph_find_cycle¶
- digraph_find_cycle(graph, /, source=None)¶
Return the first cycle encountered during DFS of a given PyDiGraph, empty list is returned if no cycle is found
- Parameters
graph (PyDiGraph) – The graph to find the cycle in
source (int) – Optional index to find a cycle for. If not specified an arbitrary node will be selected from the graph.
- Returns
A list describing the cycle. The index of node ids which forms a cycle (loop) in the input graph
- Return type