igraph (version 0.4.1)

write.graph: Writing the graph to a file in some format

Description

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

Usage

write.graph(graph, file, format="edgelist", ...)

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, gml, edgelist, lgl, ncol and dimacs are implemented. As of igraph 0.4 this argument
...
Other, format specific arguments, see below.

Value

  • A NULL, invisibly.

code

NULL

itemize

  • id

sQuote

  • name
  • name
  • weights

item

  • weights
  • target
  • capacity
  • creator

url

  • ftp://dimacs.rutgers.edu/pub/netflow/general-info/
  • http://www.infosun.fim.uni-passau.de/Graphlet/GML/

dQuote

  • id
  • id
  • source
  • target
  • Creator

Details

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.

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 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:

  • names
{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.} weights{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.} isolates{Logical, if TRUE the isolate vertices are also written to the file, they are omitted by default.}

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

read.graph

Examples

Run this code
g <- graph.ring(10)
write.graph(g, "/tmp/g.txt", "edgelist")

Run the code above in your browser using DataCamp Workspace