| simple_cycles | R Documentation |
This function lists all simple cycles in a graph within a range of cycle lengths. A cycle is called simple if it has no repeated vertices.
Multi-edges and self-loops are taken into account. Note that typical graphs have exponentially many cycles and the presence of multi-edges exacerbates this combinatorial explosion.
simple_cycles(
graph,
mode = c("out", "in", "all", "total"),
min = NULL,
max = NULL,
...,
callback = NULL
)
graph |
The input graph. |
mode |
Character constant specifying how to handle directed graphs.
|
min |
Lower limit on cycle lengths to consider. |
max |
Upper limit on cycle lengths to consider. |
... |
These dots are for future extensions and must be empty. |
callback |
Optional function to call for each cycle found. If provided,
the function should accept two arguments: Important limitation: Callback functions must NOT call any igraph
functions (including simple queries like |
If callback is NULL, returns a list with two elements: vertices
(list of integer vectors with vertex IDs) and edges (list of integer vectors
with edge IDs). If callback is provided, returns NULL invisibly.
If callback is NULL, returns a list with two elements: vertices
(list of integer vectors with vertex IDs) and edges (list of integer vectors
with edge IDs). If callback is provided, returns NULL invisibly.
simple_cycles(), vcount(), edges(), get_eids(), ecount()
Graph cycles
feedback_arc_set(),
feedback_vertex_set(),
find_cycle(),
girth(),
has_eulerian_path(),
is_acyclic(),
is_dag()
g <- graph_from_literal(A -+ B -+ C -+ A -+ D -+ E +- F -+ A, E -+ E, A -+ F, simplify = FALSE)
simple_cycles(g)
simple_cycles(g, mode = "all") # ignore edge directions
simple_cycles(g, mode = "all", min = 2, max = 3) # limit cycle lengths
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.