write_graph()
is a general function for exporting graphs to foreign
file formats. The recommended formats for data exchange are GraphML and GML.
Usage
write_graph(
graph,
file,
format = c("edgelist", "pajek", "ncol", "lgl", "graphml", "dimacs", "gml", "dot",
"leda"),
...
)
Arguments
- 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
,leda
anddimacs
are implemented. As of igraph 0.4 this argument is case insensitive.- ...
Other, format specific arguments, see below.
Edge list format
The edgelist
format is a simple text file,
with one edge per line, the two zero-based numerical vertex IDs separated
by a space character. Note that vertices are indexed starting with zero.
The file is sorted by the first and the second column. This format has no
additional arguments.
NCOL format
This format is a plain text edge list in which vertices are referred to by name rather than numerical ID. Edge weights may be optionally written. Additional parameters:
- names
The name of a vertex attribute to take vertex names from or
NULL
to use zero-based numerical IDs.- weights
The name of an edge attribute to take edge weights from or
NULL
to omit edge weights.
Pajek format
The pajek
format is provided for interoperability
with the Pajek software only. Since the format does not have a formal
specification, it is not recommended for general data exchange or archival.
References
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.
See also
Foreign format readers
graph_from_graphdb()
,
read_graph()
Author
Gabor Csardi csardi.gabor@gmail.com
Related documentation in the C library
igraph_write_graph_dimacs_flow()
, igraph_write_graph_dot()
, igraph_write_graph_edgelist()
, igraph_write_graph_gml()
, igraph_write_graph_graphml()
, igraph_write_graph_leda()
, igraph_write_graph_lgl()
, igraph_write_graph_ncol()
, igraph_write_graph_pajek()
.
Examples
g <- make_ring(10)
file <- tempfile(fileext = ".txt")
write_graph(g, file, "edgelist")
if (!interactive()) {
unlink(file)
}