Import a variety of graphs from different graph formats and create a graph object.
import_graph(graph_file, file_type = NULL, edges_extra_attr_names = NULL,
edges_extra_attr_coltypes = NULL)
a connection to a graph file.
When provided as a path to a file, it will read the
file from disk. Files starting with http://
,
https://
, ftp://
, or ftps://
will be automatically downloaded.
the type of file to be imported.
Options are: gml
(GML), sif
(SIF),
edges
(a .edges file), and mtx
(MatrixMarket format). If not supplied, the type
of graph file will be inferred by its file extension.
for edges
files,
a vector of attribute names beyond the from
and to
data columns can be provided in the
order they appear in the input data file.
for edges
files, this is a string of column types for any
attribute columns provided for
edges_extra_attr_names
. This string
representation is where each character represents
each of the extra columns of data and the mappings
are: c
-> character, i
-> integer,
n
-> number, d
-> double,
l
-> logical, D
-> date, T
->
date time, t
-> time, ?
-> guess,
or _/-
, which skips the column.
a graph object of class dgr_graph
.
# NOT RUN {
# Import a GML graph file
gml_graph <-
import_graph(
system.file(
"extdata/karate.gml",
package = "DiagrammeR"))
# Get a count of the graph's nodes
gml_graph %>%
count_nodes()
# Get a count of the graph's edges
gml_graph %>%
count_edges()
# }
Run the code above in your browser using DataLab