If I understand the function correctly, 25 is the number of nodes, and 15 should be the density of edges. However, the density of my randomized graphs are approximately 0.05.
If I’m not mistaken the function should choose edges approximately close to 15?
Does anyone know how I can force the erdos.renyi function to use the given edge density?
For gnm, the second parameter, m, is the number of edges. For a graph with 25 vertices, there are 300 possible edges, not counting loops and multi-edges. 15 edges out of 300 gives a density of 0.05, so that seems to be correct. Are you sure you want a density of 15? Because that means 15 edges per possible edge, so quite a multi-edged multigraph. It seems like the function only goes up to a density of 1.
Thank you for the response. That makes a lot of sense.
Unfortunately, I believe I must use a density of 15 as that is my observed networks edge density. (I study a highly social Crow species with many association per node).
In order to accurately simulate my random graphs, I believe the densities must be approximately the same.
When I calculate
edge_density(my_network)
I get 15
Whereas, when I calculate the simulated graph densities
edge_density(Random_network)
I get 0.05
I’m unsure as to why the “Random_network” density is given as a proportion while the actual network isn’t. I will try to investigate the function further.
In the documentation (igraph R manual pages), it says
“The density of a graph is the ratio of the number of edges and the number of possible edges.”
and also
“Note that this function may return strange results for graph with multiple edges, density is ill-defined for graphs with multiple edges.”
So I think it should never get above 1. From your description it also seems like your graph shouldn’t have multiple edges between two vertices. Does it?
If it isn’t a proportion then it isn’t a density, and it would be just the number of edges.
However, the network is very densely connected (some nodes have up to 22 edges) so it sounds like the multiple edges are affecting its ability to calculate the density correctly.
These two sentences together indicate that the graph is simple, in which case its density should never be above 1.Maybe you meant that the average degree of your network is 15 (instead of the density)?
I realized after looking through my data files that there were 2 nodes with multiple edges between them. This is definitely the driver of the strange density results.
I have begun working on converting these parallel edges to weights and then plan to run the erdos.renyi.game.
Thank you for your help @GroteGnoom !