cycletest                package:deal                R Documentation

_T_e_s_t _i_f _n_e_t_w_o_r_k _c_o_n_t_a_i_n_s _a _c_y_c_l_e

_D_e_s_c_r_i_p_t_i_o_n:

     The graph in a Bayesian network must be a directed acyclic graph.
     The procedure `cycletest' returns `TRUE' or `FALSE' if it is
     cyclic or not. This is used in `autosearch'

_U_s_a_g_e:

     cycletest(nw)
     findleaf (nw) 

_A_r_g_u_m_e_n_t_s:

      nw: an object of class `network'

_D_e_t_a_i_l_s:

     First, `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.

_V_a_l_u_e:

     `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.

_A_u_t_h_o_r(_s):

     Susanne Gammelgaard Bttcher alma@math.auc.dk, 
     Claus Dethlefsen dethlef@math.auc.dk.

_R_e_f_e_r_e_n_c_e_s:

     Further information about deal can be found at:
     <URL: http://www.math.auc.dk/novo/deal>.

_S_e_e _A_l_s_o:

     `networkfamily', `drawnetwork', `autosearch', `perturb'

_E_x_a_m_p_l_e_s:

     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)

