conversion              package:igraph              R Documentation

_C_o_n_v_e_r_t _a _g_r_a_p_h _t_o _a_n _a_d_j_a_c_e_n_c_y _m_a_t_r_i_x _o_r _a_n _e_d_g_e _l_i_s_t

_D_e_s_c_r_i_p_t_i_o_n:

     Sometimes it is useful to have a standard representation of a
     graph, like an adjacency matrix or an edge list.

_U_s_a_g_e:

     get.adjacency(graph, type=c("both", "upper", "lower"),
            attr=NULL, names=TRUE, binary=FALSE, sparse=FALSE)
     get.edgelist(graph, names=TRUE)

_A_r_g_u_m_e_n_t_s:

   graph: The graph to convert.

    type: Gives how to create the adjacency matrix for undirected
          graphs. It is ignored for directed graphs. Possible values:
          'upper': the upper right triangle of the matrix is used,
          'lower': the lower left triangle of the matrix is used.
          'both': the whole matrix is used, a symmetric matrix is
          returned.

    attr: Either 'NULL' or a character string giving an edge attribute
          name. If 'NULL' a traditional adjacency matrix is returned.
          If not 'NULL' then the values of the given edge attribute are
          included in the adjacency matrix. If the graph has multiple
          edges, the edge attribute of an arbitrarily chosen edge (for
          the multiple edges) is included.

   names: Logical constant.

          For 'graph.adjacenct' it gives whether to assign row and
          column names to the matrix. These are only assigned if the
          'name' vertex attribute is present in the graph.

          for 'get.edgelist' it gives whether to return a character
          matrix containing vertex names (ie. the 'name' vertex
          attribute) if they exist or numeric vertex ids. 

  binary: Logical, whether to return a binary matrix. This argument is
          ignored if 'attr' is not 'NULL'.

  sparse: Logical scalar, whether to create a sparse matrix. The
          ''Matrix'' package must be installed for creating sparse
          matrices.

_D_e_t_a_i_l_s:

     'get.adjacency' returns the adjacency matrix of a graph, a regular
     R matrix if 'sparse' is 'FALSE', or a sparse matrix, as defined in
     the ''Matrix'' package, if 'sparse' if 'TRUE'.

     'get.edgelist' returns the list of edges in a graph.

_V_a_l_u_e:

     A 'vcount(graph)' by 'vcount(graph)' (usually) numeric matrix for
     'get.adjacency'. (This can be huge!) Note that a non-numeric
     matrix might be returned if 'attr' is a non-numeric edge
     attribute.

     A 'ecount(graph)' by 2 numeric matrix for 'get.edgelist'.

_A_u_t_h_o_r(_s):

     Gabor Csardi csardi@rmki.kfki.hu

_S_e_e _A_l_s_o:

     'graph.adjacency', 'read.graph'

_E_x_a_m_p_l_e_s:

     g <- erdos.renyi.game(10, 2/10)
     get.edgelist(g)
     get.adjacency(g)
     V(g)$name <- letters[1:vcount(g)]
     get.adjacency(g)
     E(g)$weight <- runif(ecount(g))
     get.adjacency(g, attr="weight")

