You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/networks/models.qmd
+5-14Lines changed: 5 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -3,16 +3,6 @@ title: "NetworkX - Graph Models"
3
3
format: html
4
4
---
5
5
6
-
# NetworkX - Graph Models
7
-
8
-
_The contents of this notebook have been derived from "A First Course in Network Science" by Filippo Menczer. [You can see their official Github repository here.](https://github.com/CambridgeUniversityPress/FirstCourseNetworkScience/tree/master)_
For each of the models presented in this tutorial, we present the algorithm, and the corresponding NetworkX code function to generate the model.
17
7
18
8
**Note:** This notebook assumes you know the basics of Network X, that were shown in the "fundamentals" notebook. It will also use concepts from the "structural properties" notebook.
@@ -22,7 +12,7 @@ import matplotlib.pyplot as plt
22
12
import networkx as nx
23
13
```
24
14
25
-
## 1. Random Network Model
15
+
## Random Network Model
26
16
27
17
The random network model, as formulated by Gilbert, has two parameters: the number of nodes $N$, and the link probability $p$. As in the book text, the algorithm for creating this network is as follows:
28
18
@@ -70,7 +60,7 @@ plt.ylabel("Number of nodes")
70
60
plt.show()
71
61
```
72
62
73
-
### Erdös-Rényi random graph model
63
+
### Erdos-Renyi random graph model
74
64
75
65
Instead of specifying the link probability $p$, we can also generate a graph of $N$ nodes with exactly $M$ edges by using `random.sample()` to choose M of the possible edges generated with `itertools.combinations()`:
76
66
@@ -115,7 +105,7 @@ plt.show()
115
105
116
106
---
117
107
118
-
## 2. Small-World Model
108
+
## Small-World Model
119
109
120
110
The algorithm for generating a small-world network is as such:
121
111
@@ -161,7 +151,7 @@ plt.show()
161
151
162
152
---
163
153
164
-
## 3. Preferential Attachment Model
154
+
## Preferential Attachment Model
165
155
166
156
The Barabási-Albert preferential attachment model has two parameters: the number of nodes $N$, and the number of links added at each step $m$. Given these parameters, the algorithm is as follows:
0 commit comments