edgeWeights              package:graph              R Documentation

_R_e_t_r_i_e_v_e _t_h_e _e_d_g_e _w_e_i_g_h_t_s _f_o_r _s_p_e_c_i_f_i_e_d _i_n_d_i_c_e_s.

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

     Obtains the weights for all edges from the nodes specified by
     'index'.

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

     edgeWeights(object, index)

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

  object: A graph, any object that inherits from the 'graph' class.

   index: If supplied a character or numeric vector of node names or
          indices. 

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

     If 'index' is suppled then edge weights from these nodes to all
     adjacent nodes are found and returned. If 'index' is not supplied
     then the edge weights for all nodes are returned.

     The 'edgeData' method is the standard way to access edge attribute
     information for a 'graph' instance.  'edgeWeights' provides a
     convenience wrapper around 'edgeData'.  If an edge attribute with
     name '"weight"' is present, it will be used.

     If the attribute values associated with '"weight"' are not
     vectors, an error will be triggered.  Although any R object can be
     specified as the attribute of an edge, the structure of the return
     list of 'edgeWeights' only works with vector objects.

     If no edge attribute with name '"weight"' has been explicitly
     defined, a default edge weight of 1 will be temporarily assigned;
     a graph with no edge attributes defined will have edge weights of
     1 according to 'edgeWeights'.

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

     A named list of named edge weight vectors. The names on the list
     the names of the nodes specified by 'index', or all nodes if
     'index' was not provided.  The names on the weight vectors are
     node names to identify the edge to which the weight belongs.

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

     R. Gentleman

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

     'nodes', 'edges'

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

       V <- LETTERS[1:4]
       edL2 <- vector("list", length=4)
       names(edL2) <- V
       for(i in 1:4)
         edL2[[i]] <- list(edges=c(2,1,2,1)[i], weights=sqrt(i))
       gR2 <- new("graphNEL", nodes=V, edgeL=edL2, edgemode="directed")
       edgeWeights(gR2, "C")
       edgeWeights(gR2)
       edgeData(gR2, attr="weight")
       edgeData(gR2, from="C", attr="weight")

