Calculate transitivity for all networks in a list

108 views Asked by At

I have 500 random networks stored in a list

for (x in seq_len(500L)) {
+     gs[[x]] <- erdos.renyi.game(361, 695, type = "gnm")

I am able to calculate the transitivity for each network individually using

transitivity(gs[[1]])

How do I calculate the transitivity for all the networks and output the values into an excel sheet so as to do some statistical analysis. Anyt thoughts please.

1

There are 1 answers

0
emilliman5 On BEST ANSWER

Use an *apply function, specifically sapply or lapply.

library(igraph)

gs <- list()
for (x in seq_len(500L)) {
  gs[[x]] <- erdos.renyi.game(361, 695, type = "gnm")
}

gs.trans <- sapply(gs, transitivity)
write.csv(gs.trans, file="Graph_transivity.txt")