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", "leda"), ...)
pajek
, graphml
, dot
,
gml
, edgelist
, lgl
,
ncol
and dimacs
are implemented. As of igraph 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.read.graph
for
details. Appropriate vertex and edge attributes are also written to
the file. This format has no additional arguments.From version 0.6.1 igraph handles bipartite graphs when writing to Pajek files. As Pajek is less flexible for bipartite graphs (the numeric ids of the vertices must be sorted according to vertex type), igraph might need to reorder the vertices when writing a bipartite Pajek file. This effectively means that numeric vertex ids usually change when a bipartite graph is written to a Pajek file, and then read back into igraph.
read.graph
g <- graph.ring(10)
write.graph(g, "/tmp/g.txt", "edgelist")
Run the code above in your browser using DataLab