Tutorial 9: Random networks practically

Recapitulation of theory

Models of random graphs

Model $G(n,p)$ has different degree distribution than real graphs. In the case $G(n,p)$ the degree distribution behaves Poisson distribution, whereas real networks often have the scale-free property. For this reason there are several other network models, which try to fix this issue.

Configuration model

It has given degree sequence $k_1, k_2, \ldots, k_n$, where $k_i = \deg(v_i)$, so $m = \frac{1}{2}\sum_i k_i$. Configuration model is analogy of $G(n,m)$ with given degree sequence.

Generating random network in configuration model:

A graph has power-law degree distribution, if its degree distribution is in the form $p_k = C k^{-\alpha}$. Usually we consider $2 \leq \alpha \leq 3$.

Chung-Lu model

Analogy of $G(n,p)$. We set weights $w_i$ corresponding to mean degree.

Probability $p_{i,j}$ of an edge between $v_i$ and $v_j$ is given by $$p_{ij}=\begin{cases} \frac{w_iw_j}{2m} & \text{ for } i\neq j\\ \frac{w_i^2}{2m} & \text{ for } i = j \end{cases}$$

We define $m = \frac{1}{2}\sum_i w_i$. Mean number of edges is $$ \sum_{i < j} p_{ij} + \sum_i p_{ii} = \sum_{i < j} \frac{w_iw_j}{2m} + \sum_i \frac{w_i^2}{2m} = \sum_{ij} \frac{w_iw_j}{4m} = m $$ and similarly the mean degree of a vertex $v_i$ is $$\langle k_i \rangle = 2p_{ii} + \sum_{j\neq i} p_{ij} = \frac{w_i^2}{2m} + \sum_{j\neq i} \frac{w_iw_j}{2m} = \sum_{j} \frac{w_iw_j}{2m} = w_i.$$

Properties of random graphs

Random graphs $G(n,p)$ and $G(n,m)$ can be generated by NetworkX as follows:

More types of random graphs and details to their implementation can be found in the documentation: https://networkx.org/documentation/stable/reference/generators.html#module-networkx.generators.random_graphs

Task 1: Randomly generate set of 100 graphs on $n$ vertices with probability of an edge $p$ for given $n$ and $p$. Compare average values for the set of graphs with theoretical values for $G(n,p)$ from the lecture for the following parameters

Task 2: Generate reasonably large random graph $G(n,p)$ and find around which value of $p$

Task 3: Write a function which for given degree distribution returns randomly generated network using the configuration model.

Task 4: Write a function which for given weights of vertices returns randomly generated network using the Chung-Lu model.