| find_cycle {igraph} | R Documentation |
Finds a cycle in a graph, if there is one
Description
This function returns a cycle of the graph, in terms of both its vertices and edges. If the graph is acyclic, it returns empty vertex and edge sequences.
Use is_acyclic() to determine if a graph has cycles, without returning
a specific cycle.
Usage
find_cycle(graph, mode = c("out", "in", "all", "total"))
Arguments
graph |
The input graph. |
mode |
Character constant specifying how to handle directed graphs.
|
Value
A list of integer vectors, each integer vector is a path from the source vertex to one of the target vertices. A path is given by its vertex ids.
Related documentation in the C library
See Also
Graph cycles
feedback_arc_set(),
feedback_vertex_set(),
girth(),
has_eulerian_path(),
is_acyclic(),
is_dag(),
simple_cycles()
Examples
g <- make_lattice(c(3, 3))
find_cycle(g)
# Empty results are returned for acyclic graphs
find_cycle(sample_tree(5))
[Package igraph version 2.2.3 Index]