write.graph              package:igraph              R Documentation

_W_r_i_t_i_n_g _t_h_e _g_r_a_p_h _t_o _a _f_i_l_e _i_n _s_o_m_e _f_o_r_m_a_t

_D_e_s_c_r_i_p_t_i_o_n:

     'write.graph' is a general function for exporting graphs to
     foreign file formats, however not many formats are implemented
     right now.

_U_s_a_g_e:

     write.graph(graph, file, format=c("edgelist", "pajek", "ncol",
            "lgl", "graphml", "dimacs", "gml", "dot"), ...)

_A_r_g_u_m_e_n_t_s:

   graph: The graph to export.

    file: A connection or a string giving the file name to write the
          graph to.

  format: Character string giving the file format. Right now  'pajek',
          'graphml', 'dot', 'gml', 'edgelist', 'lgl', 'ncol' and
          'dimacs' are implemented. As of igraph 0.4 this argument is
          case insensitive. 

     ...: Other, format specific arguments, see below.

_D_e_t_a_i_l_s:

     The 'edgelist' format is a simple text file, with one edge in a
     line, the two vertex ids separated by a space character. The file
     is sorted by the first and the second column. This format has no
     additional arguments.

     The Pajek format is a text file, see 'read.graph' for details.
     Appropriate vertex and edge attributes are also written to the
     file. This format has no additional arguments.

     The GraphML format is a flexible XML based format. See
     'read.graph' for GraphML details. Vertex and edge attributes are
     also written to the file. This format has no additional arguments.

     The dot format is used by the popular GraphViz program. Vertex and
     edge attributes are written to the file. There are no additional
     arguments for this format.

     The 'lgl' format is also a simple text file, this is the format
     expected by the 'Large Graph Layout' layout generator software.
     See read.graph for details. Additional arguments:

   _n_a_m_e_s If you want to write symbolic vertex names instead of vertex
        ids, supply the name of the vertex attribute containing the
        symbolic names here. By default the 'name' attribute is used if
        there is one. Supply 'NULL' if you want to use numeric  vertex
        ids even if there is a 'name' vertex attribute. 

   _w_e_i_g_h_t_s If you want to write edge weights to the file, supply the
        name of the edge attribute here. By defaults the vertex
        attribute 'weights' are used if they are installed. Supply
        'NULL' here if you want to omit the weights.

   _i_s_o_l_a_t_e_s Logical, if 'TRUE' the isolate vertices are also written to
        the file, they are omitted by default.

     The 'ncol' format is also used by LGL, it is a text file, see
     read.graph for details. Additional arguments:

   _n_a_m_e_s If you want to write symbolic vertex names instead of vertex
        ids, supply the name of the vertex attribute containing the
        symbolic names here. By default the 'name' attribute is used if
        there is one. Supply 'NULL' if you want to use numeric  vertex
        ids even if there is a 'name' vertex attribute. 

   _w_e_i_g_h_t_s If you want to write edge weights to the file, supply the
        name of the edge attribute here. By defaults the vertex
        attribute 'weights' are used if they are installed. Supply
        'NULL' here if you want to omit the weights.

     The 'dimacs' file format, more specifically the  version for
     network flow problems, see the files at <URL:
     ftp://dimacs.rutgers.edu/pub/netflow/general-info/>

     This is a line-oriented text file (ASCII) format. The first
     character of each line defines the type of the line. If the first
     character is 'c' the line is a comment line and it is ignored.
     There is one problem line ('p' in the file, it must appear before
     any node and arc descriptor lines. The problem line has three
     fields separated by spaces: the problem type ('min', 'max' or
     'asn'), the number of vertices and number of edges in the graph.
     Exactly two node identification lines are expected ('n'), one for
     the source, one for the target vertex. These have two fields: the
     id of the vertex and the type of the vertex, either 's' (=source)
     or 't' (=target). Arc lines start with 'a' and have three fields:
     the source vertex, the target vertex and the edge capacity.

     Vertex ids are numbered from 1.

     Additional arguments:

   _s_o_u_r_c_e The id of the source vertex, if 'NULL' (the default) then it
        is taken from the 'source' graph attribute.

   _t_a_r_g_e_t The id of the target vertex, if 'NULL' (the default) then it
        is taken from the 'target' graph attribute.

   _c_a_p_a_c_i_t_y A numeric vector giving the edge capacities. If 'NULL' (the
        default) then it is taken from the 'capacity' edge attribute.

     GML is a quite general textual format, see  <URL:
     http://www.infosun.fim.uni-passau.de/Graphlet/GML/> for details.

     The graph, vertex and edges attributes are written to the file as
     well, if they are numeric of string.

     As igraph is more forgiving about attribute names, it might  be
     neccessary to simplify the them before writing to the GML file.
     This way we'll have a syntactically correct GML file. The
     following  simple procedure is performed on each attribute name:
     first the alphanumeric  characters are extracted, the others are
     ignored. Then if the first character is not a letter then the
     attribute name is prefixed with <quote>igraph</quote>. Note that
     this might result identical names for two attributes, igraph  does
     not check this. 

     The "id" vertex attribute is treated specially.  If the 'id'
     argument is not 'NULL' then it should be a numeric  vector with
     the vertex ids and the "id" vertex attribute is  ignored (if there
     is one). If 'id' is 0 and there is a  numeric 'id' vertex
     attribute that is used instead. If ids are not specified in either
     way then the regular igraph vertex ids are used.

     Note that whichever way vertex ids are specified, their 
     uniqueness is not checked.

     If the graph has edge attributes named "source" or "target"
     they're silently ignored. GML uses these attributes to specify the
     edges, so we cannot write them to the file. Rename them  before
     calling this function if you want to preserve them.

     Additional arguments:

   _i_d 'NULL' or a numeric vector giving the vertex ids. See details
        above.

   _c_r_e_a_t_o_r A character scalar to be added to the "Creator" line in the
        GML file. If this is 'NULL' (the default) then the current date
        and time is added.

_V_a_l_u_e:

     A NULL, invisibly.

_A_u_t_h_o_r(_s):

     Gabor Csardi csardi@rmki.kfki.hu

_R_e_f_e_r_e_n_c_e_s:

     Adai AT, Date SV, Wieland S, Marcotte EM. LGL: creating a map of
     protein function with an algorithm for visualizing very large
     biological networks. _J Mol Biol._ 2004 Jun 25;340(1):179-90.

_S_e_e _A_l_s_o:

     'read.graph'

_E_x_a_m_p_l_e_s:

     g <- graph.ring(10)
     ## Not run: write.graph(g, "/tmp/g.txt", "edgelist")

