
Last chance! 50% off unlimited learning
Sale ends in
Erdos-Renyi random graph model is one of the most popular and
fundamental examples in modeling networks. Given n nodes,
gmodel.ER
generates edges randomly from Bernoulli distribution
with a globally specified probability.
gmodel.ER(n, mode = "prob", par = 0.5, rep = 1)
the number of nodes to be generated
'prob' (default) for edges to be drawn from Bernoulli distribution independently, or 'num' for a graph to have a fixed number of edges placed randomly
a real number mode='prob'
, or a
positive integer mode='num'
the number of observations to be generated.
depending on rep
value, either
an
a length-rep
list where each element
is an observation is an
In network science, 'ER' model is often interchangeably used in where we have fixed number of edges to be placed at random. The original use of edge-generating probability is from Gilbert (1959). Therefore, we set this algorithm to be flexible in that user can create either a fixed number of edges placed at random or set global edge-generating probability and draw independent observations following Bernoulli distribution.
Erdos1959graphon
Gilbert1959graphon
# NOT RUN {
## generate 3 graphs with a global with probability 0.5
graph3 = gmodel.ER(100,par=0.5,rep=3)
## visualize
opar = par(no.readonly=TRUE)
par(mfrow=c(1,3), pty="s")
image(graph3[[1]], main="1st sample")
image(graph3[[2]], main="2nd sample")
image(graph3[[3]], main="3rd sample")
par(opar)
# }
Run the code above in your browser using DataLab