Checks if matrix is a directed acyclic graph
Usage
is_dag(W, threshold = 1e-05)
Arguments
- W
A matrix that represents a directed graph
- threshold
A threshold to determine if a value is zero
Value
A boolean indicating if the matrix is a directed acyclic graph
Examples
d <- 100
B <- matrix(0, d, d)
idx <- sample(1:d)
B[lower.tri(B)] <- runif(d*(d - 1) / 2, min = 1, max = 100)
is_dag(B[idx, idx]) # DAG
#> [1] TRUE
B[1,10] <- 1
is_dag(B[idx, idx]) # Not a DAG
#> [1] FALSE