Matrics to Graph coersions       package:graph       R Documentation

_C_o_e_r_c_i_n_g _m_a_t_r_i_c_e_s _t_o _g_r_a_p_h_s

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

     A collection of functions and methods to convert various forms of
     matrices into graph objects.

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

     aM2bpG(aM)
     ftM2adjM(ft, W=NULL, V=NULL, edgemode="directed")

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

      ft: A matrix with two columns containing the from/to
          representation of graph edges.

       W: An optional vector of edge weights.

       V: An optional vector of node names.

      aM: An affiliation matrix for a bipartite graph.

edgemode: Specifies if the resulting graph is to be directed or
          undirected

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

     In the fuction 'ftM2adjM', a 'from/to' matrix is converted into an
     'adjacency' matrix (which can then be coerced directly into a
     'graphNEL-class' with 'as'.  Ths first column of the 'ft'
     represents the 'from' nodes and the second column represents 'to'
     nodes.  This representation does not allow for unconnected nodes
     except with the 'V' argument (see below).  The 'edgemode'
     parameter can be used to specify if the desired output is a
     directed or undirected graph. 

     Also in 'ftM2adjM', 'W' is an optional vector of edge weights. The
     order of the edge weights in the vector should correspond to the
     order of the edges recorded in 'L'.  If it is not specified, edge
     weights of 1 are assigned by default.  The 'V' argument is an
     optional vector of node names.  All nodes in 'ft' must be
     contained in 'V', but not all nodes in 'V' must be contained in
     'ft'.  If 'V' is not specified, it is set to all nodes represented
     in 'ft' or 'M'.  Specifying 'V' is most useful for creating a
     graph that includes nodes with degree 0. 

     'aM' is an affiliation matrix as frequently used in social
     networks analysis.  The rows of 'aM' represent actors, and the
     columns represent events.  An entry of "1" in the ith row and jth
     column represents affiliation of the ith actor with the jth event.
      Weighted entries may also be used.  'aM2bpG' returns a 'graphNEL'
     object with nodes consisting of the set of actors and events, and
     directed (possibly weighted) edges from the actors to their
     corresponding events.  If plotted using 'Rgraphviz' and the 'dot'
     layout, the bipartite structure of the graph returned by 'aM2bpG'
     should be evident. 

     An 'adjacency' matrix can be directly coerced into a 'graphNEL'
     using the 'as' method.  If the matrix is a symmetric matrix, then
     the resulting graph will be 'undirected', otherwise it will be
     'directed'.

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

     For 'aM2bpG', an object of class 'graphNEL'.  For 'ftM2adjM', an
     adjacency matrix representation of the coerced graph.

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

     Denise Scholtens

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

     From <- c("A","A","C","C")
     To <- c("B","C","A","D")
     L <- cbind(From,To)

     W <- 1:4
     M1 <- ftM2adjM(L,W, edgemode="undirected")
     M2 <- ftM2adjM(L)

     G1 <- as(M1, "graphNEL")
     G2 <- as(M2, "graphNEL")

