Machine Learning

Graph Neural Networks Explained: Message Passing and Where GNNs Fit

How graph neural networks learn from nodes and edges through message passing, the main architectures, their known limits, and where GNNs are used in practice today.

By Institute for Joint Cognition & AI · 5 min · 24 November 2026

A network of glowing nodes connected by thin lines of light against a dark background, with pulses travelling along the connections

Most deep learning architectures assume a fixed structure in their input. Convolutional networks expect a grid of pixels; sequence models expect an ordered list of tokens. A great deal of real data has neither. Molecules are atoms joined by bonds, social and payment networks are accounts joined by interactions, road systems are junctions joined by streets. Graph neural networks (GNNs) are the class of models built to learn directly from that kind of structure, and their core mechanism, message passing, is simple enough to state in a paragraph.

The message-passing framework

A graph has nodes, edges between them, and optionally features on both. A GNN maintains a vector representation for each node and updates it in rounds, usually called layers. In each layer, every node:

  1. Collects messages from its neighbours, where each message is a function of the neighbour’s current representation and, optionally, the features of the connecting edge.
  2. Aggregates those messages with a permutation-invariant function such as sum, mean or max, so that the result does not depend on the arbitrary order in which neighbours are listed.
  3. Updates its own representation by combining the aggregate with its previous state, typically through a small neural network.

Gilmer et al. (2017) formalised this as the message passing neural network (MPNN) framework and showed that many earlier graph models were special cases of it. After k layers, a node’s representation reflects information from its k-hop neighbourhood. For tasks about the whole graph, such as predicting a molecule’s property, a final “readout” step pools all node representations into one vector.

The permutation-invariance requirement is what makes GNNs different from simply flattening a graph into a vector. A graph has no canonical node ordering, and a model whose output changed when nodes were relabelled would be learning an artefact of the data format.

The main architectures

Most widely used GNNs differ in how they weight and aggregate messages.

Graph convolutional networks

Kipf and Welling’s GCN (2016) averages neighbour representations with a normalisation based on node degrees, then applies a shared linear transform and nonlinearity. It is cheap and remains a strong baseline for semi-supervised node classification, such as labelling papers in a citation network from a few known labels.

Sampling for large graphs

GraphSAGE (Hamilton, Ying and Leskovec, 2017) samples a fixed number of neighbours per node and learns aggregation functions rather than per-node embeddings. That makes it inductive, able to embed nodes not seen during training, and practical on very large graphs. Pinterest’s PinSage, built on similar ideas, was reported to run on a graph with billions of nodes for recommendation.

Attention over neighbours

Graph attention networks (Veličković et al., 2017) learn a weight for each neighbour, so a node can attend more to some neighbours than others. The connection to transformers is direct: a transformer’s self-attention is message passing on a fully connected graph where every token is every other token’s neighbour. Our explainer on the transformer architecture covers that side.

What GNNs cannot do, and why

The message-passing view also explains the architecture’s well-documented limits.

Expressive power. Xu et al. (2018) showed that standard message-passing GNNs are at most as powerful as the Weisfeiler-Lehman graph isomorphism test at telling graphs apart. Some structurally different graphs are indistinguishable to any such GNN, for example certain regular graphs, and simple properties such as counting cycles can be out of reach. The same paper introduced the graph isomorphism network (GIN), which uses sum aggregation to reach that upper bound. Higher-order and subgraph-based GNNs go beyond it at extra computational cost.

Over-smoothing. As layers stack, repeated averaging pushes node representations towards each other until they become hard to distinguish. Deep GNNs therefore often perform worse than shallow ones without residual connections, normalisation or other countermeasures. Many practical GNNs use only a few layers.

Over-squashing. Information from an exponentially growing neighbourhood must be compressed into a fixed-size vector, which makes long-range dependencies hard to learn. Graph rewiring, virtual nodes connected to everything, and graph transformers with global attention are common responses.

Scale and irregularity. Graphs do not map neatly onto accelerator hardware. Neighbourhood sizes vary wildly, a single high-degree node can dominate memory, and mini-batching requires neighbour sampling or graph partitioning. Much engineering effort in production GNNs goes here rather than into the model.

Where GNNs fit in practice

GNNs earn their place when relationships are the signal, not just context.

  • Molecules and materials. Atoms and bonds map naturally onto nodes and edges, and GNNs are widely used to predict molecular properties and screen candidates in drug and materials discovery.
  • Recommendation. User-item interaction graphs let a model use the behaviour of similar users and related items, as in PinSage.
  • Fraud and risk. Transaction networks reveal rings of accounts that look normal in isolation. Graph features or GNNs over account-device-merchant graphs are a common approach in payment fraud detection.
  • Physical simulation and forecasting. DeepMind’s GraphCast (Lam et al., 2023) uses an encode-process-decode GNN on a multi-resolution mesh over the globe for medium-range weather forecasting, and its authors reported it outperforming a leading operational system on most of the targets they evaluated.
  • Traffic and logistics. Road networks and transit systems are graphs, and GNNs are used for travel-time estimation and demand forecasting on them.

GNNs are a poorer fit when the graph is incidental, when a strong tabular model on hand-built graph features already captures the signal, or when the relevant structure is a plain sequence or grid that existing architectures handle well. A useful practical test is to compare against a baseline that ignores edges entirely. If the GNN does not clearly beat it, the graph may not be carrying the information you assumed.

Message passing is a small idea with wide reach: wherever data is defined by what is connected to what, it gives a principled way to learn from those connections. Knowing its limits, particularly expressivity and over-smoothing, is what separates a well-chosen GNN from a fashionable one.