0

Just as it says in the question. My networks have many parallel edges, for example, one has 18 vertices and 693 edges.

LpOTb.dc.rd <- list()
for (x in seq_len(1000L)) {
  LpOTb.dc.rd[[x]] <- erdos.renyi.game(18, 
                                       693,
                                       type = "gnm",
                                       loops = T)
}

I would like to make a random network to compare it to, but I keep getting an error message:

Error in erdos.renyi.game(18, 693, type = "gnm", loops = T) : 
At games.c:703 : Invalid number (too large) of edges, Invalid value

I would prefer not to simplify my networks and account for random edge weights, mostly because there's over 30 of them and I would have to redo all of my metrics for my networks.

  • With 18 vertices it is only possible to have 171 edges (including loops) unless you allow multiple edges between a pair of nodes. I think that the `erdos.renyi.game` code does not permit that. You could get to 342 non-repeated edges by making the graph directed. – G5W Aug 06 '20 at 23:17
  • How do allow multiple edges between a pair of nodes? – user13822027 Aug 06 '20 at 23:20
  • I do not think that the erdos.renyi.game code permits that. – G5W Aug 06 '20 at 23:21
  • Is there a different igraph code that might? – user13822027 Aug 06 '20 at 23:22

1 Answers1

0

You could generate your own random graph with 18 vertices and 693 edges using graph_from_data_frame. To match your code above, I made an undirected graph that permitted loops.

library(igraph)
Start = sample(18, 693, replace=TRUE)
End   = sample(18, 693, replace=TRUE)
df = data.frame(Start, End)

g = graph_from_data_frame(df, directed=FALSE)
vcount(g)
[1] 18
ecount(g)
[1] 693

If you want to generate multiple graphs like this, you can mimic the code in the previous answer mentioned in the comments.

library(igraph)
set.seed(1)
gs <- list()
for (x in seq_len(100L)) {
    Start = sample(18, 693, replace=TRUE)
    End   = sample(18, 693, replace=TRUE)
    df = data.frame(Start, End)
    gs[[x]]= graph_from_data_frame(df, directed=FALSE)
}
G5W
  • 36,531
  • 10
  • 47
  • 80
  • This great, thank you! Is there a way to generate a series of them like in this [link](https://stackoverflow.com/questions/39880873/how-to-generate-a-series-of-random-networks-in-r) question? – user13822027 Aug 06 '20 at 23:54
  • Do you always want 18 vertices and 693 edges? Or a random number of vertices like in the link? – G5W Aug 06 '20 at 23:56
  • I always want 18 vertices and 693 edges – user13822027 Aug 07 '20 at 00:01