find_loops {LoopDetectR} | R Documentation |
Loop detection in a matrix
Description
Given the Jacobian matrix of an ODE system or the adjacency matrix of a graph, this function determines all loops in the system up to the maximal number supplied.
Usage
find_loops(jacobian, max_num_loops = 1e+05)
Arguments
jacobian |
Square Jacobian matrix of an ODE system or the adjacency
matrix of a graph; captures interactions such that entry |
max_num_loops |
Positive numeric value indicating the maximal number
of loops that are reported. Default: |
Details
The input matrix delivers the directed interactions in the ODE
system; if entry (i,j)
is non-zero it means that variable (or node) i
is
regulated by variable (node) j
. Johnson's algorithm for path detection
as well as Tarjan's algorithm for detecting strongly connected
components are used as implemented in the igraph package (functions:
all_simple_paths
, components
) .
If the maximal number of loops, max_num_loops, is reached, no warning is
issued. It is very probable that not all feedback loops of the system
have been found.
Running the function multiple times with re-ordered jacobian as input
can enable detection of alternative feedback loops while limiting the
runtime and output size of single runs.
If columns of the Jacobian are named,
the identification is given by the attribute node_ids
,
attr(result,"node_ids")
.
Value
A data.frame with three columns: loop
, length
, sign
containing up to max_num_loops
loops of the systems defined
by matrix jacobian
. Each entry in the loop column is a list of
identifiers that correspond to the indices of the variable in the
Jacobian matrix and denote
in which order the variables form the loop.
See Also
find_loops_noscc
, find_loops_vset
Examples
#sample Jacobian matrix of a system with 4 variables
jac_matrix <- rbind(c(-1,0,0,-1),c(1,-1,0,1),c(0,1,-1,0),c(0,0,1,-1))
#find the first 5 feedback loops of the system
loop_list <- find_loops(jac_matrix,5)