Last chance! 50% off unlimited learning
Sale ends in
cycletest
returns TRUE
or
FALSE
if it is cyclic or not. This is used in autosearch
cycletest(nw)
findleaf (nw)
network
cycletest
returns TRUE
if nw
contains a cycle, FALSE
if not.
findleaf
returns an index of a leaf, or 0 if no leaf is found.cycletest
uses findleaf
to find a node without
parents (called a leaf). Then, this node is deleted from the graph. If
this process can be repeated until all nodes have been deleted, no
cycle is present in the graph.
The procedure findleaf
returns the index of the first found
leaf. If no leaf is found, 0 is returned.networkfamily
,
drawnetwork
,
autosearch
,
perturb
data(rats)
# make Sex numeric so that a cycle is possible
rats$Sex <- as.numeric(rats$Sex)
# define network and prior and learn
nw <- network(rats)
nw.prior <- jointprior(nw,12)
nw <- learn(nw,rats,nw.prior)$nw
# insert a cycle
nw <- insert(nw,1,3,rats,nw.prior)$nw
nw <- insert(nw,3,4,rats,nw.prior)$nw
nw <- insert(nw,4,1,rats,nw.prior)$nw
cycletest(nw)
Run the code above in your browser using DataLab