The Last Word
The Last Word

Reputation: 203

Calculate transitivity for all networks in a list

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.

Upvotes: 0

Views: 106

Answers (1)

emilliman5
emilliman5

Reputation: 5966

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")

Upvotes: 1

Related Questions