DS701 Session 23 — Mon Nov 23, 2026
An undirected graph has \(n\) nodes and \(e\) edges. State what the degree of a node is, and explain in one or two sentences why the average degree is \(2e/n\). Then say how the notion of degree changes for a directed graph.
The lecture defined a small-world network as one with high clustering and* short average path length. Explain why those two properties seem to be in tension (think of the ring lattice), and what Watts and Strogatz showed about how little it takes to get both at once.*
In the football example the lecture built a \(G(n,p)\) random graph with the same number of nodes and edges as the real network and compared the two. Why is a random graph a useful baseline, and name two ways the lecture showed real networks typically differ from \(G(n,p)\) — say what you would look at to see each difference.

\(E = \{(1,2),(1,3),(2,3),(3,4),(3,5)\}\)

Number the nodes; \(A_{ij} = 1\) if \((i,j) \in E\), else \(0\):
\[ A = \begin{bmatrix} 0 & 1 & 1 & 0 & 0\\ 1 & 0 & 1 & 0 & 0\\ 1 & 1 & 0 & 1 & 1\\ 0 & 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0 & 0 \end{bmatrix} \qquad \text{row sums} = \begin{bmatrix} 2\\2\\4\\1\\1 \end{bmatrix} \]
Every one of these is one NetworkX call: G.degree, nx.connected_components, nx.shortest_path_length, nx.diameter, nx.average_clustering. The skill is knowing which to ask, and what a surprising answer would look like.
It is not a model of anything real. It is what “no structure” looks like at this size and density — so anything the real graph does differently is worth explaining.

Degree distribution as a CCDF: \(P(X > x)\), the fraction of nodes with degree above \(x\).
Clustering coefficient — the probability that two of your neighbours are connected.
\[ C^{(1)} = \frac{\sum_i \#\text{triangles at } i}{\sum_i \#\text{neighbour pairs at } i} \]
Five-node example: \(\dfrac{1+1+1}{1+1+6} = \dfrac{3}{8}\).
\(C^{(2)}\) averages the per-node ratios instead (nx.average_clustering): \(\dfrac{1}{5}\bigl(1+1+\tfrac16\bigr) = 0.433\).
Random graph: \(C = p\). Real networks: much higher.

Watts–Strogatz: a few rewired edges collapse \(L\) while \(C\) holds. Small world = high clustering and short paths. Milgram’s 6.2 hops; Granovetter’s weak ties; Kevin Bacon is not special.


The same relationship data can be turned into several graphs — and they answer questions differently.
There is no representation-free “the network”. Today’s activity: same data, three representations, three sets of answers — then you decide which is right for the question. Next session: centrality and PageRank — the representation choice bites even harder there.
Goal: build small networks in NetworkX from edge lists — adjacency matrix, degree, components, shortest paths, diameter, clustering, degree distributions against a \(G(n,p)\) baseline and a heavy-tailed one — then re-represent the same data as directed / weighted / thresholded graphs and watch the answers move.
numpy, pandas, matplotlib, scipy, networkx.The activity notebook goes live on the day of the lecture. Colab is optional — you can also open it on GitHub and run it locally.
Full lecture notes: Introduction to Networks