Graph isomorphism network

On this page 7

A graph isomorphism network (GIN) is a message passing graph neural network that sums neighbor features and passes the result through a multilayer perceptron, a design chosen so that it can distinguish graph structures as well as the Weisfeiler-Lehman graph isomorphism test. In graph learning, a field of artificial intelligence, GIN serves as the reference architecture for maximally expressive neighborhood aggregation.

GIN was introduced by Xu, Hu, Leskovec and Jegelka in 2019 in a study of how powerful graph neural networks can be. The work showed that common choices such as mean or max aggregation lose information, while an injective sum aggregator combined with an MLP reaches the theoretical upper bound for this family of models.

How a graph isomorphism network updates node features

Each GIN layer computes a new representation for every node from its own previous state and the sum of its neighbors’ states. The update for node v at layer k is h_v = MLP((1 + ε) · h_v + Σ h_u), where the sum runs over the neighbors u of v and ε is a learnable or fixed scalar.

The term (1 + ε) gives the central node a distinct weight, so the network can tell a node’s own features apart from those of its neighborhood. The MLP, usually two layers with batch normalization and ReLU, models the injective function on multisets that the theory requires; a single linear layer, as in a graph convolutional network, is not expressive enough.

ComponentTypical choicePurpose
AggregatorSum over neighborsPreserves multiset size and counts
Self weight1 + ε, ε learned or zeroSeparates node from neighborhood
Update functionTwo-layer MLPApproximates an injective mapping
NormalizationBatch normalizationStabilizes training of deep stacks
DepthAbout 3 to 5 layersSets the receptive field in hops
Components of a GIN layer

Why sum aggregation makes GIN expressive

The expressive power of a message passing network depends on whether its aggregator is injective on multisets of neighbor features. If two different neighborhoods map to the same aggregate, no later layer can recover the difference, and the model cannot distinguish the two structures.

AggregatorWhat it preservesTypical failure
SumFull multiset, including countsNone within the 1-WL bound
MeanDistribution of featuresNeighborhoods with equal proportions
MaxSet of distinct featuresRepeated features or different counts
What different aggregators can distinguish

For example, a node with two identical red neighbors and a node with four identical red neighbors look the same under mean and max, but sum aggregation separates them. Mean aggregation remains useful when the relative distribution matters more than counts, as in some node classification tasks with varying degree.

The formal result states that GIN is exactly as powerful as the 1-dimensional Weisfeiler-Lehman test: any two graphs the test separates can be mapped to different embeddings, and no message passing network of this type can do better.

Graph-level readout and variants

For graph classification, GIN builds a whole-graph representation with a readout function applied after every layer. The original design sums node embeddings at each layer and concatenates the results across layers, so the final vector combines information from different neighborhood radii, similar to the subtree features of a Weisfeiler-Lehman graph kernel.

VariantChangeWhen to use
GIN-0ε fixed at zeroDefault; often matches GIN-ε accuracy
GIN-εε learned per layerWhen node-neighbor balance matters
GINEAdds edge features to messagesMolecules with typed bonds
GIN with virtual nodeGlobal node linked to all nodesLong-range information flow
Mean-readout GINMean pooling instead of sumGraphs of very different sizes
Common GIN variants

In molecular benchmarks, the edge-aware GINE variant is a common baseline because bond types carry essential chemistry. It adds a projected edge feature to each neighbor message, often with a ReLU, before summation.

How GIN compares with other graph neural networks

GIN sits within the broader message passing neural network framework and differs from its neighbors mainly in the aggregator and update. The comparison below shows the practical trade-offs.

ModelAggregationExpressive power
GINSum plus MLPEqual to 1-WL
Graph convolutional networkDegree-normalized mean, linear updateBelow 1-WL
GraphSAGEMean, max or LSTM over samplesBelow 1-WL with mean or max
Graph attention networkAttention-weighted meanBelow 1-WL in general
Higher-order GNNsTuples or subgraphs of nodesAbove 1-WL, higher cost
GIN compared with related architectures

Expressive power is not the same as accuracy. On node classification with homophily, a graph convolutional network often matches or beats GIN, while GIN tends to shine on graph classification tasks in chemistry and social networks, where structural differences decide the label.

Limitations and practical considerations

Because it is bounded by the 1-WL test, GIN cannot distinguish certain non-isomorphic graphs, such as many pairs of regular graphs with the same degree. It also cannot reliably count cycles or triangles, which matters for molecules and some social structures.

  • Sum aggregation scales with degree, so high-degree nodes can produce very large activations without normalization.
  • Deep stacks suffer from over-smoothing and over-squashing like other message passing networks.
  • Small benchmark datasets give high variance; report results over repeated cross-validation folds.
  • Positional or structural encodings, such as random features or Laplacian eigenvectors, are common ways to exceed the 1-WL limit.

Despite these limits, GIN remains a strong and simple baseline: it trains quickly, has few hyperparameters and is implemented in major graph libraries.

Understanding it simply

A graph is a set of points joined by links, like atoms joined by bonds. A graph neural network learns by letting each point collect information from its neighbors.

A graph isomorphism network collects that information by adding it up, not by averaging it. Adding keeps track of how many neighbors there are. Averaging loses that count.

Because of this choice, the network can tell apart almost as many shapes as a well-known mathematical test for comparing graphs.

Applied in practice

A pharmaceutical research team screens about 200,000 candidate molecules for toxicity. Each molecule is represented as a graph with atoms as nodes, element and charge as node features, and bond types as edge features.

The team trains a five-layer GINE model with sum readout concatenated across layers, using a scaffold split so that test molecules have structures unseen during training. A graph convolutional network with mean aggregation serves as the baseline.

The GIN-based model improves the area under the ROC curve by roughly three points on the held-out scaffolds, mainly on molecules whose toxicity depends on repeated functional groups that mean aggregation blurs. Chemists then use the ranked predictions to remove the riskiest few percent of candidates before laboratory testing.