rgraph_er function

Erdos-Renyi model

Erdos-Renyi model

Generates a bernoulli random graph.

rgraph_er( n = 10, t = 1, p = 0.01, undirected = getOption("diffnet.undirected"), weighted = FALSE, self = getOption("diffnet.self"), as.edgelist = FALSE )

Arguments

  • n: Integer. Number of vertices
  • t: Integer. Number of time periods
  • p: Double. Probability of a link between ego and alter.
  • undirected: Logical scalar. Whether the graph is undirected or not.
  • weighted: Logical. Whether the graph is weighted or not.
  • self: Logical. Whether it includes self-edges.
  • as.edgelist: Logical. When TRUE the graph is presented as an edgelist instead of an adjacency matrix.

Returns

A graph represented by an adjacency matrix (if t=1), or an array of adjacency matrices (if t>1).

Details

For each pair of nodes i,j{i,j}, an edge is created with probability pp, this is, c("%", "\n\n", "PrLinkijPr{Link i-j}"), where xx is drawn from a Uniform(0,1)Uniform(0,1).

When weighted=TRUE, the strength of ties is given by the random draw xx used to compare against pp, hence, if x<px < p

then the strength will be set to xx.

In the case of dynamic graphs, the algorithm is repeated tt times, so the networks are uncorrelated.

Note

The resulting adjacency matrix is store as a dense matrix, not as a sparse matrix, hence the user should be careful when choosing the size of the network.

Examples

# Setting the seed set.seed(13) # Generating an directed graph rgraph_er(undirected=FALSE, p = 0.1) # Comparing P(tie) x <- rgraph_er(1000, p=.1) sum(x)/length(x) # Several period random gram rgraph_er(t=5)

References

Barabasi, Albert-Laszlo. "Network science book" Retrieved November 1 (2015) https://barabasi.com/book/network-science.

See Also

Other simulation functions: permute_graph(), rdiffnet(), rewire_graph(), rgraph_ba(), rgraph_ws(), ring_lattice()

Author(s)

George G. Vega Yon