topSort                 package:ggm                 R Documentation

_T_o_p_o_l_o_g_i_c_a_l _s_o_r_t

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

     'topOrder' returns the topological order of a directed acyclic
     graph (parents, before children). 'topSort' permutates the
     adjacency matrix according to the topological order.

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

     topSort(amat)
     topOrder(amat)

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

    amat: a square Boolean matrix with dimnames, representing the
          adjacency matrix of a directed acyclic graph.

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

     The topological order needs not to be unique. After the
     permutation the adjacency matrix of the graph is upper triangular.
     The function is a translation of the Matlab function
     'topological_sort' in Toolbox 'BNT' written by Kevin P. Murphy.

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

     'topSort(amat)' returns a vector of integers representing the
     permutation of the nodes. 'topSort(amat)' returns the adjacency
     matrix with rows and columns permutated.

_N_o_t_e:

     The order of the nodes defined by 'DAG' is that of their first
     appearance in the model formulae (from left to right).

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

     Kevin P. Murphy, Giovanni M. Marchetti

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

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

     Lauritzen, S. (1996). _Graphical models_. Oxford: Clarendon Press.

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

     'DAG', 'isAcyclic'

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

     ## A simple example
     dag <- DAG(a ~ b, c ~ a + b, d ~ c + b)
     dag
     topOrder(dag)
     topSort(dag)

