Reading foreign file formats
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.
read.graph(file, format = c("edgelist", "pajek", "ncol", "lgl", "graphml", "dimacs", "graphdb", "gml", "dl"), ...)
- The connection to read from. This can be a local file, or
ftpconnection. It can also be a character string with the file name or URI.
- Character constant giving the file format. Right now
graphdbare supported, the defaul
- Additional arguments, see below.
read.graph function may have additional arguments depending
on the file format (the
format argument). See the details
separately for each file format, below.
- A graph object.
Pajek it a popular network analysis program for Windows. (See the
Pajek homepage at
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
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:
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
y_fact Pajek attributes.
labeldist The distance of the label from the vertex. (
lr in Pajek.)
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
NaN is assigned.
The following edge attributes might be added:
l in Pajek.
color Edge color, if the color is given with a symbolic name,
c in Pajek.
color-blue Edge color if it was given in RGB notation,
c in Pajek.
w in Pajek.
s in Pajek.
h2 in Pajek.
a2 in Pajek, Bezier curve parameters.
k2 in Pajek, Bezier curve parameter.
ap in Pajek.
lp in Pajek.
lphi in Pajek.
la in Pajek.
fos in Pajek.
a in Pajek.
p in Pajek.
lc in Pajek.
There are no additional arguments for this format.
GML file format
GML is a simple textual format, see
edgeattributes 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 for
Versionand the first
graphattribute are completely ignored.
- Graph attributes except for
edgeare completely ignored.
- There is no maximum line length.
- There is no maximum keyword length.
- Character entities in strings are not interpreted.
- We allow
nan(not a number) as a real number. This is case insensitive, so
There are not additional argument for this format.