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)
Arguments
n: the number of nodes to be generated
mode: '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
par: a real number ∈[0,1] for mode='prob', or a positive integer ∈[1,n∗(n−1)/2] for mode='num'
rep: the number of observations to be generated.
Returns
depending on rep value, either
(rep=1): an (n×n) observation matrix, or
(rep>1): a length-rep list where each element is an observation is an (n×n) realization from the model.
Details
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.
Examples
## generate 3 graphs with a global with probability 0.5graph3 = gmodel.ER(100,par=0.5,rep=3)## visualizeopar = 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)