This loads a graph from a file. Currently, only GraphML files are supported.
load_graph(file, directed, filetype = "graphml")
file | The filename to load the graph from |
---|---|
directed | Choose to load a directed or undirected graph. Note that this has to correspond to the type of graph described in the file! |
filetype | Choose the filetype of the file. Currently, only GraphML is supported |
The loaded nctx graph
See https://en.wikipedia.org/wiki/GraphML for further information about the file format.
Information associated to nodes are loaded as well and accessible via attribute functions, e.g. get_vertex_attributes
and get_vertex_attribute_names
.
library(RUnit) library(nctx) file_dir <- system.file("extdata", "bcde.directed.graphml", package="nctx") file_undir <- system.file("extdata", "bcde.undirected.graphml", package="nctx") g <- load_graph(file_dir, directed=TRUE) checkEquals(num_vertices(g), 10)#> [1] TRUE#> [1] TRUE#> Error in is_directed(g): Not a graph object#> [1] TRUE#> [1] TRUE#> Error in is_directed(g): Not a graph object#> [1] TRUE#> [1] TRUE#> Error in is_directed(g): Not a graph object#> [1] TRUE#> [1] TRUE#> Error in is_directed(g): Not a graph object#> Error in g$graph$from_file_graphml(file) : #> read_graphviz: Tried to read a directed graph into an undirected graph.#> [1] TRUE#> Error in g$graph$from_file_graphml(file) : #> read_graphviz: Tried to read an undirected graph into a directed graph.#> [1] TRUE#> Error in load_graph(file_undir, directed = FALSE, filetype = "edgelist") : #> fileformats other than graphml currently not supported#> [1] TRUE