combineNodes              package:graph              R Documentation

_c_o_m_b_i_n_e_N_o_d_e_s

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

     A function to combine, or collapse, a specified set of nodes in a
     graph.

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

     combineNodes(nodes, graph, newName)

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

   nodes: A set of nodes that are to be collapsed. 

   graph: The graph containing the nodes 

 newName: The name for the new, collapsed node. 

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

     The nodes specified are reduced to a single new node with label
     given by 'newName'. The in and out edges of the set of nodes are
     all made into in and out edges for the new node.

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

     An new instance of a graph of the same class as 'graph' is
     returned. This new graph has the specified nodes reduced to a
     single node.

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

     R. Gentleman

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

     'inEdges', 'addNode'

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

       V <- LETTERS[1:4]
       edL1 <- vector("list", length=4)
       names(edL1) <- V
       for(i in 1:4)
         edL1[[i]] <- list(edges=c(2,1,4,3)[i], weights=sqrt(i))
       gR <- new("graphNEL", nodes=V, edgeL=edL1)
       gR <- addNode("M", gR)
       gR <- addEdge("M", "A", gR, 1)
       gR <- addEdge("B", "D", gR, 1)
       gX <- combineNodes(c("B","D"), gR, "X")

