write.graph
is a general function for exporting
graphs to foreign file formats, however not many formats are
implemented right now.write.graph(graph, file, format=c("edgelist", "pajek", "ncol",
"lgl", "graphml", "dimacs", "gml", "dot"), ...)
pajek
, graphml
, dot
,
gml
, edgelist
, lgl
,
ncol
and dimacs
are implemented. As of igraph NULL
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:
NULL
if you want to use numeric
vertex ids even if there is a NULL
here if you want to omit the weights.}
TRUE
the isolate vertices are
also written to the file, they are omitted by default.}read.graph
g <- graph.ring(10)
write.graph(g, "/tmp/g.txt", "edgelist")
Run the code above in your browser using DataLab