首页 > 解决方案 > Storing the node degrees of a group of networks in an excel sheet

问题描述

I have a code that creates multiple random graphs in R using the igraph package.

set.seed(1)
gs1 <- list()
for (x in seq_len(500L)) 
{
  gs1[[x]] <- sample_bipartite(62, 243, type = "gnm",m = 630, directed = TRUE)

}

I know how to individually retrieve the node degrees of each graph.

degree(gs1[[1]], v = V(gs1[[1]]), mode = c("all", "out", "in", "total"),
+        loops = TRUE, normalized = FALSE)

As you can see, I have created 500 random networks with those values. I would like to store the node degrees of all 500 of these networks in an excel sheet (hopefully 500 columns in a single sheet). How can I do so? Kindly advice.

标签: rigraph

解决方案


简单地

write.csv(sapply(gs1, degree), file = "degrees.csv")

将完成这项工作。这将是一个 305x500 的表格。

此外,在您的情况下,无需编写loops等,因为您的参数值是默认值。此外,只mode考虑一个/第一个值,所以也许你应该再看看以?degree确定你想要什么样的学位。


推荐阅读