Message passing is permutation-equivariant, and no amount of it can distinguish graphs that the 1-WL test cannot.
Each node repeatedly summarises its neighbours. After k rounds it knows its k-hop neighbourhood, and after many rounds it knows only the average.
How this chapter is built
M3Load-bearing
The content is mathematics. Understanding is demonstrated by computation, not recall.
basics11/11what the words mean
concept2/2what to picture
theory4/4why it works, and when it does not
mathematics15/15derive it, then compute it
practice9/9build it, break it, read the papers
Five strands, not one. Mathematics is the spine; the other four are the body. A chapter cannot pay its way out of teaching with problems, nor out of problems with teaching.
Grids and sequences are graphs with a fixed, regular neighbourhood. Molecules, interaction networks and citation graphs are not, and their nodes have no natural order. Generalising convolution to an arbitrary neighbourhood is the last piece of neural machinery Elementa needs. We build the layer from the one constraint a graph imposes, that numbering the nodes means nothing; derive the graph convolution and what it cannot represent; show that repeating it averages every node into the same vector; and prove a limit on what any such network can tell apart.
Fig. 14 — One round of message passing at node 3 of a four-node graph. The neighbours' states are summed, so their order cannot matter, and the same rule runs at every node. Renumbering the nodes renumbers the outputs and changes nothing else.
What this chapter covers
Node features, adjacency and what a relabelling does to them
Permutation equivariance of layers and invariance of readouts
Message passing: messages, aggregators, updates
Receptive fields on a graph: k layers see k hops
The graph Laplacian, spectral filters and the graph convolution
Why a graph convolution cannot tell its neighbours apart
Over-smoothing: repeated averaging and the second eigenvalue
Colour refinement and the limit it sets on message passing
Sum, mean and max aggregators, and which can count
Sparse computation, batching graphs and neighbour sampling
Apparatus
The mathematics this chapter leans on, held in Book 0 so it can be assumed here without being taught here. Not a gate — follow a link when a step stops making sense.
XA batch of token representations, T×d, rows are tokens
λA regularisation coefficient, or an eigenvalue where the context is linear algebra
dModel width
σThe logistic function, or a standard deviation
∇Gradient operator
ℒThe loss
Definitions
Definition 1Node features
A matrix X with one row per node and one column per feature, n by d. Together with the adjacency matrix A it is the whole input. The order of its rows is a labelling, not information.
Definition 2Relabelling
A permutation of the node numbers, written as a permutation matrix P. It sends A to P A P^T and X to P X, and describes the same graph with the same features.
Definition 3Permutation equivariance and invariance
A layer f is equivariant if f(P A P^T, P X) = P f(A, X) for every permutation: relabelling the input relabels the output. A readout r is invariant if r(P A P^T, P X) = r(A, X): relabelling changes nothing.
Definition 4Message passing
A layer in which every node computes a message from each neighbour, combines the messages with a permutation-invariant aggregator, and updates its own state from the result and its previous state. The same functions are used at every node.
Definition 5Aggregator
The function that combines a node's incoming messages: sum, mean, max, or a weighted sum such as attention. It must not depend on the order of the neighbours, so it acts on a multiset.
Definition 6Node embedding
A node's state after the last layer, a vector that depends on the node's features and on its neighbourhood up to as many hops as there are layers.
Definition 7Readout
A permutation-invariant function of all node states that produces one vector per graph, usually their sum or mean, used for predictions about whole graphs.
Definition 8Graph Laplacian
L = D - A, with D the diagonal matrix of degrees. Its quadratic form x^T L x is the sum over edges of (x_u - x_v)^2, so small values mean a signal that varies little across edges. The normalised form is I - D^(-1/2) A D^(-1/2).
Definition 9Graph convolution
The layer H' = sigma(A-hat H W) of Kipf and Welling, with A-hat = D-tilde^(-1/2) (A + I) D-tilde^(-1/2) and D-tilde the degrees counted with self-loops. Every node takes a degree-weighted average of itself and its neighbours, then all nodes share W.
Definition 10Over-smoothing
The convergence of node states towards a common direction as averaging layers are stacked. The nodes become indistinguishable except for a factor set by their degrees.
Definition 11Colour refinement (1-WL)
The Weisfeiler-Lehman test: give every node the same colour, then repeatedly recolour each node by its own colour and the multiset of its neighbours' colours. Two graphs whose colour counts differ at some round are not isomorphic; equal counts prove nothing.
Formal results
I.14.T1
Message passing with an invariant aggregator is permutation-equivariant
If every node applies the same message, aggregation and update functions, and the aggregator depends only on the multiset of incoming messages, then relabelling the nodes by P sends the layer's output H to P H. A readout that sums or averages over nodes is then permutation-invariant, and so is any composition of such layers followed by it.
What this does not promise
Equivariance is a restriction as well as a guarantee: a node cannot tell its neighbours apart, so no layer of this kind computes a directional difference. Nor does it promise that structurally different nodes receive different states; I.14.T4 bounds that.
I.14.T2
k layers see k hops
After k message-passing layers, a node's state depends only on the features and edges within distance k of it. In matrix form, the entry of A^k for nodes v and u counts walks of length k between them, and is zero when they are more than k apart.
What this does not promise
Possible dependence is not effective dependence. A node k hops away may influence the state by a negligible amount, and a fixed-width state must summarise a neighbourhood that can grow exponentially with k.
I.14.T3
The graph convolution's averaging converges at the rate of its second eigenvalue
For a connected graph, A-hat = D-tilde^(-1/2) (A + I) D-tilde^(-1/2) has eigenvalue 1 once, with unit eigenvector u proportional to the square roots of the degrees with self-loops, and every other eigenvalue strictly between -1 and 1. Hence A-hat^k x tends to u (u^T x), and the distance to that limit is at most |lambda_2|^k times the starting distance, where |lambda_2| is the largest other eigenvalue in absolute value.
What this does not promise
This is the linear part only. Learned weights and nonlinearities change the rate, and residual connections or normalisation can prevent the collapse. Without self-loops a bipartite graph has eigenvalue -1 and the iteration oscillates instead. A disconnected graph converges separately on each component.
I.14.T4
Message passing is no more discriminating than colour refinement
If colour refinement gives two graphs the same colour counts at every round, then every message-passing network started from identical node features gives them the same multiset of node states at every layer, and so the same readout. With a sum aggregator and injective update functions a message-passing network separates every pair that colour refinement separates. Mean and max aggregators are strictly weaker.
What this does not promise
Matching colour refinement in principle does not mean a trained network does. Distinct node features break the ties the theorem assumes. Colour refinement separates almost all graphs drawn at random, and fails on regular graphs such as two triangles against a hexagon.
Assumptions
Each is paired with the problem that shows what its removal costs. An assumption nobody tests is a disclaimer.
The aggregator is invariant to the order of the neighbours. A layer that reads neighbours in index order depends on the labelling.I.14.X02
The graph is connected and has self-loops when convergence is claimed. Without self-loops a bipartite graph oscillates.I.14.X05
Graphs batched together are offset so that their edges stay within their own blocks.I.14.B05
Node features, or extra structural features, break the symmetries that colour refinement cannot.I.14.B03
The dependencies the task needs lie within as many hops as there are layers.I.14.X07
Where counting matters, the aggregator is injective on multisets, as a sum is and a mean or a max is not.I.14.X03
Stacking averaging layers. On the four-node paw graph the distance of the state from its limit falls from 2.516217 to 0.244093 after four rounds and to 0.000255 after sixteen; after ten the four nodes differ by less than one per cent.
A mean or max aggregator where counts matter. The centres of stars with two and four leaves receive the same mean, 1, from constant features; the multisets {1, 1, 2, 2} and {1, 2} have the same mean and the same maximum.
Merging nodes with the same closed neighbourhood. One graph convolution gives nodes 1 and 2 of the paw graph the same output, 1.866025, although their features are 1 and 2.
Batching graphs without offsetting their edge lists. Three graphs of sizes 4, 3 and 5 should read out 8, 4 and 10 after one summed round; without offsets they read out 10, 2 and 0.
Omitting self-loops on a bipartite graph. On a hexagon the normalised adjacency has eigenvalue -1, and the alternating signal flips sign at every layer instead of converging.
Expecting message passing to separate regular graphs. Two triangles and a hexagon get identical outputs from every message-passing network with identical starting features, though one has two triangles and the other none.
Using a dense adjacency matrix. For a million nodes and ten million edges it needs 4e12 bytes and 1.28e14 multiply-accumulates per layer of width 128; an edge list needs 3.2e8 bytes and 1.89e10.
Too few layers for the task. Node 1 of a four-node path and of a five-node path has the same state after two layers, 0.892956, and the two differ only from the third.
Ignoring neighbourhood growth. With average degree 20, a three-layer network's prediction for one node can depend on up to 8,000 nodes; sampling 25 and then 10 neighbours bounds two layers at 250.
Feeding Laplacian eigenvectors as positions without handling their ambiguity. Each eigenvector is defined only up to sign, and the eigenvalue 3 of two triangles has multiplicity four, with no preferred basis.
The Graph Neural Network ModelScarselli, Gori, Tsoi, Hagenbuchner and Monfardini, 2009 · IEEE Transactions on Neural Networks 20(1)