read_graph: Reading foreign file formats

View source: R/foreign.R

read_graphR Documentation

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. Various 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, ncol, lgl, graphml, dimacs, graphdb, gml and dl are supported, the default is edgelist. As of igraph 0.4 this argument is case insensitive.

...

Additional arguments, see below.

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.

Value

A graph object.

Edge list format

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:

n

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).

directed

Logical scalar, whether to create a directed graph. The default value is TRUE.

Pajek format

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.

Author(s)

Gabor Csardi csardi.gabor@gmail.com

See Also

write_graph()

Foreign format readers graph_from_graphdb(), write_graph()


igraph documentation built on Oct. 20, 2024, 1:06 a.m.