bfs                   package:RBGL                   R Documentation

_B_r_e_a_d_t_h _a_n_d _D_e_p_t_h-_f_i_r_s_t _s_e_a_r_c_h

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

     These functions return information on graph traversal by breadth
     and depth first search using routines from the BOOST library.

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

     bfs(object, node, checkConn=TRUE)
     dfs(object, node, checkConn=TRUE)

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

  object: instance of class graph from Bioconductor graph class

    node: node name where search starts - note that this is ignored for
          dfs 

checkConn: logical indicating whether connectivity of input graph
          should be checked 

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

     These two functions are interfaces to the BOOST graph library
     functions for breadth first and depth first search. Both methods
     can handle unconnected graphs and unless 'checkConn' is specified
     neither tests connectivity. If 'checkConn' is specified and the
     graph is not connected an error is signalled.

     Note that the parameter sequences for bfs and dfs agree, but that
     at present the 'node' argument to 'dfs' is ignored. Cormen et al
     note (p 542) that `results of depth-first search may depend upon
     the order in which the vertices are examined ... These different
     visitation orders tend not to cause problems in practices, as any
     DFS result can usually be used effectively, with essentially
     equivalent results'.  To fix the starting node of 'dfs', order the
     graph vertex list so that the desired start point is the first
     entry.

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

     For 'bfs' a vector of node indices in order of BFS visit.

     For 'dfs' a list of two vectors of nodes, with elements 'discover'
     (order of DFS discovery), and 'finish' (order of DFS completion).

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

     VJ Carey <stvjc@channing.harvard.edu>

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

     dd <- fromGXL(file(system.file("XML/bfsex.gxl",package="RBGL")))
     bfs(dd, "r", FALSE)
     bfs(dd, "s", TRUE)

     dd2 <- fromGXL(file(system.file("XML/dfsex.gxl",package="RBGL")))
     dfs(dd2, "u", FALSE)

