Before you start: review of the earlier sessions
The thread so far. This bonus page is the "before and around" the GNN block: features that preceded learned embeddings (sessions 1–2) and tricks that make GNNs (sessions 3–5) affordable at scale.
What this session takes from earlier ones
- Lecture 1: node, link and graph tasks, now solved with hand-made features
- Lecture 2: random walks, which also underlie PageRank and label propagation
- Lecture 3: the GCN layer, which SGC strips to a fixed propagation
- Lecture 5: neighbour sampling, extended here to GraphSAGE-style and cluster-based scaling
Those sessions in one minute each
Lecture 1 · Introduction — Machine Learning with Graphs
A graph model must work for any number of nodes and give the same answer no matter how the nodes are numbered — everything else is a design choice about what the nodes and edges mean.
A homogeneous graph is the special case \(|R| = |T| = 1\). Permutation: relabelling nodes with a permutation matrix \(P\) turns \(A\) into \(PAP^\top\); a graph-level model \(f\) must satisfy \(f(PAP^\top, PX) = f(A, X)\).
Define similarity by co-occurrence on short random walks, then learn one vector per node so that dot products reproduce it — fast with negative sampling, but just a lookup table.
\(N_R(u)\): multiset of nodes visited by walks from \(u\) under strategy \(R\) (uniform for DeepWalk, \(p,q\)-biased for node2vec); \(n_i\): negatives sampled ∝ degree; \(\sigma\): sigmoid.
Lecture 3 · Graph Neural Networks
A GNN layer = for every node, combine its own vector with an order-free aggregate of its neighbours' vectors, using weights shared across all nodes; stacking K layers lets information travel K hops.
Rows of \(H\) are node embeddings; \(D^{-1}A\) averages over neighbours; \(W_k\) transforms the neighbourhood message; \(B_k\) transforms the node itself.
Lecture 5 · GNN Augmentation and Training
Choose the computation graph deliberately (features, virtual nodes, sampling), pick the head that matches the task level, and split so that information from validation/test can never leak into training through message passing.
Warm-up: answer these before you read on
What is the difference between a directed and an undirected graph in the adjacency matrix? from Lecture 1
An undirected graph has a symmetric adjacency matrix; a directed graph does not.
Give the three limits of shallow embeddings. from Lecture 2
No parameter sharing (one vector per node), no use of node features, and no embedding for nodes unseen at training time (transductive).
What does the self-loop (or the B matrix) do in the GCN layer? from Lecture 3
It keeps the node's own previous vector in the update, so a node does not forget its own features while absorbing its neighbours'.
What is the difference between a transductive and an inductive split? from Lecture 5
Transductive: one graph, all nodes visible, only labels are split. Inductive: separate graphs (or subgraphs) for training and test, so test nodes are never seen.
More questions from every session you have reached, with spaced repetition: the cumulative review.
In short
This bonus page covers three chapters of the 2024 lecture notes that this year's slides do not: traditional features (notes ch. 1), label propagation (ch. 19) and scaling GNNs (ch. 20). They belong together: all three ask "how much can we get from the graph structure itself, cheaply?"
1. Hand-crafted features. In a classic pipeline you compute a feature vector and give it to logistic regression or a random forest. For a node: degree, centralities (eigenvector, betweenness, closeness), clustering coefficient, and the graphlet degree vector. For a pair of nodes (link prediction): common neighbours, Jaccard, Adamic–Adar (local) and the Katz index (global). For a whole graph: a kernel \(K(G,G')=\phi(G)^\top\phi(G')\), for example the graphlet kernel or the Weisfeiler–Lehman (WL) kernel.
2. Labels are signals too. Because of homophily, neighbours tend to share labels. Label propagation repeatedly sets each unlabelled node's class probability to the weighted average of its neighbours'. Correct & Smooth takes any base predictor, spreads its errors along edges (correct), then spreads the corrected predictions (smooth). Masked label prediction feeds some labels as input features and asks the model to predict the hidden ones, like BERT.
3. Scaling. Full-batch GNN training on a graph with \(10^8\)–\(10^9\) nodes does not fit in GPU memory. Neighbour sampling (GraphSAGE) keeps at most \(H\) neighbours per hop: cost \(M\cdot H^K\). Cluster-GCN trains on communities found by METIS/Louvain: cost linear in \(K\). Simplified GCN removes the nonlinearities, so \(\tilde A^K X\) is computed once as preprocessing.
The picture: Correct & Smooth on a four-node path
How to read it (hover a step)
- A path graph a–b–c–d. Only a (true class 1) and d (true class 0) are labelled. A base predictor that ignores the graph (for example an MLP on node features) outputs a probability of class 1 for every node. It is not confident: .60, .55, .50, .40.
- On the labelled nodes we know the truth, so we know the error \(e_v=p_v-\hat p_v\): a is under-predicted by .40, d is over-predicted by .40. Unlabelled nodes get error 0 for now.
- Correct. Errors are correlated along edges, so we spread them: one step of \(E\leftarrow(1-\alpha)E+\alpha\,\bar A E\) with \(\alpha=0.5\) and \(\bar A\) = "average over neighbours" (a toy version of \(\tilde A\)) gives b +.10 and c −.10. Adding them (scale \(s=1\)): b .65, c .40. Labelled nodes are set to their true labels: \(z_a=1,\ z_d=0\).
- Smooth. Now spread the corrected labels \(z\) themselves with the same rule: a .825, b .675, c .3625, d .2 (rounded in the picture). b now clearly leans to class 1 and c to class 0, which matches its position in the graph. Labelled nodes' final values do not matter: we already know them.
1 · Node-level features: degree, centrality, clustering, graphlets
The classic pipeline has two stages. (1) Design features for the objects you predict on. (2) Train any standard model (logistic regression, random forest, a small MLP) on these features. The notes say it plainly: using effective features over graphs is the key to good performance. Everything below assumes an undirected graph \(G=(V,E)\) with adjacency matrix \(A\). \(N(v)\) is the set of neighbours of \(v\) and \(k_v=|N(v)|\) is its degree.
Degree
\(k_v\): the number of neighbours. Simple and useful, but it treats all neighbours as equal: a node linked to five isolated leaves and a node linked to five hubs get the same value.
Centralities: how "important" is a node?
- Eigenvector centrality. A node is important if its neighbours are important: \(c_v=\frac{1}{\lambda}\sum_{u\in N(v)}c_u\). Written for all nodes at once this is \(\lambda c=Ac\), an eigenvector equation. We take the eigenvector of the largest eigenvalue \(\lambda_{\max}\). By the Perron–Frobenius theorem (for a connected graph) \(\lambda_{\max}\) is positive and simple, and its eigenvector can be chosen with all entries positive, so it is a valid score. (PageRank is a close cousin with a random-jump term.)
- Betweenness centrality. A node is important if it is a gatekeeper: it lies on many shortest paths between other nodes. \[ c_v=\sum_{s\neq v\neq t}\frac{\#\{\text{shortest paths } s\to t \text{ through } v\}}{\#\{\text{shortest paths } s\to t\}} \] Each pair \((s,t)\) gives one unit of "flow", split equally among its shortest paths; \(v\) collects the share that passes through it.
- Closeness centrality. A node is important if it is close to everyone: \(c_v=\dfrac{1}{\sum_{u\neq v} d(u,v)}\), where \(d(u,v)\) is the shortest-path length. (The notes' formula prints "number of shortest paths" in the denominator; the standard definition, used here, sums shortest-path lengths.)
Clustering coefficient
How connected are \(v\)'s neighbours to each other? \[ e_v=\frac{\#\{\text{edges among } N(v)\}}{\binom{k_v}{2}}\in[0,1] \] The denominator is the number of possible edges among \(k_v\) neighbours. \(e_v\) counts triangles through \(v\) in its ego-network (the subgraph induced by \(\{v\}\cup N(v)\)). Social networks have very high clustering: your friends tend to know each other.
Graphlet degree vector (GDV)
The clustering coefficient counts one pattern (the triangle). Why not count all small patterns? Graphlets are small rooted, connected, induced, non-isomorphic subgraphs. "Rooted" means we also record which position \(v\) holds in the pattern (in a 3-node path, the centre and an end are different positions, called orbits). "Induced" means we take a node subset with all edges between those nodes. The GDV of \(v\) counts, for each graphlet position, how many times \(v\) appears there. Using all graphlets with 2–5 nodes gives a vector of 73 numbers: a detailed fingerprint of \(v\)'s local topology.
Two families of node features. Importance-based features (degree, centralities) help predict influential nodes, such as celebrities on X. Structure-based features (degree, clustering, GDV) capture the shape of the neighbourhood, which helps predict a node's role, such as a bridge or a member of a dense group. The limitation (notes p.10): these features are all local; two nodes in far-apart but similar regions get the same features.
Why does the eigenvector of \(\lambda_{\max}\) give a sensible score, while the eigenvector of the second-largest eigenvalue does not?
For a connected graph, \(A\) is non-negative and irreducible, so Perron–Frobenius guarantees that the top eigenvector can be taken with all entries strictly positive. Any other eigenvector is orthogonal to it, so it must have both positive and negative entries. A "centrality" with negative values makes no sense as importance. (The second eigenvector is still useful: its sign pattern splits the graph into two groups, which is the idea behind spectral partitioning.)
2 · Link-level features: neighbourhood overlap and Katz
Link prediction comes in two forms (notes p.10):
- Links missing at random. Remove a random set of edges and try to recover them (for example, unknown drug–drug interactions).
- Links over time. Given the graph \(G[t_0,t_0']\) with edges up to time \(t_0'\), output a ranked list \(L\) of pairs that will appear in \(G[t_1,t_1']\). Evaluation: let \(n=|E_{\text{new}}|\) be the number of new edges in the test period; take the top \(n\) pairs of \(L\) and count how many are correct.
The method: compute a score \(c(x,y)\) for every pair \((x,y)\), sort, and predict the top pairs as links. Scores:
- Common neighbours: \(c(u,v)=|N(u)\cap N(v)|\).
- Jaccard coefficient: \(c(u,v)=\dfrac{|N(u)\cap N(v)|}{|N(u)\cup N(v)|}\). Normalises by the size of the neighbourhoods, so two hubs do not win just because they are big.
- Adamic–Adar: \(c(u,v)=\sum_{w\in N(u)\cap N(v)}\dfrac{1}{\log k_w}\). A shared neighbour with few friends is strong evidence; a shared celebrity is weak evidence. (The notes print \(1/k_u\); that is the "resource allocation" index. Adamic–Adar uses \(1/\log k_w\).)
The problem with all three: they are 0 when \(u\) and \(v\) share no neighbour, even if they are very close in the graph. A global score fixes this.
Katz index
Count all walks between \(u\) and \(v\), of every length, with shorter walks weighted more. The key fact: \((A^\ell)_{uv}\) = number of walks of length \(\ell\) from \(u\) to \(v\) (proof by induction: \((A^{\ell+1})_{uv}=\sum_w (A^\ell)_{uw}A_{wv}\), i.e. extend each length-\(\ell\) walk by one edge). So \[ S_{uv}=\sum_{\ell=1}^{\infty}\beta^\ell (A^\ell)_{uv},\qquad S=\sum_{\ell=1}^\infty(\beta A)^\ell=(I-\beta A)^{-1}-I. \] \(\beta\in(0,1)\) is a decay factor. The closed form is the geometric series of matrices; it converges when \(\beta\lt 1/\lambda_{\max}(A)\) (the notes just say \(\beta\lt 1\), which is necessary but not sufficient for graphs with \(\lambda_{\max}\gt 1\)).
Prove \(\sum_{\ell\ge1}(\beta A)^\ell=(I-\beta A)^{-1}-I\).
Let \(T=\sum_{\ell\ge0}(\beta A)^\ell\). Then \((I-\beta A)T=T-\beta A T=\sum_{\ell\ge0}(\beta A)^\ell-\sum_{\ell\ge1}(\beta A)^\ell=I\), so \(T=(I-\beta A)^{-1}\) (the series converges because the spectral radius of \(\beta A\) is below 1). Subtract the \(\ell=0\) term \(I\).
3 · Graph-level features: kernels, graphlets and Weisfeiler–Lehman
To classify whole graphs (is this molecule toxic?), we need a feature vector for an entire graph. Kernel methods (for example SVMs) do not need explicit features; they need a similarity \(K(G,G')\in\mathbb R\) such that the kernel matrix \([K(G,G')]_{G,G'}\) is always positive semi-definite. Then there exists a feature map \(\phi\) (maybe infinite-dimensional) with \(K(G,G')=\phi(G)^\top\phi(G')\). In practice we design \(\phi\) directly.
Idea: bag-of-X. In NLP, bag-of-words counts words and ignores order. For graphs, "bag of nodes" (count nodes) is too weak: every graph with 4 nodes looks the same. "Bag of degrees" is better. Graph kernels count richer things.
Graphlet kernel
Here graphlets are defined slightly differently from the node-level version: they are not rooted and need not be connected. For size \(k=3\) there are 4 graphlets: no edge, one edge, a path of two edges, a triangle. The feature \(f_G\in\mathbb R^{n_k}\) counts how many \(k\)-node subsets of \(G\) induce each graphlet. Because bigger graphs have bigger counts, normalise: \(h_G=f_G/\sum_i f_{G,i}\), then \(K(G,G')=h_G^\top h_{G'}\).
The limitation is cost. Counting size-\(k\) graphlets by enumeration in a graph with \(n\) nodes takes \(O(n^k)\), because each subset needs an isomorphism test (and subgraph isomorphism is NP-hard in general). With maximum degree \(d\), connected graphlets can be enumerated in \(O(n d^{k-1})\) (notes p.11).
Weisfeiler–Lehman (WL) kernel (not in these notes; from earlier years' lecture 2 slides)
Goal: an efficient feature that still sees structure. Use colour refinement:
- Give every node the same initial colour \(c^{(0)}(v)\) (or its node label).
- Repeat \(K\) times: \(c^{(k+1)}(v)=\text{HASH}\big(c^{(k)}(v),\ \{\!\{c^{(k)}(u):u\in N(v)\}\!\}\big)\). HASH maps each distinct (own colour, multiset of neighbour colours) pair to a new colour. After \(k\) steps, a node's colour summarises its \(k\)-hop neighbourhood.
- \(\phi(G)\) = counts of every colour that appeared in any round. \(K(G,G')=\phi(G)^\top\phi(G')\).
Each round costs \(O(|E|)\), so the whole kernel is linear in the number of edges per iteration. This is the same aggregation that message-passing GNNs do, which is why the WL test is the ceiling of their expressive power (the GIN result).
Run one WL round on the path 1–2–3 (all nodes start with colour A). How many distinct colours after round 1? Can WL distinguish a 6-cycle from two disjoint triangles?
Round 1: node 1 sees (A, {A}), node 3 sees (A, {A}), node 2 sees (A, {A,A}). So two new colours: B for the ends, C for the centre. \(\phi\) = (A:3, B:2, C:1).
A 6-cycle and two triangles: every node has degree 2, so every node always sees (same colour, {same, same}). Colours never split, and \(\phi\) is identical. WL cannot separate them, even though one graph has triangles and the other has none. This is a classic limitation that also applies to standard GNNs.
4 · Label propagation: let labels flow along edges
Setting (transductive, also called semi-supervised, node classification). We know labels \(Y_v\) for some nodes of one graph \(G=(V,E)\) and want the labels of the rest. Node embeddings and GNNs use features and structure, but they do not use the known labels of neighbours as input. Label propagation does.
Why would neighbours share labels? Two social mechanisms (notes p.103):
- Homophily: people link to similar people ("birds of a feather"). Similarity causes the link.
- Influence: linked people become similar (you adopt your friends' opinions). The link causes the similarity.
Either way, labels are correlated across edges, and that correlation is a signal.
The algorithm
Binary labels \(Y_v\in\{0,1\}\). Keep a probability \(P(Y_v=c)\) for each node.
- Initialise: labelled nodes get their true label (\(P=1\) for their class). Unlabelled nodes get \(P(Y_v=1)=\tfrac12\).
- Update every unlabelled node to the weighted average of its neighbours: \[ P^{(t+1)}(Y_v=c)=\frac{1}{\sum_{(v,u)\in E}A_{v,u}}\sum_{(v,u)\in E}A_{v,u}\,P^{(t)}(Y_u=c). \] \(A_{v,u}\) is the edge weight (1 for unweighted graphs), so the denominator is \(v\)'s (weighted) degree. Labelled nodes stay fixed.
- Stop when \(|P^{(t)}(Y_v)-P^{(t-1)}(Y_v)|\le\epsilon\) for all \(v\), or after a maximum number of iterations. Predict class 1 if \(P(Y_v=1)\gt 0.5\).
Mini-example. Path 1–2–3–4–5, node 1 has label 1, node 5 has label 0. Start: 2, 3, 4 at 0.5. One synchronous step: node 2 = (1+0.5)/2 = 0.75, node 3 = (0.5+0.5)/2 = 0.5, node 4 = (0.5+0)/2 = 0.25. Next step: node 2 = (1+0.5)/2 = 0.75, node 3 = (0.75+0.25)/2 = 0.5, node 4 = (0.5+0)/2 = 0.25 — nothing changes, so it has converged. The probabilities fall linearly from the 1-labelled end to the 0-labelled end.
At convergence, each unlabelled value equals the average of its neighbours. What is this object called, and why is the answer on a path always linear?
A function that equals the average of its neighbours at every free node is a discrete harmonic function (Zhu, Ghahramani, Lafferty 2003). Harmonic functions obey a maximum principle and are unique given the boundary values (the labelled nodes). On a path, "average of the two neighbours" means \(f(i)-f(i-1)=f(i+1)-f(i)\): constant differences, so linear. There is also a random-walk reading: \(P(Y_v=1)\) is the probability that a random walk from \(v\) hits a 1-labelled node before a 0-labelled node.
Issues (notes p.104): convergence can be slow and is not guaranteed (for example oscillation on bipartite graphs if you also update all nodes synchronously without anchoring); and it ignores node features. One step is very cheap, and overall it is usually cheaper than training a deep network, but GNN inference on new data is faster than re-running propagation.
5 · Correct & Smooth, and masked label prediction
Motivation. GNNs can fail badly when node features are only mildly predictive (figure above). Correct & Smooth (C&S) is a post-processing method that is model-agnostic: take your favourite base model (even a plain MLP) and improve it with the graph. The key observation: the errors of a base predictor are also correlated along edges. If the model underestimates class 1 at a node, it probably also underestimates it at that node's neighbours.
The diffusion matrix
Add self-loops (\(A_{ii}=1\)), let \(D\) be the diagonal degree matrix (\(D_{ii}=\deg i\)), and define \[ \tilde A=D^{-1/2}AD^{-1/2},\qquad \tilde A_{ij}=\frac{1}{\sqrt{d_i d_j}}\ \text{ if } i\sim j. \] Each edge weight accounts for the degree of both endpoints, so hubs do not dominate.
Theorem (notes p.106). All eigenvalues of \(\tilde A\) lie in \([-1,1]\), and the largest is 1 with eigenvector \(D^{1/2}\mathbf 1\). Hence powers \(\tilde A^K\) neither explode nor vanish.
Prove both parts of the theorem.
Eigenvector: \(\tilde A D^{1/2}\mathbf 1=D^{-1/2}AD^{-1/2}D^{1/2}\mathbf 1=D^{-1/2}A\mathbf 1=D^{-1/2}D\mathbf 1=D^{1/2}\mathbf 1\), using \(A\mathbf 1=D\mathbf 1\) (row sums are degrees). So eigenvalue 1.
Range: \(\tilde A=D^{1/2}(D^{-1}A)D^{-1/2}\) is similar to \(P=D^{-1}A\), so they have the same eigenvalues. \(P\) is row-stochastic (non-negative rows summing to 1), so \(\|Px\|_\infty\le\|x\|_\infty\) and every eigenvalue has \(|\lambda|\le1\). Since \(\tilde A\) is symmetric, the eigenvalues are real, so they lie in \([-1,1]\).
The algorithm
- Train a base predictor that outputs soft labels (class probabilities) for every node. Use the labelled nodes for training and validation.
- Apply it to all nodes (labelled ones too) to get soft labels \(\hat p_v\); stack them as the matrix \(\hat P\).
- Correct step. Compute the training error on labelled nodes and zero elsewhere: \[ e_v=\begin{cases}p_v-\hat p_v & v \text{ labelled } (p_v=\text{one-hot true label})\\ 0 & v \text{ unlabelled}\end{cases} \] Diffuse the error matrix \(E^{(0)}\) for \(T\) steps: \(E^{(t+1)}=(1-\alpha)E^{(t)}+\alpha\tilde AE^{(t)}\). Add it back with a scale \(s\): \(\tilde P=\hat P+sE^{(T)}\). Then set \(z_v=p_v\) for labelled nodes and \(z_v=\tilde p_v\) for unlabelled ones.
- Smooth step. Neighbouring nodes tend to share labels, so diffuse \(Z\): \(Z^{(t+1)}=(1-\alpha)Z^{(t)}+\alpha\tilde AZ^{(t)}\). The final \(Z\) gives the predictions.
\(\alpha\in(0,1)\) controls how much a node trusts its neighbours over itself; the notes describe it as controlling the assumed degree of homophily. The picture section walks through all four steps on a small path.
Strictly speaking: the original paper (Huang et al. 2021) uses the "label spreading" form \(E^{(t+1)}=(1-\alpha)E^{(0)}+\alpha\tilde AE^{(t)}\), which keeps pulling back to the initial signal (like personalised PageRank). The notes' form replaces \(E^{(0)}\) by \(E^{(t)}\). Both spread the signal along edges; the paper's form has a well-defined fixed point \((1-\alpha)(I-\alpha\tilde A)^{-1}E^{(0)}\).
Results (notes p.107): C&S significantly improves the base model, beats a smooth-only baseline, and can be combined with GNNs. In the paper, a linear model or MLP plus C&S matched or beat much larger GNNs on several OGB benchmarks, with far fewer parameters.
Why is C&S only for transductive node classification, not graph classification?
It needs ground-truth labels on some nodes of the same graph at prediction time, to compute the errors that it diffuses. In graph classification each test graph has no labelled nodes. (The notes add: you can diffuse untrusted features inside a graph in a similar way, but that is a different paradigm.)
Masked label prediction
Inspired by BERT's masked-word objective (notes p.107). Treat labels as extra node features: concatenate the label matrix to the feature matrix, \([X,\ \dot Y]\), where \(\dot Y\) holds the observed labels (one-hot) and zeros for unknown nodes.
- Training: corrupt \(\dot Y\) into \(\tilde Y\) by masking a random portion of the known labels to 0. Feed \([X,\tilde Y]\) to a GNN and predict the masked labels. The masking prevents the trivial solution "copy your own label".
- Inference: use all known labels \(\dot Y\) as input and predict the unlabelled nodes.
Like link prediction, this is a self-supervised task: the supervision is made from the data itself. The GNN learns how to propagate labels, instead of using a fixed averaging rule.
6 · Why scaling is hard, and neighbour sampling
Real graphs are huge (notes p.107–108): recommender systems (Amazon, YouTube, Pinterest) have \(10^8\)–\(10^9\) users and \(10^7\)–\(10^9\) items; social networks (Facebook, X, Instagram) have \(10^8\)–\(10^9\) users; academic graphs (Microsoft Academic Graph) and knowledge graphs (Wikidata, Freebase, about \(10^8\) entities) are similar.
Normal deep learning minimises an average loss \(\ell(\theta)=\frac1N\sum_{i=0}^{N-1}\ell_i(\theta)\) with SGD: sample a mini-batch \(B\) of \(M\ll N\) examples, compute \(\hat\ell(\theta)\) on it, update \(\theta\leftarrow\theta-\alpha\nabla\hat\ell(\theta)\). This works because examples are independent.
GNNs break this. A node's embedding depends on its neighbours, so a random mini-batch of nodes is useless on its own: sampled nodes are usually far apart and their neighbours are missing. The alternative, full-batch training, updates all nodes at once, layer by layer: \[ H^{(k+1)}=\sigma\big(\tilde AH^{(k)}W_k^\top+H^{(k)}B_k^\top\big), \] where \(H^{(k)}\) holds all node embeddings at layer \(k\), \(W_k\) transforms neighbour messages and \(B_k\) transforms the node's own embedding. This needs all embeddings of all layers in GPU memory (10–20 GB at the time of the notes): impossible for \(10^9\) nodes.
Three fixes: two methods compute on small subgraphs (neighbour sampling, Cluster-GCN), one turns the GNN into feature preprocessing (Simplified GCN).
Neighbour sampling (GraphSAGE)
To compute one node's embedding with a \(K\)-layer GNN, you only need its \(K\)-hop computational graph. So: sample \(M\) target nodes, build their computational graphs, train on those. The problem: \(K\)-hop neighbourhoods grow exponentially, and one hub (a node with millions of followers) makes the graph explode.
Fix: at hop \(k\), keep at most \(H_k\) randomly sampled neighbours per node; prune the rest. A \(K\)-layer GNN then touches at most \(\prod_{k=1}^K H_k\) leaf nodes per target. With equal \(H\), total cost is \(M\cdot H^K\).
- Trade-off: small \(H\) = cheaper but higher-variance aggregation, so training is less stable.
- Still exponential in \(K\): each extra layer multiplies the cost by \(H\).
- Better sampling: instead of uniform sampling, run random walks with restarts from the node and keep the neighbours with the highest visit scores (this is what PinSAGE does). It works better in practice on natural graphs.
Worked count. With \(K=2\) and \(H_1=H_2=10\), each target needs at most \(10+10\cdot10=110\) sampled neighbours, of which 100 are leaves, whatever the hub sizes. With \(K=3\) it becomes up to 1000 leaves: one more layer, ten times the work.
7 · Cluster-GCN: train on communities
Observation. Neighbour sampling is wasteful: when targets share neighbours, the same embeddings are recomputed many times. Full-batch training avoids this with layer-wise updates: a \(K\)-layer GNN needs only about \(2K|E|\) messages (each edge sends one message in each direction per layer), because each layer reuses the previous layer's embeddings. That is efficient, but does not fit in memory for the whole graph.
Idea: do layer-wise full-batch updates on a small subgraph. Which subgraph? Messages travel along edges, so the subgraph should keep as many edges as possible. Real graphs have community structure, so sample a community.
Vanilla Cluster-GCN:
- Preprocessing: partition \(V\) into \(C\) groups \(V_1,\dots,V_C\) with a community-detection or graph-partitioning algorithm (Louvain, METIS). Each \(V_c\) induces a subgraph \(G_c\). Edges between groups are dropped.
- Mini-batch training: sample one group \(V_c\), run the GNN layer-wise on \(G_c\), compute the loss on its nodes, update.
Issues: (a) dropped between-group edges bias the gradient estimates; (b) one group covers only a small, concentrated part of the data; (c) groups are not diverse, so gradients differ a lot between groups, giving high variance and slow SGD convergence.
Advanced Cluster-GCN: partition into many small groups; each mini-batch samples \(q\) groups \(V_{i_1},\dots,V_{i_q}\) and runs the GNN on the subgraph induced by their union. This restores the edges among the chosen groups and mixes different parts of the graph in each batch, so gradients are less biased and less noisy.
Cost. For \(M\) target nodes, a \(K\)-layer Cluster-GCN costs about \(K\cdot M\cdot D_{\text{avg}}\) (\(D_{\text{avg}}\) = average degree): linear in \(K\), versus \(M\cdot H^K\) for neighbour sampling. Example: with \(K=3\), \(H=10\), \(D_{\text{avg}}=10\): \(1000M\) versus \(30M\).
Answers from the notes' Q&A (p.111): what about nodes with no community, and should you train one model per cluster?
Assign isolated nodes to some community. Train one model over all clusters; separate models would overfit their subgraph. Partitioning cost is not a concern: many community-detection algorithms are linear in \(|V|\). Open problems mentioned: representing each dropped cluster as a "hypernode" (see GNNAutoScale) and avoiding edge-type bias on heterogeneous graphs.
8 · Simplified GCN: remove the nonlinearity, precompute
Start from the GCN layer: \(E^{(k+1)}=\text{ReLU}(\tilde AE^{(k)}W^{(k)})\). Simplified GCN (SGC) removes the ReLU. Then the layers collapse: \[ E^{(K)}=\tilde A\big(\cdots\tilde A(\tilde A X W^{(0)})W^{(1)}\cdots\big)W^{(K-1)}=\tilde A^KX\,\underbrace{W^{(0)}W^{(1)}\cdots W^{(K-1)}}_{=:W}. \] A product of linear maps is one linear map, so the model is \(\tilde A^K X W\) with a single \(W\). SGC also adds self-loops, \(A\leftarrow A+I\), before normalising, and takes the node features \(X\) as given (unlike LightGCN, which has no self-loops and learns the node embeddings).
- Preprocess once (on CPU, sparse matrix products): \(\tilde X=\tilde A^KX\). This is \(K\) sparse multiplications.
- Train any standard model (logistic regression, MLP) on the rows of \(\tilde X\). Now nodes are independent examples, so ordinary mini-batch SGD works and scales to billions of nodes.
Drawback: less expressive (a linear model on fixed features). Surprise: on many node-classification benchmarks it performs about as well as GCN. Why? Homophily: connected nodes tend to share labels, and \(\tilde A^K X\) averages features over \(K\)-hop neighbourhoods, so nodes in the same region get similar pre-processed features, which is exactly what a homophilous task needs. (The notes' Q&A: does that mean much of what GNNs learn is linear? "Yes.")
When should SGC (and label propagation) do badly?
On heterophilous graphs, where linked nodes tend to have different labels (fraud rings linking to victims, dating networks, some bot–human interaction graphs). Averaging over neighbours then mixes the classes and erases the signal. Models that keep the node's own features separate (the \(B_k\) term) or use signed or higher-order aggregation do better there.
Key idea
Graph structure is a feature generator: hand-crafted counts (degree, centrality, graphlets, Katz, WL colours) were the first graph ML. Homophily makes labels and errors smooth over edges, so cheap diffusion (label propagation, Correct & Smooth) rivals deep GNNs. At web scale, either compute on small subgraphs (neighbour sampling, Cluster-GCN) or precompute the diffusion once (SGC).
All three are the same operator: multiply by a normalised adjacency matrix, again and again. They differ in what is diffused (labels, errors, features).
The mathematics, step by step
This bonus session collects the formulas that predate GNNs or run beside them. They are simple, and that is their value: each can be computed by hand on a small graph, as below, and several of them are what a GNN reduces to when its weights are removed.
Symbols used in this session
| symbol | meaning | what kind of object |
|---|---|---|
| \(k_v\) | degree of node \(v\) | whole number |
| \(e_v\) | clustering coefficient of \(v\) | number in \([0,1]\) |
| \(c_v\) | betweenness centrality of \(v\) | non-negative number |
| \(\beta\) | Katz discount per step, \(0<\beta<1/\lambda_{\max}(A)\) | small positive number |
| \(S_{uv}\) | Katz index of the pair \((u,v)\) | non-negative number |
| \(P^{(t)}(Y_v=c)\) | current belief that node \(v\) has class \(c\), after \(t\) rounds | probability |
| \(\tilde A\) | normalised adjacency \(D^{-1/2}AD^{-1/2}\) | symmetric matrix |
| \(E\) | matrix of residual errors, one row per node: true one-hot label minus predicted probabilities on labelled nodes, 0 elsewhere | \(n\times C\) matrix |
| \(\alpha\) | how much is taken from the neighbours at each diffusion step | number in \((0,1)\) |
1Clustering coefficient
In words. Of all pairs of neighbours of \(v\), what share are themselves linked? Equivalently: how many of the possible triangles through \(v\) exist.
Why it has this form. A node with \(k_v\) neighbours has \(\binom{k_v}{2}=k_v(k_v-1)/2\) pairs of neighbours; each linked pair closes a triangle with \(v\). The ratio is 1 when the neighbours form a clique and 0 when none know each other. It is the simplest graphlet count: the number of triangles at \(v\) divided by the number of open two-paths centred at \(v\).
Watch out. The average of \(e_v\) over nodes is not the same number as the global transitivity (3 × triangles / connected triples), which weights high-degree nodes more.
2Betweenness centrality
In words. For every pair of other nodes, look at the shortest paths between them and note the fraction that pass through \(v\). Add up these fractions.
Why it has this form. A node matters as a broker if communication between others has to go through it. When several shortest paths tie, each carries an equal share, hence the fraction. Brandes' algorithm computes all values with one breadth-first search per source, accumulating dependencies from the far end back, in time proportional to nodes × edges.
Watch out. Conventions differ by a factor of two (ordered or unordered pairs) and by normalisation; compare values only within one convention.
3Katz index
In words. Count the walks of every length between \(u\) and \(v\), and discount a walk of length \(\ell\) by \(\beta^\ell\) so that long walks count little. The whole infinite sum is one matrix inverse.
Why it has this form. \((A^\ell)_{uv}\) is the number of walks of length \(\ell\) (Lecture 1). The closed form is the geometric series for matrices: \(\sum_{\ell\ge0}M^\ell=(I-M)^{-1}\) with \(M=\beta A\), minus the \(\ell=0\) term \(I\). It converges exactly when \(\beta\) times the largest eigenvalue of \(A\) is below 1. Unlike common-neighbour counts, which see only walks of length 2, the Katz index is non-zero for any two nodes in the same component.
Watch out. If \(\beta\ge1/\lambda_{\max}\) the series diverges, yet the matrix inverse may still exist and return meaningless (even negative) numbers.
4Label propagation
In words. Every unlabelled node replaces its belief by the (weighted) average of its neighbours' beliefs. Labelled nodes keep their labels. Repeat until nothing changes.
Why it has this form. The rule encodes homophily: a node is probably like its neighbours. At convergence each unlabelled node's value equals the average of its neighbours', which is the probability that a random walk started at the node reaches a node labelled \(c\) before any other labelled node. There are no parameters and no features; the labelled nodes are boundary conditions and the rest is diffusion.
Watch out. Under heterophily (neighbours tend to differ) the same averaging spreads the wrong label. The method also ignores node features entirely.
5Correct and Smooth
In words. Train any simple classifier on node features alone. On the labelled nodes compute its errors. Diffuse the errors over the graph and add them to the predictions (correct); then diffuse the corrected predictions, with the true labels clamped in, once more (smooth).
Why it has this form. The assumption is that errors, like labels, are similar on neighbouring nodes: if the classifier under-predicts class A on a labelled node, it probably does so on that node's unlabelled neighbours too. The diffusion with restart, \((1-\alpha)E^{(0)}+\alpha\tilde AE\), is personalised PageRank applied to each column: it spreads the known errors while staying anchored to them. The scale \(s\) compensates for the shrinking of errors as they spread. Graph structure is used only after training, so the classifier can be a plain MLP trained in seconds.
Watch out. The smoothing step uses validation labels as well as training labels at test time, which is legitimate in the transductive setting but must be stated when comparing with models that do not.
6The cost of a computation graph, and sampling
In words. To compute one node's embedding with \(K\) layers you need its neighbours, their neighbours, and so on: roughly degree to the power \(K\) nodes. Sampling a fixed number of neighbours at each hop replaces the degree by a number you choose.
Why it has this form. Every layer multiplies the number of nodes needed by the average degree, so memory explodes with depth, and one hub pulls in most of the graph. With at most \(H_k\) neighbours per node at hop \(k\), the size is bounded by a product of constants, independent of the graph. The sampled mean is an unbiased estimate of the full mean aggregation, at the price of variance. Cluster-GCN takes the other route: cut the graph into dense clusters and run full message passing inside a few clusters at a time.
Watch out. The savings shrink for a batch of nearby targets, whose computation graphs overlap, and sampling too few neighbours at the last hop makes the estimate noisy.
7Simplified GCN: what remains without non-linearities
In words. Remove the non-linearities from a \(K\)-layer GCN. All the weight matrices multiply into one, and all the graph operations multiply into \(\tilde A^K\). The model is logistic regression on features that have been averaged over the graph \(K\) times.
Why it has this form. Matrix multiplication is associative, so with nothing between the layers the products can be regrouped. \(\tilde A^KX\) has no parameters and can be computed once, before training; after that the graph is never touched again and training is as fast as for a linear model. That this works well on homophilous benchmarks shows where much of a GCN's accuracy comes from: the smoothing of features, not the depth of non-linear processing.
Watch out. For large \(K\) all rows of \(\tilde A^KX\) converge to the same vector (up to degree), so SGC inherits over-smoothing; \(K=2\) or \(3\) is typical.
Review: what to keep from this session
Carried forward. Use it as a baseline toolkit for the project: run label propagation and classic features before a GNN, and reach for sampling when the graph does not fit on a GPU.
Quick self-check
When does label propagation work and when does it fail?
It works under homophily (linked nodes share labels) and fails under heterophily, where diffusion mixes different classes.
What does SGC remove from GCN and what is left?
It removes non-linearities and per-layer weights; what is left is K steps of fixed propagation followed by one linear classifier.
Why is Cluster-GCN faster than full-batch training?
Each mini-batch is a dense cluster, so most edges stay inside the batch and the computation graph does not explode.
Worked example: features of one small graph
Graph with 5 nodes and edges A–B, A–C, A–D, B–C, D–E (a triangle A–B–C with a tail A–D–E).
- Degrees: A 3, B 2, C 2, D 2, E 1.
- Clustering: A has neighbours {B, C, D}: 3 possible pairs, 1 edge (B–C), so \(e_A=1/3\). B has neighbours {A, C}, linked, so \(e_B=1\); same for C. D has {A, E}, not linked, so \(e_D=0\). E has degree 1: undefined (usually set to 0).
- Betweenness of A: pairs not containing A whose shortest path passes through A: B–D, B–E, C–D, C–E (each has a unique shortest path through A); B–C and D–E do not. So \(c_A=4\). For D: A–E, B–E, C–E, so \(c_D=3\). B, C, E: 0.
- Closeness: distances from A: 1, 1, 1, 2, total 5, so \(c_A=1/5\). From D: A 1, B 2, C 2, E 1, total 6, so \(1/6\). From E: 2, 3, 3, 1, total 9, so \(1/9\). A is the most central by all three measures.
- Link B–D: \(N(B)=\{A,C\}\), \(N(D)=\{A,E\}\). Common neighbours 1; Jaccard \(1/|\{A,C,E\}|=1/3\); Adamic–Adar \(1/\log 3\approx0.91\).
- Link C–E: \(N(C)=\{A,B\}\), \(N(E)=\{D\}\): no common neighbour, so all three local scores are 0. Katz: there are no walks of length 1 or 2; the only walk of length 3 is C–A–D–E. So \(S_{CE}=\beta^3+O(\beta^4)\gt 0\): Katz still ranks this pair above unreachable ones.
Check yourself: compute the WL colours of this graph after one round (start all nodes at the same colour). You should get three colours: one for degree 1 (E), one for degree 2 (B, C, D), one for degree 3 (A). After round 2, does D separate from B and C? show answer
Yes: D's neighbours have degrees 3 and 1; B's have 3 and 2.
Proof workshop: When does the Katz index exist?
One problem in olympiad style. Give it fifteen minutes on paper before you open the first hint; the hints are graded, so open them one at a time.
Problem. For a symmetric adjacency matrix \(A\) with largest eigenvalue \(\lambda_{\max}\), prove that \(S=\sum_{k\ge1}\beta^kA^k\) converges if and only if \(0\le\beta<1/\lambda_{\max}\) (for \(\beta\ge0\)), and that then \(S=(I-\beta A)^{-1}-I\). Then show that label propagation \(F\leftarrow\alpha\hat AF+(1-\alpha)Y\), with \(\hat A=D^{-1/2}AD^{-1/2}\) and \(0<\alpha<1\), converges to \(F^{\star}=(1-\alpha)(I-\alpha\hat A)^{-1}Y\) from any start.
Hint 1
Hint 2
Solution
Why it matters. Katz and label propagation are the same object, a resolvent \((I-\beta A)^{-1}\), seen as a link score and as a diffusion. Personalised PageRank, APPNP and the "smooth" step of Correct & Smooth are further members of the family. On X, \(\lambda_{\max}\) is driven by hubs (\(\lambda_{\max}\ge\sqrt{d_{\max}}\), with equality for a star), so the admissible \(\beta\) shrinks as celebrity accounts grow.
Sharper lens: three classics, exactly
Not in the lecture notes. Three or four points where the chapter rounds something off: the exact statement, a second way to see it, and where it stops being true. Each is short and has a pointer for going further.
Betweenness for all nodes in O(nm): Brandes' accumulation
The definition suggests counting shortest paths for all \(n^2\) pairs through every node, \(O(n^3)\). Let \(\sigma_{st}\) be the number of shortest \(s\)–\(t\) paths and \(\delta_s(v)=\sum_t\sigma_{st}(v)/\sigma_{st}\) the dependency of source \(s\) on \(v\). Prove the recursion
\[ \delta_s(v)=\sum_{w\,:\,v\in\mathrm{pred}_s(w)}\frac{\sigma_{sv}}{\sigma_{sw}}\big(1+\delta_s(w)\big), \]
where \(\mathrm{pred}_s(w)\) are the neighbours of \(w\) one step closer to \(s\).
Solution and consequence
Overlap heuristics need the pair; a node-wise GNN cannot compute them
Common neighbours, Jaccard and Adamic–Adar are functions of the pair \((u,v)\). A GNN that embeds each node separately and scores \(\mathbf h_u^\top\mathbf h_v\) cannot compute even the number of common neighbours: by the automorphism argument in Lecture 15's Sharper lens, it gives pairs at different distances the same score whenever the endpoints look alike. This is why these 20-year-old scores still beat plain GNN link predictors on several benchmarks under careful evaluation.
The theory that joined the two worlds is SEAL (Zhang and Chen, NeurIPS 2018): Katz, rooted PageRank and SimRank are all "\(\gamma\)-decaying" heuristics, computable from the \(h\)-hop subgraph around the pair with an error that shrinks exponentially in \(h\). So extract that subgraph, label every node by its distances to \(u\) and \(v\), and let a GNN learn the heuristic. Later models keep the idea and drop the cost: ELPH and BUDDY (Chamberlain et al., ICLR 2023) estimate neighbourhood overlaps inside message passing with MinHash and HyperLogLog sketches, and NCN (Wang et al., ICLR 2024) pools the embeddings of the common neighbours themselves.
Low homophily is not the same as "hard for a GNN"
Section 8 says SGC and label propagation fail when linked nodes have different labels. The exact condition is weaker. Take a bipartite graph in which every edge joins class A to class B: edge homophily is 0, yet the task is easy, because \(\tilde A^2\) connects each node to its own class, and one more linear step maps "all my neighbours are B" to "I am A". What a GNN needs is that nodes of the same class have similar neighbourhood label distributions, and different classes different ones (Ma et al., ICLR 2022). Mean aggregation fails only when those distributions coincide across classes.
The measure matters too. Edge homophily, the fraction of same-label edges, is inflated by class imbalance: with 90% of nodes in one class, random wiring gives 0.82. Use adjusted homophily, which subtracts the level expected from the class sizes, or label informativeness, the mutual information between the labels at the two ends of a random edge (Platonov et al., NeurIPS 2023). The bipartite example has adjusted homophily near \(-1\) and maximal informativeness, the combination on which GNNs do well.
Lab: hands-on and practical tips
Try it live. In the Graph Explorer: node features, community detection, link heuristics and label propagation against a GCN. Each lesson has predict-then-check questions.
notebook · L20 classic graph ML computes classic node and link features, Katz, label propagation, Correct & Smooth, Cluster-GCN and SGC.
fraction of edges with equal labels, tells you whether to diffuse or to learn.Practice
- Centrality on a star. In a star with centre \(h\) and \(n-1\) leaves, compute the betweenness of \(h\) and the closeness of \(h\) and of a leaf.
Answer
Every pair of leaves has a unique shortest path, through \(h\): betweenness \(\binom{n-1}{2}\). Closeness of \(h\): \(1/(n-1)\). A leaf is at distance 1 from \(h\) and 2 from the other \(n-2\) leaves: \(1/(1+2(n-2))=1/(2n-3)\).
- Label propagation by hand. A triangle u–v–w plus an edge w–x. u is labelled 1 and x is labelled 0. Start v and w at 0.5 and iterate (synchronously) until convergence. What are the final values?
Answer
Fixed point: \(v=(u+w)/2=(1+w)/2\) and \(w=(u+v+x)/3=(1+v)/3\). Substituting, \(w=(1+(1+w)/2)/3\Rightarrow 6w=3+w\Rightarrow w=0.6\), \(v=0.8\). Both lean to class 1, w less so because it touches the 0-labelled node.
- Cost comparison. A 3-layer GNN, 1024 target nodes per batch. Neighbour sampling with \(H=15\) versus Cluster-GCN on a graph with average degree 20. Estimate the number of node computations for each, using the notes' formulas.
Answer
Neighbour sampling: \(M H^K=1024\cdot 15^3=1024\cdot3375\approx3.5\times10^6\). Cluster-GCN: \(K M D_{\text{avg}}=3\cdot1024\cdot20\approx6.1\times10^4\). About 56 times cheaper, at the price of dropping between-cluster edges.
- Why does SGC need self-loops? Consider a bipartite graph and \(K=2\) without self-loops: whose features end up in node \(v\)?
Answer
\(\tilde A^K X\) mixes features from nodes reachable by walks of length exactly \(K\). Without self-loops, odd \(K\) on a bipartite graph mixes only the other side, and \(v\)'s own features are lost for odd \(K\). Self-loops add walks that "stay", so \(v\) always keeps part of its own features and all nodes within distance \(K\) contribute. They also shrink the negative end of the spectrum, which makes the filter more low-pass.
Readings & lookup guide
lecture notes CS224W course notes (Leni Aniva, Autumn 2024 — in your course folder)
- Ch. 1 — Traditional ML on graphs (pp. 8–11)
- Ch. 19 — Label propagation (pp. 105–109)
- Ch. 20 — Scaling up GNNs (pp. 109–114)
read first Huang, He, Singh, Lim, Benson — Combining Label Propagation and Simple Models Out-performs Graph Neural Networks (ICLR 2021)
- Read: §2 (the correct and smooth steps, the two scaling variants), the OGB tables, and the discussion of why errors are correlated along edges.
scaling Chiang et al. — Cluster-GCN (KDD 2019) · Wu et al. — Simplifying Graph Convolutional Networks (ICML 2019)
- Cluster-GCN: §3 (why vanilla mini-batch SGD is expensive for GCN; the multiple-cluster trick). SGC: §2–3 (collapsing layers; the spectral low-pass-filter view).
sampling Hamilton, Ying, Leskovec — Inductive Representation Learning on Large Graphs (GraphSAGE, NeurIPS 2017) · Ying et al. — PinSAGE (KDD 2018)
- GraphSAGE Algorithm 2 is neighbour sampling; PinSAGE shows random-walk-based neighbour importance at Pinterest scale.
labels as input Shi et al. — Masked Label Prediction: Unified Message Passing Model for Semi-Supervised Classification (UniMP, IJCAI 2021)
- The masking strategy and why it prevents label leakage.
classics Shervashidze et al. — Weisfeiler–Lehman Graph Kernels (JMLR 2011) · Liben-Nowell & Kleinberg — The Link-Prediction Problem for Social Networks (2007) · Zhu, Ghahramani, Lafferty — harmonic functions (ICML 2003)
- Liben-Nowell & Kleinberg is the systematic comparison of Jaccard, Adamic–Adar, Katz and others on co-authorship networks: real SNA data.
Self-check
Common neighbours, Jaccard and Adamic–Adar all fail for a pair of nodes that …
- are both hubs
- are already linked
- share no neighbour
- have different degrees
They only look at shared neighbours; the Katz index counts longer walks.
The WL kernel's main advantage over the graphlet kernel is …
- it uses node features
- each refinement round is linear in the number of edges
- it distinguishes all non-isomorphic graphs
- it is not positive semi-definite
Graphlet counting is \(O(n^k)\); WL colour refinement is \(O(|E|)\) per round. It does not separate all graphs (6-cycle vs two triangles).
In Correct & Smooth, the "correct" step diffuses …
- node features
- the base model's weights
- the true labels
- the base model's errors on labelled nodes
Errors are correlated along edges; spreading them fixes neighbours of mispredicted nodes.
Neighbour sampling's cost for \(M\) targets, \(K\) layers and fan-out \(H\) is …
- \(M\cdot H^K\)
- \(K\cdot M\cdot D_{\text{avg}}\)
- \(2K|E|\)
- \(M\cdot K\cdot H\)
Each layer multiplies the computational graph by \(H\). Option 2 is Cluster-GCN.
Why does Simplified GCN work well despite being linear?
- ReLU was never needed in deep learning
- It uses many more parameters
- Homophily: averaged neighbourhood features already separate the classes
- It learns the node embeddings
On homophilous graphs \(\tilde A^KX\) makes same-class regions look alike.
Flashcards (click to flip)
History & the bigger picture
- 1934–1950s — sociometry and centrality. Moreno drew the first "sociograms" of who-likes-whom; Bavelas (1950) studied closeness in communication groups; Katz (1953) proposed his status index from walk counts.
- 1954 — "homophily" is named by Lazarsfeld and Merton; McPherson, Smith-Lovin and Cook's 2001 review "Birds of a Feather" made it a pillar of network science.
- 1968 — Weisfeiler–Lehman colour refinement for graph isomorphism. 1977 — Freeman's betweenness, from sociology. 2003 — Adamic–Adar; Liben-Nowell & Kleinberg frame link prediction.
- 2002–2004 — label propagation (Zhu & Ghahramani; Zhou et al.'s label spreading). 2007 — Pržulj's graphlet degree vectors in biology. 2009–2011 — graphlet and WL kernels (Shervashidze, Borgwardt).
- 2017–2019 — scaling GNNs: GraphSAGE (sampling), PinSAGE (3 billion nodes at Pinterest), Cluster-GCN, SGC, GraphSAINT. 2020 — C&S and UniMP top the Open Graph Benchmark with label-aware tricks.
Most of the methods on this page are sociology's ideas (centrality, homophily, communities) turned into engineering. The scaling chapter shows the other direction: GraphSAGE and PinSAGE came out of a Stanford–Pinterest collaboration, and graphs of \(10^9\) users exist only inside a few platforms. This creates an asymmetry that philosophers of technology have noted for data-driven science in general: the questions that can be asked about social behaviour at scale are shaped by who owns the data and the GPUs. The C&S and SGC results are a counterpoint: simple, cheap, interpretable diffusion often does almost as well, which makes careful baselines a matter of scientific honesty and of access, not just efficiency.
Classic SNA bridge
| In this lecture | Classic SNA counterpart | What carried over, what changed |
|---|---|---|
| Node features: degree, centralities, clustering, graphlets | Freeman (1979) centrality; Katz (1953); the triad census; graphlet degree vectors (Pržulj 2007) | This page is SNA. The only change is that the features feed a classifier instead of a table, and that GNNs provably cannot compute some of them (triangles beyond WL), so they remain useful inputs. |
| Label propagation | Contagion and social influence models; DeGroot; "network autocorrelation" | Spreading labels along edges is a social-influence model used as a classifier. Its success is evidence of homophily, not of influence (Shalizi–Thomas). |
| Correct & Smooth | Residual diffusion in spatial statistics; kriging of residuals | Spreading the base predictor's errors along the graph is spatial-residual smoothing on a network. Geographers did it on maps; C&S does it on graphs with a learned base model. |
| Katz index for link prediction | Katz status (1953); Liben-Nowell & Kleinberg (2003) compared common neighbours, Adamic–Adar, Katz on co-authorship | The classic link-prediction study is the direct ancestor of every GNN link predictor; its features are still the baselines a 2026 reviewer asks for. |
| Cluster-GCN on Louvain communities | Community detection as a first step of analysis; block-diagonal approximations of the sociomatrix (blockmodels) | Training inside communities and dropping between-community edges is a blockmodel approximation. SNA knew the between-block edges are often the interesting ones (weak ties); Cluster-GCN sacrifices them for speed. |
On retweet, reply and quote graphs from the same event, compute edge homophily for stance labels, then run label propagation, C&S and a GCN on each. Plot accuracy against homophily per relation type. The expected picture (diffusion wins where homophily is high, learned features where it is low) becomes a measured curve, and a cheap, publishable sanity step for every later model you build.
Go deeper in the SNA course. The twelve-unit course on social network analysis in this repository gives the classic side of this lecture in full, with labs and real-data analyses: Unit 1 · Ties, triads & the roots of SNA (common neighbours, Adamic–Adar and Katz as classic link predictors); Unit 2 · Homophily, balance & brokerage (label propagation: homophily used directly, with no learning); Unit 3 · Centrality & link analysis (centralities as hand-made node features, and the Katz index); Unit 5 · Heavy tails & the scale-free debate (neighbour sampling: scaling GNNs when a few hubs own most of the edges); Unit 6 · Communities & statistical network models (Louvain, modularity and label propagation as baselines); Unit 8 · Epidemics & opinion dynamics (label propagation and Correct & Smooth: opinion dynamics as a classifier); Unit 11 · Polarization, algorithms & misinformation (hand-made features and label propagation: the baselines a detector has to beat).
Connecting to your research
Running project. Section L20 · label propagation of notebooks/project/retweet_thread.py applies this lecture to one synthetic X world with coordinated rings, the same graph across the whole course.
Research extension. experiments/motif-signatures (hypotheses written before running): label propagation from 3 known ring members works best on a synchronised co-retweet graph in stealthy worlds (0.96 and 0.76 vs 0.91 and 0.58 on the plain graph): homophily needs reach.
- Label propagation on X/Twitter. Stance, ideology or bot labels for a few seed accounts can be spread through retweet or follow graphs. Retweet graphs are strongly homophilous (echo chambers), so LP and C&S are strong baselines; reply/quote graphs are often heterophilous (people argue with the other side), where they fail. Measuring edge homophily per relation type before choosing a model is a cheap, publishable sanity step.
- Homophily vs influence. Shalizi & Thomas (2011) showed the two are generically confounded in observational network data. A GNN that "works" because of homophily tells you nothing about influence; keep the causal question separate from the prediction question.
- Interpretable features as symbolic knowledge. Centralities, clustering and graphlet counts are human-readable. Concatenating them with GNN embeddings, or using them as the vocabulary for rule learners, is a simple neuro-symbolic hybrid; GNNs provably cannot count some graphlets (triangles beyond WL), so the hand-made counts add real information.
- Scale. For millions of accounts, Cluster-GCN with Louvain communities is natural (you already compute communities in SNA), and SGC lets you precompute \(\tilde A^KX\) once and run many cheap experiments.
From the experiments: results and datasets
Generated by scripts/sync_guides.py from the experiments' committed results and the dataset catalogue; rerun it (make sync-guides) after an experiment changes.
motif-signatures
Question. Which small patterns give rings away, and does timing help? experiment folder ↗
Verdicts (hypotheses written before running): H1 refuted, H2 supported, H3 refuted, H4 refuted.
Datasets for this session
From the repo's catalogue (gl.datasets; the full list with sources and licences is in data/README.md). Load one with gl.datasets.graph(name), temporal(name) or node_data(name).
| name | dataset | nodes | ground truth | good for |
|---|---|---|---|---|
florentine | Florentine families | 15 | — | centrality: why the Medici won (betweenness) |
football | NCAA college football 2000 | 115 | conference (12) | community detection with ground truth; node embeddings recover conferences |
polbooks | Books about US politics | 105 | leaning: liberal / neutral / conservative | co-purchase echo chambers, label propagation |
polblogs | US political blogs 2004 | 1,490 | leaning: liberal / conservative | polarisation, homophily, the classic SBM / spectral benchmark |
email-eu-core | EU research institution e-mail | 1,005 | department (42) | community detection and node classification with ground truth |
twitch-en | Twitch users, England (mature content) | 7,126 | streams mature content (2) | a heterophilous social task; also DE, ES, FR, PTBR, RU for shift |
lastfm-asia | LastFM Asia friendships | 7,624 | country (18) | a homophilous social task |
deezer-europe | Deezer Europe friendships | 28,281 | gender (2) | a hard heterophilous social task |
Frontier 2025–26: what changed since the slides
Frontiers · homophily is hidden inside a dozen methods · one operator links five literatures · shrinking a graph
Words & phrases
| Term | Simple meaning | Persian | In context |
|---|---|---|---|
| homophilyn. | the tendency of people to connect with people similar to them | همسانگرایی (تمایل به پیوند با هممانندها) | "Because of homophily, neighbours tend to share labels" |
| gatekeepern. | someone who controls who or what can pass from one place to another | دروازهبان؛ واسطهٔ کنترلکننده | "a node is important if it is a gatekeeper" |
| model-agnosticadj. | works with any model; does not depend on how the model is built | مستقل از مدل | "C&S is model-agnostic" |
| corruptv. | to damage data on purpose, e.g. hide or change some values | مخدوش کردن؛ خراب کردن | "corrupt the observed labels by masking" |
| prunev. | to cut away parts that are not needed (like cutting branches of a tree) | هرس کردن | "prune the rest of the neighbours" |
| centralityn. | a score of how important or central a node is | مرکزیت | "betweenness centrality" |
| clustering coefficientn. | the fraction of a node's neighbour pairs that are themselves linked | ضریب خوشهبندی | "a high clustering coefficient" |
| label propagationn. | spreading known labels along edges until they settle | انتشار برچسب | "label propagation alone reaches 0.71" |
| graph kerneln. | a similarity function between graphs, used with SVMs | هسته گراف | "the Weisfeiler–Lehman graph kernel" |
Go deeper
- Next: Bonus B — geometric GNNs, subgraph matching and motifs, and explainability.
- Expressivity link: the WL kernel here is the same algorithm as the WL test in the GNN theory lectures (6–7): GIN is a learnable WL kernel.
- Beyond homophily: Zhu et al. (2020) "Beyond Homophily in Graph Neural Networks" (H2GCN, arXiv:2006.11468) — design choices for heterophilous graphs.
- Scaling, later: GraphSAINT (subgraph sampling with unbiased normalisation, arXiv:1907.04931) and GNNAutoScale (historical embeddings for dropped neighbours, arXiv:2106.05609).
- Open question: is there a principled way to choose between "diffuse labels" and "learn features" for a given graph, from measurable statistics such as edge homophily and feature informativeness?