我查看了 V 和 E 的源代码,但我不确定它们是如何工作的。这是V的代码:
> V
function (graph)
{
if (!is.igraph(graph)) {
stop("Not a graph object")
}
vc <- vcount(graph)
if (vc == 0) {
res <- numeric()
}
else {
res <- 0:(vc - 1)
}
class(res) <- "igraph.vs"
ne <- new.env()
assign("graph", graph, envir = ne)
attr(res, "env") <- ne
res
}
我不确定调用 assign 和 attr 的目的是什么。分配图表是否会创建图表的新副本?这是多么有效/低效?也就是说,这会生成多少个图形副本,例如:
V(g)$someattr <- somevector
谢谢您的帮助。