GIN: Graph Isomorphism Network, The Most Expressive GNN
Published:

Why Expressiveness Matters
Two different graphs that a GNN represents identically are indistinguishable by that model, it can’t learn to predict different outputs for them. The more graphs a GNN can distinguish, the more powerful it is.
A concrete failure of mean aggregation:
The Weisfeiler-Leman Test
The 1-WL test (also called colour refinement) is a classical algorithm for distinguishing graphs. Write \(c^{(k)}_v\) for the colour of node \(v\) at round \(k\), starting from \(c^{(0)}_v\) = the node’s label. Each round it applies
where \(\{\!\{\cdot\}\!\}\) denotes a multiset (a set that keeps repetitions) and \(\operatorname{HASH}\) is injective. The algorithm terminates when the partition of nodes into colours stops changing. If two graphs end with different colour histograms they are certainly not isomorphic; if the histograms match, the test is inconclusive, 1-WL is a one-sided test, and it famously fails on pairs of regular graphs such as a 6-cycle versus two disjoint triangles.
Compare that update with the MPNN loop: a GNN is running exactly this algorithm with learned functions in place of \(\operatorname{HASH}\). Xu et al. (2019) proved:
For a GNN to match 1-WL, its aggregation must be an injective multiset function: different multisets of neighbour features must produce different outputs, exactly as \(\operatorname{HASH}\) does. The enabling lemma is:
In other words sum aggregation can be made injective, mean and max cannot:
- Mean cannot distinguish multisets with the same distribution of elements but different sizes: \(\operatorname{mean}(\{\!\{A, A, A, A\}\!\}) = \operatorname{mean}(\{\!\{A, A\}\!\})\) (see the figure above).
- Max only sees the set of distinct elements, so it is blind to every multiplicity: \(\max(\{\!\{A, A, B\}\!\}) = \max(\{\!\{A, B\}\!\})\).
- Sum preserves both the size of the multiset and its contents.
The GIN Layer
Two components:
- \(\epsilon^{(k)} \in \mathbb{R}\), a scalar, either learned by gradient descent or fixed at \(0\) (the variant the paper calls GIN-0). It weights the centre node’s own representation separately from the neighbour sum, so that the pair \(\big(h_v, \{\!\{h_u\}\!\}\big)\) is recoverable, the analogue of the first argument of \(\operatorname{HASH}\).
- \(\operatorname{MLP}^{(k)}\), a multi-layer perceptron applied after summing. This is what realises the injective \(f\) (and the outer function composed with it) from the lemma above. It is crucial: a single linear layer, as in GCN, cannot represent the required injective mappings, whereas an MLP with at least one hidden layer is a universal approximator.
Comparison
| Model | Aggregator | Update | 1-WL power |
|---|---|---|---|
| GCN | Degree-normalised sum (mean-like) | Linear + ReLU | \(<\) 1-WL |
| GAT | Attention-weighted sum | Linear + ReLU | \(<\) 1-WL |
| GraphSAGE | Mean or max-pool | Linear + ReLU | \(<\) 1-WL |
| GIN | Sum | MLP | \(=\) 1-WL |
GIN is the only architecture in this list that reaches the 1-WL bound. Note this is a statement about worst-case distinguishing power, not about accuracy: a less expressive model can still win on a given dataset.
GIN for Graph Classification
For graph-level tasks, GIN uses a readout that concatenates the sum-pooled representations from all layers, not just the final one:
where \(\Vert\) is concatenation over the layer index \(k\) and \(V\) is the node set. Sum pooling is used here for the same reason as inside the layer, it is the injective choice. Using representations from all layers captures both fine-grained (early layers) and coarse (late layers) structural information.
✅ Key Takeaways
- Message-passing GNNs are bounded in expressiveness by the 1-dimensional Weisfeiler-Leman test; two graphs 1-WL cannot separate, no MPNN can separate.
- GIN reaches that bound using sum aggregation + an MLP update, because sum is the aggregator that can be made injective over multisets.
- Mean and max aggregation are provably less expressive, mean loses the multiset size, max loses all multiplicities.
- The \(\epsilon^{(k)}\) parameter lets GIN weight the centre node differently from the sum over its neighbours.
- 1-WL is itself only a one-sided test, so matching it is a ceiling, not a guarantee of distinguishing every pair of non-isomorphic graphs.
