How powerful can a message-passing GNN be? Xu, Hu, Leskovec and Jegelka (ICLR 2019) proved that no message-passing GNN can distinguish more graphs than the 1-dimensional Weisfeiler–Lehman (WL) isomorphism test. They also showed that summing neighbour features and passing the result through an MLP reaches that limit. The resulting Graph Isomorphism Network (GIN) uses h' = MLP((1 + ε)h + Σ neighbours). Mean and max aggregation are strictly weaker, because they cannot count. This page covers the WL test, injective multiset functions and the expressiveness hierarchy. In the exercises you implement WL refinement and a GIN layer, then embed all 34 non-isomorphic 5-node graphs from constant features. Sum aggregation separated all 34, matching WL, while mean and max separated only 5. Like WL, GIN could not tell a hexagon from two triangles.
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.
Counting matters
To tell two graphs apart, a GNN has to notice differences in how nodes are connected. An old test does this by repeatedly giving each node a colour based on its own colour and the colours of its neighbours. GIN copies that recipe exactly by adding up neighbour features, so it can count how many neighbours of each kind a node has. Averaging or taking the maximum loses those counts. The demo runs the colour-refinement test on a small graph.
Graph neural network lab
Distinct colours after each iteration: 1 → 3 → 5. WL refines colours by neighbour multisets; GIN is exactly as powerful as this test.
Why engineers care
For molecules, circuits and mechanical assemblies, telling structures apart is the whole task. GIN is a strong default for graph-level classification and regression.
📝 Quick check (Level 0)
0/3 answered
1. GIN aggregates neighbours by…
2. Summing lets a node…
3. GIN is as powerful as…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.
By hand
WL refinement: start with equal colours. Repeatedly set colour(i) ← hash(colour(i), multiset of neighbour colours). Two graphs with different colour histograms are certainly not isomorphic.
Multiset functions:
sum separates the multisets (1, 1) and (1, 1, 1);
mean gives 1 for both;
max cannot tell (1, 2) from (1, 2, 2).
GIN layer: h_i’ = MLP((1 + ε) h_i + Σ_(j ∈ N(i)) h_j). On a 4-node path with all features 1, the aggregate is 2 at the ends and 3 in the middle.
Graph readout: sum the node embeddings of every layer and concatenate them.
Counts: there are 2^10 = 1024 labelled graphs on 5 nodes but only 34 up to isomorphism.
📝 Quick check (Level 1)
0/3 answered
1. Which aggregation separates {1, 1} from {1, 1, 1}?
2. GIN aggregate for h = 1 with three neighbours of value 1 (ε = 0):
3. Labelled graphs on 5 nodes:
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.
GIN in code
Exercise 1.
One WL step on a 4-node path gave the ends one colour and the middle nodes another.
Sum separated multisets that mean and max merged.
A GIN layer counted neighbours.
Practice.
In PyTorch Geometric, use GINConv(nn.Sequential(Linear, BatchNorm, ReLU, Linear), train_eps=True) with sum pooling over layers (global_add_pool).
On molecules, add bond features (GINEConv).
If node features are absent, use constant or degree features. Positional or random features can push beyond 1-WL.
from torch_geometric.nn import GINConv, global_add_poolmlp = nn.Sequential(nn.Linear(d, 64), nn.BatchNorm1d(64), nn.ReLU(), nn.Linear(64, 64))conv = GINConv(mlp, train_eps=True)h = conv(x, edge_index); g = global_add_pool(h, batch) # sum readout keeps counts
🐍 Exercise 1: WL and GIN
Implement one WL refinement step, compare multiset aggregators, and write a GIN layer.
📝 Quick check (Level 2)
0/3 answered
1. PyG GIN layer with edge features:
2. GIN's graph readout uses…
3. To exceed 1-WL, add…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.
Theory
Upper bound.
Any message-passing GNN computes node states from the node’s state and the multiset of neighbour states, exactly the information WL uses.
By induction over layers, if WL gives two graphs the same colour histogram, so does every message-passing GNN (Xu and colleagues; Morris and colleagues, 2019).
Achieving it.
If the aggregate-and-update function is injective on multisets, the GNN matches WL.
Sums of a suitable feature map are injective on bounded multisets, and an MLP can approximate that feature map. Hence GIN, with sum aggregation and an MLP update, is as powerful as WL.
Mean (distributions only) and max (sets only) are not injective and are strictly weaker.
Beyond WL.
WL fails on regular graphs of the same size and degree, such as a 6-cycle versus two triangles, and so does every message-passing GNN.
Higher-order GNNs (k-WL), subgraph GNNs, and positional or structural encodings (Laplacian eigenvectors, random features) break this limit.
📝 Quick check (Level 3)
0/3 answered
1. Message-passing GNNs are at most as powerful as…
2. Mean aggregation captures…
3. WL fails to separate…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.
How many graphs can each aggregator tell apart?
History.
B. Weisfeiler and A. Leman (1968) introduced colour refinement.
K. Xu, W. Hu, J. Leskovec and S. Jegelka, “How powerful are graph neural networks?” (ICLR 2019).
C. Morris et al., “Weisfeiler and Leman go neural” (AAAI 2019), introduced higher-order GNNs.
Exercise 2.
Graphs: all 34 non-isomorphic graphs on 5 nodes.
Embeddings: a 4-layer GNN with a random 2-layer MLP update, constant input features and sum readout, using sum, mean or max neighbour aggregation.
Count: distinct graph embeddings for each aggregator, compared with the classes WL separates. A hexagon versus two triangles is tested as well.
method
graphs separated (of 34)
1-WL test
34
sum aggregation (GIN)
34
mean aggregation
5
max aggregation
5
Hexagon versus two triangles: WL gives them the same colours, and the sum GNN gives identical embeddings.
Sum aggregation matches WL: every one of the 34 graphs got its own embedding, even with random, untrained weights. Injectivity does the work.
Mean and max are almost blind here: with constant features, every neighbour looks the same, so the mean or max of neighbours is just “1 if the node has any neighbours.” The only thing left is the number of isolated nodes (0, 1, 2, 3 or 5), hence 5 classes.
The WL ceiling is real: a hexagon and two triangles (both 2-regular on 6 nodes) are indistinguishable to WL and to GIN alike.
Robust to the random weights: seeds 1 and 2 gave the same counts (34, 5, 5).
🐍 Exercise 2 (research): how many graphs can each aggregator tell apart?
Embed all 34 five-node graphs with sum, mean and max aggregation and compare with the WL test.
GIN in AI, robotics and aerospace
Molecules and materials: property prediction for fuels, propellants and coatings, where small structural differences matter.
Circuits and assemblies: classifying netlists and CAD assembly graphs.
Design lesson: if counts of neighbours matter for your task, use sum aggregation. Check whether your task needs to go beyond WL, for example to tell regular structures apart.
References
K. Xu, W. Hu, J. Leskovec and S. Jegelka (2019). “How powerful are graph neural networks?” ICLR.
C. Morris et al. (2019). “Weisfeiler and Leman go neural: higher-order graph neural networks.” Proc. AAAI.
B. Weisfeiler and A. Leman (1968). “The reduction of a graph to canonical form and the algebra which appears therein.” NTI 2.
From constant features, sum separated all 34 five-node graphs; mean and max separated only 5.
Practice
Show:
Level 0
Problem 1Level 0
Year GIN appeared at ICLR?
2019.
Problem 2Level 0
Non-isomorphic graphs on 5 nodes?
34.
Problem 3Level 0
GIN aggregate for h = 1 with three neighbours of value 1 (ε = 0)?
4.
Level 1
Problem 4Level 1
Labelled graphs on 5 nodes?
1024.
Problem 5Level 1
Labelled graphs on 3 nodes?
8.
Problem 6Level 1
gin_update(2, [], eps = 0.5)?
1.5·2 = 3.
Problem 7Level 1
Degree sum of a 2-regular graph on 6 nodes?
12.
Level 2
Problem 8Level 2
Graphs separated by sum aggregation in exercise 2?
34.
Problem 9Level 2
Graphs separated by mean aggregation?
5.
Problem 10Level 2
Possible numbers of isolated nodes in a 5-node graph (how many values)?
0, 1, 2, 3, 5: 5.
Problem 11Level 2
WL classes for a hexagon and two triangles?
1.
Problem 12Level 2
Max of the multiset (1, 2, 2)?
2.
Problem 13Level 2
GIN aggregate of a middle node on a 4-node path with all features 1?
1 + 2 = 3.
Level 3
Problem 14Level 3
Prove that a message-passing GNN cannot separate graphs that WL does not.
By induction on layers: initially all nodes have equal states and colours. Suppose after layer t, nodes with equal WL colours have equal GNN states. A node’s state at t + 1 is a function of its state and the multiset of neighbour states, which are determined by its WL colour and neighbour-colour multiset, i.e. its colour at t + 1. So equal colours imply equal states at every layer; equal colour histograms then give equal (permutation-invariant) readouts. ∎
Problem 15Level 3
Explain why mean and max separated exactly 5 graphs.
With constant features, every neighbour has the same state, so the mean or max of a non-empty neighbourhood is that state and an isolated node gets zero. After every layer, nodes are of only two types: isolated or not. The sum readout then depends only on how many nodes are isolated, which can be 0, 1, 2, 3 or 5. ∎
Problem 16Level 3
Compare GIN with GCN.
GCN uses degree-normalised averaging (mean-like), which cannot count and is weaker than WL, but it is a good low-pass filter for node classification with homophily. GIN uses sum aggregation with an MLP, matching WL, and suits graph-level tasks where structure must be distinguished (molecules). ∎
Problem 17Level 3
Advise on a model to classify CAD assembly graphs.
Use GIN (or GINE with edge features such as joint types) with sum pooling over layers, and node features from part attributes. If assemblies contain symmetric or regular substructures that must be distinguished, add positional encodings or subgraph counts. Validate on held-out assemblies, and check that near-identical structures get different predictions when they should. ∎
Level 4
Problem 18Level 4
Graphs separated by max aggregation?
5.
Problem 19Level 4
Number of message-passing layers used in exercise 2?
4.
Problem 20Level 4
Year of Weisfeiler and Leman’s paper?
1968.
Coding practice
🐍 Code 1 (Level 0): labelled graphs
2^(n choose 2).
🐍 Code 2 (Level 0): GIN update
(1 + ε)h + Σ neighbours.
🐍 Code 3 (Level 0): isolated counts
Possible values.
🐍 Code 4 (Level 0): mean
Average.
🐍 Code 5 (Level 0): regular degree sum
n·d.
Topic test
A timed test drawn at random from this topic's question bank. Each attempt gets new questions. For a longer test across the whole chapter, see the chapter test, or mix topics in the question bag.
Graph Isomorphism Network (GIN): topic test
10 questions, drawn at random from a bank of 21. Every attempt is different.
⏱ Time limit: 15 minutes. The test submits itself when time runs out.
Levels covered: 0, 1, 2, 3, 4. No hints or solutions until you submit.