igraph (version 0.7.0)

read.graph: Reading foreign file formats

Description

The read.graph function is able to read graphs in various representations from a file, or from a http connection. Currently some simple formats are supported.

Usage

read.graph(file, format = c("edgelist", "pajek", "ncol", "lgl",
        "graphml", "dimacs", "graphdb", "gml", "dl"), ...)

Arguments

file
The connection to read from. This can be a local file, or a http or ftp connection. It can also be a character string with the file name or URI.
format
Character constant giving the file format. Right now edgelist, pajek, graphml, gml, ncol, lgl, dimacs and graphdb are supported, the defaul
...
Additional arguments, see below.

Value

  • A graph object.

Pajek format

Pajek it a popular network analysis program for Windows. (See the Pajek homepage at http://vlado.fmf.uni-lj.si/pub/networks/pajek/.) It has a quite flexible but not very well documented file format, see the Pajek manual on the Pajek homepage for some information about the file format.

igraph implements only a subset of the Pajek format:

  • Only .net files are supported, Pajek project files (which can contain many graph and also other type of data) are not. Poject files might be supported in a forthcoming igraph release if they turned out to be needed.
  • Time events networks are not supported.
  • Hypergraphs (graphs with non-binary edges) are not supported as igraph cannot handle them.
  • Graphs containing both directed and undirected edges are not supported as igraph cannot represent them.
  • Graph with multiple edge sets are not supported.

From version 0.6.1 igraph supports reading bipartite (two-mode) graphs from Pajek files and adds the type vertex attribute. A warning is given if invalid edges (edges connecting vertices of the same type) are present in the file. Vertex and edge attributes defined in the Pajek file will be also read and assigned to the graph object to be created. These are mainly parameters for graph visualization, but not exclusively, eg. the file might contain edge weights as well.

The following vertex attributes might be added: ll{ igraph name description, Pajek attribute id Vertex id x, y, z The x, y and z coordinate of the vertex vertexsize The size of the vertex when plotted (size in Pajek). shape The shape of the vertex when plotted. color Vertex color (ic in Pajek) if given with symbolic name framecolor Border color (bc in Pajek) if given with symbolic name labelcolor Label color (lc in Pajek) if given with symbolic name xfact, yfact The x_fact and y_fact Pajek attributes. labeldist The distance of the label from the vertex. (lr in Pajek.) labeldegree, labeldegree2 The la and lphi Pajek attributes framewidth The width of the border (bw in Pajek). fontsize Size of the label font (fos in Pajek.) rotation The rotation of the vertex (phi in Pajek). radius Radius, for some vertex shapes (r in Pajek). diamondratio For the diamond shape (q in Pajek). type vertex types in bipartite (two-mode) graphs. }

These igraph attributes are only created if there is at least one vertex in the Pajek file which has the corresponding associated information. Eg. if there are vertex coordinates for at least one vertex then the x, y and possibly also z vertex attributes will be created. For those vertices for which the attribute is not defined, NaN is assigned. The following edge attributes might be added: ll{ igraph name description, Pajek attribute weight Edge weights. label l in Pajek. color Edge color, if the color is given with a symbolic name, c in Pajek. color-red, color-green, color-blue Edge color if it was given in RGB notation, c in Pajek. edgewidth w in Pajek. arrowsize s in Pajek. hook1, hook2 h1 and h2 in Pajek. angle1, angle2 a1 and a2 in Pajek, Bezier curve parameters. velocity1, velocity2 k1 and k2 in Pajek, Bezier curve parameter. arrowpos ap in Pajek. labelpos lp in Pajek. labelangle, labelangle2 lr and lphi in Pajek. labeldegree la in Pajek. fontsize fos in Pajek. arrowtype a in Pajek. linepattern p in Pajek. labelcolor lc in Pajek. } There are no additional arguments for this format.

GML file format

GML is a simple textual format, see http://www.fim.uni-passau.de/en/fim/faculty/chairs/theoretische-informatik/projects.html for details. Although all syntactically correct GML can be parsed, we implement only a subset of this format, some attributes might be ignored. Here is a list of all the differences:
  • Onlynodeandedgeattributes are used, and only if they have a simple type: integer, real or string. So if an attribute is an array or a record, then it is ignored. This is also true if only some values of the attribute are complex.
  • Top level attributes except forVersionand the firstgraphattribute are completely ignored.
  • Graph attributes except fornodeandedgeare completely ignored.
  • There is no maximum line length.
  • There is no maximum keyword length.
  • Character entities in strings are not interpreted.
  • We allowinf(infinity) andnan(not a number) as a real number. This is case insensitive, sonan,NaNandNANare equal.
Please contact us if you cannot live with these limitations of the GML parser.

There are not additional argument for this format.

Details

The read.graph function may have additional arguments depending on the file format (the format argument). See the details separately for each file format, below.

See Also

write.graph