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"), ...)
http
or ftp
connection. It can also be a character
string with the file name or URI.edgelist
, pajek
, graphml
, gml
,
ncol
, lgl
, dimacs
and graphdb
are supported, the defaul igraph
implements only a subset of the Pajek format:
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:
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 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-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.
node
andedge
attributes 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.Version
and the
firstgraph
attribute are completely ignored.node
andedge
are completely ignored.inf
(infinity) andnan
(not a number) as a real number. This is case insensitive, sonan
,NaN
andNAN
are equal.There are not additional argument for this format.
read.graph
function may have additional arguments depending
on the file format (the format
argument). See the details
separately for each file format, below.write.graph