read_graph | R Documentation |
The read_graph()
function is able to read graphs in various
representations from a file, or from a http connection. Various formats
are supported.
read_graph(
file,
format = c("edgelist", "pajek", "ncol", "lgl", "graphml", "dimacs", "graphdb", "gml",
"dl"),
...
)
file |
The connection to read from. This can be a local file, or a
|
format |
Character constant giving the file format. Right now
|
... |
Additional arguments, see below. |
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.
A graph object.
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. Vertex IDs contained in the file are assumed to start at zero.
Additional arguments:
The number of vertices in the graph. If it is smaller than or equal to the largest integer in the file, then it is ignored; so it is safe to set it to zero (the default).
Logical scalar, whether to create a directed graph. The
default value is TRUE
.
Currently igraph only supports Pajek network
files, with a .net
extension, but not Pajek project files with
a .paj
extension. Only network data is supported; permutations,
hierarchies, clusters and vectors are not.
Additional arguments:
Names of the vertices in the file.
If character(0)
(the default) is given here
then vertex IDs will be assigned to vertex names in the order of
their appearance in the .ncol file.
If it is not character(0)
and some unknown vertex names are found
in the .ncol file then new vertex ids will be assigned to them.
Logical value, if TRUE
(the default)
the symbolic names of the vertices will be added to the graph
as a vertex attribute called “name”.
Whether to add the weights of the edges to the graph
as an edge attribute called “weight”.
"yes"
adds the weights (even if they are not present in the file,
in this case they are assumed to be zero).
"no"
does not add any edge attribute.
"auto"
(the default) adds the attribute if and only
if there is at least one explicit edge weight in the input file.
Whether to create a directed graph (default: FALSE
).
As this format was originally used only for undirected graphs
there is no information in the file about the directedness of the graph.
igraph_read_graph_dimacs_flow()
, igraph_read_graph_dl()
, igraph_read_graph_edgelist()
, igraph_read_graph_gml()
, igraph_read_graph_graphdb()
, igraph_read_graph_graphml()
, igraph_read_graph_lgl()
, igraph_read_graph_ncol()
, igraph_read_graph_pajek()
.
Gabor Csardi csardi.gabor@gmail.com
write_graph()
Foreign format readers
graph_from_graphdb()
,
write_graph()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.