Reputation: 1546
Is it possible to store a set of graphs (from igraph
) in vector or other data structure?
I'm trying to do it in this way:
require('igraph')
g1 <- make_tree(10,3)
g2 <- make_tree(30,3)
gs <- c(g1,g2)
as.igraph(gs[1])
but it doesn't work. I got error:
Error in UseMethod("as.igraph") :
no applicable method for 'as.igraph' applied to an object of class "list"
Upvotes: 4
Views: 907
Reputation: 21425
You can store them in a list:
gs <- list(g1,g2)
class(gs[[1]])
# [1] "igraph"
The gs[[i]]
are igraphs and you don't need to run as.igraph
on them.
Also, according to the docs, the as.igraph
function can only be used on codeigraphHRG
objects.
Upvotes: 2