edgeMatrix               package:graph               R Documentation

_C_o_m_p_u_t_e _a_n _E_d_g_e _M_a_t_r_i_x _o_r _w_e_i_g_h_t _v_e_c_t_o_r _f_o_r _a _G_r_a_p_h

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

     For our purposes an _edge matrix_ is a matrix with two rows and as
     many columns as there are edges. The entries in the first row are
     the index of the node the edge is _from_, those in the second row
     indicate the node the edge is _to_.

     If the graph is undirected then the 'duplicates' option can be
     used to indicate whether reciprocal edges are wanted. The default
     is to leave them out. In this case the notions of _from_ and _to_
     are not relevant.

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

     edgeMatrix(object, duplicates=FALSE)
     eWV(g, eM, sep = ifelse(edgemode(g) == "directed", "->",
                      "--"), useNNames=FALSE)
     pathWeights(g, p, eM=NULL)

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

  object: An object that inherits from 'graph'. 

       g: An object that inherits from 'graph'. 

duplicates: Whether or not duplicate edges should be produced for
          undirected graphs. 

      eM: An edge matrix

     sep: a character string to concatenate node labels in the edge
          label

useNNames: a logical; if TRUE, node names are used in the edge label;
          if FALSE, node indices are used

       p: a vector of node names constituting a path in graph 'g'

     ...: arguments passed to 'edgeMatrix'.

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

     Implementations for 'graphNEL', 'clusterGraph' and 'distGraph' are
     available.

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

     'edgeMatrix' returns a matrix with two rows, _from_ and _to_, and
     as many columns as there are edges. Entries indicate the index in
     the node vector that corresponds to the appropriate end of the
     edge.

     'eWV' uses the edge matrix to create an annotated vector of  edge
     weights.

     'pathWeights' returns an annotated vector of edge weights for a
     specified path in a graph.

_N_o_t_e:

     A path through an undirected graph may have several
     representations as a named vector of edges.  Thus in the example,
     when the weights for path b-a-i are requested, the result is the
     pair of weights for edges a-b and a-i, as these are the edge
     labels computed for graph g1.

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

     R. Gentleman

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

     'edges'

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

       set.seed(123)
       g1 <- randomGraph(letters[1:10], 1:4, p=.3)
       edgeMatrix(g1)
       g2 <- new("clusterGraph", clusters=list(a=c(1,2,3), b=c(4,5,6)))
       em2 <- edgeMatrix(g2)
       eWV(g1, edgeMatrix(g1))
       eWV(g1, edgeMatrix(g1), useNNames=TRUE)
       pathWeights(g1, c("b", "a", "i"))

