Learn R Programming

ggm (version 1.0.4)

isAcyclic: Graph queries

Description

Checks if a given graph is acyclic.

Usage

isAcyclic(amat)

Arguments

amat
a square Boolean matrix with dimnames, the adjacency matrix of a graph.

Value

  • a logical value, TRUE if the graph is acyclic and FALSE otherwise.

References

Aho, A.V., Hopcroft, J.E. & Ullman, J.D. (1983). Data structures and algorithms. Reading: Addison-Wesley.

Examples

Run this code
## A cyclic graph
d <- matrix(0,3,3)
rownames(d) <- colnames(d) <- c("x", "y", "z")
d["x","y"] <- d["y", "z"] <- d["z", "x"] <- 1
## Test if the graph is acyclic
isAcyclic(d)

Run the code above in your browser using DataLab