graph2SparseM             package:graph             R Documentation

_C_o_e_r_c_i_o_n _m_e_t_h_o_d_s _b_e_t_w_e_e_n _g_r_a_p_h_s _a_n_d _s_p_a_r_s_e _m_a_t_r_i_c_e_s

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

     These functions provide coercions between objects that inherit
     from the 'graph' class to sparse matrices from the 'SparseM'
     package.

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

     graph2SparseM(g, useweights=FALSE)
     sparseM2Graph(sM, nodeNames) 

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

       g: An instance of the 'graph' class. 

useweights: A logical value indicating whether to use the edge weights
          in the graph as values in the sparse matrix.

      sM: A sparse matrix.

nodeNames: A 'character' vector of the node names.

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

     A very simple coercion from one representation to another.

     Currently it is presumed that the matrix is square. For other
     graph formats, such as bipartite graphs, some improvements will be
     needed; patches are welcome.

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

     'graph2SparseM' takes as input an instance of the 'graph' class
     and returns a sparse matrix while 'sparseM2Graph' takes a sparse
     matrix as input and returns an in instance of the graph class.

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

     R. Gentleman

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

     'graph-class' And for other conversions, 'aM2bpG' and 'ftM2adjM'

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

       set.seed(123)
       g1 <- randomGraph(letters[1:10], 1:4, p=.3)
       s1 <- graph2SparseM(g1)

       sparseM2Graph(s1, letters[1:10])

