Erdős–Rényi Model
Buildup
Let us consider a simple graph with labeled vertices and edges, which has the property .
A random graph with exactly links can be represented as follows . The graph produced in this manner does not care who makes it or what probability it is made with, as long as it only has nodes and links. In other words, no probability distribution has been given yet. The easiest probability distribution we can think of here is the uniform distribution, where everyone has the same probability.
Since a simple graph must connect different nodes, among nodes, choosing of them can have links, and especially since it chooses of those links, it is . For all means that all graphs with nodes and links have an equal chance of being selected.
Definition 1 2
Given a probability space , let us consider the property .
A random graph having the following probability mass function is called the Erdős–Rényi Graph .
Description
The Erdős-Rényi model is the representative network among random graphs, frequently found and used throughout the scientific community, and is also referred to as the ER model for short. Since all have the same probability of being selected, following a uniform distribution, it can also be called a Uniform Random Network.
The Gilbert model constructs a network similar to the ER model in a different way. Although algorithmically and mathematically the two models are different, essentially, if we do not focus on the differences between the two models, they are almost the same. Unfortunately, since the ER model is too well-known, there are many cases where the Gilbert model is also referred to as the ER model, which means the author either cannot or does not feel the need to distinguish between the differences, so let’s not get too hung up on that either.
The algorithm for sampling ER networks is as follows.
Algorithm
Input
Assuming the number of nodes and links are given.
Step 1. Initialization
Create a null graph with nodes, and make a list (sequence) of tuples . Shuffle the order of sequence randomly.
Step 2. Sampling
for
For , add link to network as follows.
Output
Obtain a simple graph with nodes and links.
Visualization
Below is the sampled ER network and the histogram of its node degrees when , .
Code
Here is the code using Julia’s Graphs
, GraphRecipes
packages.
cd(@__DIR__); pwd()
@time using Graphs
@time using Plots
@time using GraphRecipes
n = 50
G_nm = erdos_renyi(n, 3n, seed = 0)
plot_G_nm = graphplot(G_nm, title = "n = 50, m = 150", curves=false, size = (300,300), node_weights = degree(G_nm).^2,
node_shape = :rect, nodecolor = :black, nodestrokealpha = 0.5, edgecolor = :black)
png(plot_G_nm, "plot_G_nm.png")
histogram_G_nm = histogram(degree(G_nm), title = "Histogram of Degree",
color = :black, alpha = 0.8, label = :none, size = (300,300))
png(histogram_G_nm, "histogram_G_nm.png")