read.graph

0th

Percentile

Reading foreign file formats

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.

Keywords
graphs
Usage
read.graph(file, format = "edgelist", ...)
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.
Details

The read.graph function may have additional arguments depending on the file format (the format argument).

  • edgelist
{ This format is a simple text file with numeric vertex ids defining the edges. There is no need to have newline characters between the edges, a simple space will also do. There are no additional arguments for this format. } pajek{ 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.} {Bipartite (also called affiliation) networks are not supported. The surrent igraph version imports the network structure correctly but vertex type information is omitted.} {Graph with multiple edge sets are not supported.} }

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 color-red, color-green, color-blue Vertex color (ic in Pajek) if given in RGB notation framecolor Border color (bc in Pajek) if given with symbolic name framecolor-red, framecolor-green, framecolor-blue Border color (bc in Pajek) if given in RGB notation labelcolor Label color (lc in Pajek) if given with symbolic name labelcolor-red, labelcolor-green, labelcolor-blue Label color (lc in Pajek) if given in RGB notation 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). }

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.

Value

  • A graph object.

item

  • graphml
  • GML
  • ncol
  • lgl
  • dimacs
  • graphdb

itemize

  • directed

url

  • http://graphml.graphdrawing.org
  • http://www.infosun.fim.uni-passau.de/Graphlet/GML/
  • http://bioinformatics.icmb.utexas.edu/lgl
  • http://bioinformatics.icmb.utexas.edu/lgl
  • ftp://dimacs.rutgers.edu/pub/netflow/general-info/
  • http://amalfi.dis.unina.it/graph/
  • http://amalfi.dis.unina.it/graph/db/doc/graphdbat-2.html

code

graph.graphdb

a

  • igraph is happy with these.

    Additional arguments:

    • names
    {Logical constant, whether to add the symbolic names as vertex attributes to the graph. If TRUE the name of the vertex attribute will be name.} weights{Logical constant, whether to add the weights of the edges as edge attribute weight. }

  • igraph it is not an error to have multiple and loop edges. Additional arguments:
    • names
    {Logical constant, whether to add the symbolic names as vertex attributes to the graph. If TRUE the name of the vertex attribute will be name.} weights{Logical constant, whether to add the weights of the edges as edge attribute weight. }

dQuote

The second format is the LGL file format (.lgl file suffix). This is yet another graph file format that tries to be as stingy as possible with space, yet keeping the edge file in a human readable (not binary) format. The format itself is like the following: # vertex1name vertex2name [optionalWeight] vertex3name [optionalWeight] Here, the first vertex of an edge is preceded with a pound sign '#'. Then each vertex that shares an edge with that vertex is listed one per line on subsequent lines.

emph

  • The graphs are stored in a compact binary format, one graph per file. The file is composed of 16 bit words, which are represented using the so-called little-endian convention, i.e. the least significant byte of the word is stored first.
  • Then, for each node, the file contains the list of edges coming out of the node itself. The list is represented by a word encoding its length, followed by a word for each edge, representing the destination node of the edge. Node numeration is 0-based, so the first node of the graph has index 0.

See Also

write.graph

Aliases
  • read.graph
  • LGL
  • Pajek
  • GraphML
  • GML
Documentation reproduced from package igraph, version 0.4.4, License: GPL version 2 or later (June, 1991)

Community examples

Looks like there are no examples yet.