Learn R Programming

dagitty (version 0.3-4)

isAcyclic: Test for Cycles

Description

isAcyclic(x) returns TRUE if the given graph does not contain a directed cycle.

Usage

isAcyclic(x)

findCycle(x)

Arguments

x

the input graph, of any graph type.

Details

findCycle(x) will try to find at least one cycle in x and return it as a list of node names.

These functions will only consider simple directed edges in the given graph.

Examples

Run this code
g1 <- dagitty("dag{X -> Y -> Z}")
stopifnot( isTRUE(isAcyclic( g1 )) )
g2 <- dagitty("dag{X -> Y -> Z -> X}")
stopifnot( isTRUE(!isAcyclic( g2 )) )
g3 <- dagitty("mag{X -- Y -- Z -- X}")
stopifnot( isTRUE(isAcyclic( g3 )) )

Run the code above in your browser using DataLab