"# EXERCISE SHEET 2, EXERCISE 2: Giant Component in ER-Model"
"# EXERCISE SHEET 4, EXERCISE 2: Giant Component in ER-Model"
]
},
{
...
...
%% Cell type:markdown id: tags:
# EXERCISE SHEET 2, EXERCISE 2: Giant Component in ER-Model
# EXERCISE SHEET 4, EXERCISE 2: Giant Component in ER-Model
%% Cell type:markdown id: tags:
The goal of this exercise is to observe and verify the behaviour of the ER-Model under different parameter specifications.
%% Cell type:code id: tags:
``` python
#import the neccessary packages
```
%% Cell type:markdown id: tags:
# QUESTION 1:
Generate a function that samples instances of ER-$G(N,p)$ models. Given a simple graph G = (V,E), the probability that your function outputs G should be equal to $p^M (1-p)^{\binom{N}{2}-M}$, where $M \coloneqq |E|$.
Your function could follows this sturcture:
- Take as inputs two paramters $N \in \mathbb{N}$ and $p \in [0,1]$;
- Create an empty undirected networkx graph with $N$ nodes;
- Loop over each pair of nodes $(i,j)$ and with probability $p$, add an edge between $i$ and $j$;
- Return the graph.
Generate a few test graphs, compute their average degree and plot their degree distributions. Verify that the results you obtain are consistent with what you expect from the analytical derivations of the lecture.