logo

Erdős–Rényi Model 📂Graph Theory

Erdős–Rényi Model

Buildup

Let us consider a simple graph with nn labeled vertices and mm edges, which has the property Gn,m2(n2)\mathscr{G}_{n,m} \subset 2^{\binom{n}{2}}.

A random graph with exactly mm links can be represented as follows Gn,m:ΩGn,m\mathbb{G}_{n, m} : \Omega \to \mathscr{G}_{n,m}. 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 nn nodes and mm 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 nn nodes, choosing 22 of them can have (n2)\binom{n}{2} links, and especially since it chooses mm of those links, it is Gn,m=((n2)m)\displaystyle \left| \mathscr{G}_{n,m} \right| = \binom{\binom{n}{2}}{m}. For all GGn,mG \in \mathscr{G}_{n,m} P(Gn,m=G)=((n2)m)1 P \left( \mathbb{G}_{n,m} = G \right) = \binom{\binom{n}{2}}{m}^{-1} means that all graphs with nn nodes and mm links have an equal chance of being selected.

Definition 1 2

Given a probability space (Ω,F,P)( \Omega , \mathcal{F} , P), let us consider the property Gn,m2(n2)\mathscr{G}_{n,m} \subset 2^{\binom{n}{2}}.

A random graph having the following probability mass function is called the Erdős–Rényi Graph Gn,m\mathbb{G}_{n,m}. P(Gn,m=G)=((n2)m)1,GGn,m P \left( \mathbb{G}_{n,m} = G \right) = \binom{\binom{n}{2}}{m}^{-1} \qquad , \forall G \in \mathscr{G}_{n,m}

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 GGn,mG \in \mathscr{G}_{n,m} have the same probability of being selected, following a uniform distribution, it can also be called a Uniform Random Network.

The Gilbert model Gn,p\mathbb{G}_{n,p} constructs a network similar to the ER model Gn,p\mathbb{G}_{n,p} 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 nNn \in \mathbb{N} and links mNm \in \mathbb{N} are given.


Step 1. Initialization

Create a null graph GG with nn nodes, and make a list (sequence) of tuples {lk}\left\{ l_{k} \right\}. {lk}={(i,j)[n]2:ij},[n]={1,,n} \left\{ l_{k} \right\} = \left\{ (i,j) \in [n]^{2} : i \ne j \right\} \qquad , [n] = \left\{ 1, \cdots , n \right\} Shuffle the order of sequence {lk}\left\{ l_{k} \right\} randomly.


Step 2. Sampling

for k=1,,mk = 1 , \cdots , m

  For lk=(i,j)l_{k} = (i,j), add link ijij to network GG as follows. GG+ijG \gets G + ij


Output

Obtain a simple graph GGn,mG \in \mathscr{G}_{n,m} with nn nodes and mm links.

Visualization

Below is the sampled ER network and the histogram of its node degrees when n=50n = 50, m=150m = 150.

plot_G_nm.pnghistogram_G_nm.png

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")

  1. Erdős, Rényi. (1959). On the evolution of random graphs ↩︎

  2. Frieze. (2015). Introduction to Random Graphs: p3. ↩︎