01 / MOTIVATIONWhy graphs need their own networks
Most successful neural networks assume a fixed, regular layout. Graphs break that assumption, and that is exactly why they need a different tool.
A convolutional network expects a grid: pixels with fixed neighbours, left, right, up, down. A recurrent or transformer model expects a sequence: a clean left-to-right order. Both lean hard on that regular structure.
An enormous amount of real data has neither. A molecule is atoms joined by bonds. A road network is intersections joined by streets. A knowledge graph is entities joined by relations. A power grid, a social network, a citation network, a fleet of components wired into subsystems: all of these are graphs, sets of nodes connected by edges, with no canonical ordering and no fixed number of neighbours.
Two properties make graphs awkward for ordinary networks, and a GNN is built to respect both:
- Permutation invariance. Relabelling the nodes must not change the answer. A molecule is the same molecule whether you number its atoms 1-to-n or shuffle them. The model must not depend on the arbitrary order.
- Variable structure. Different nodes have different numbers of neighbours, and different graphs have different numbers of nodes. The model must handle that gracefully, not assume a fixed-size input.
02 / THE CENTRAL IDEAMessage passing, in plain words
Give every node a starting vector (its features: an atom's element, a user's profile, a sensor's reading). Then repeat one simple round, called a message-passing layer, as many times as you have layers:
- Each node sends a message to its neighbours, derived from its current vector.
- Each node aggregates the messages arriving from all of its neighbours into one summary. Because neighbours have no order, this aggregation must be a function that does not care about order: a sum, a mean, or a max.
- Each node updates its own vector by combining its old vector with that aggregated summary, usually through a small learnable transform and a nonlinearity.
That is the entire mechanism. The beautiful consequence is about reach. After one layer, a node knows about its immediate neighbours. After two layers, it knows about neighbours of neighbours, because its neighbours have themselves just absorbed their neighbours. In general, after k layers, every node's vector summarises its entire k-hop neighbourhood.
03 / THE UPDATE RULEThe same idea, written down
The general message-passing form, which almost every GNN is a special case of, reads:
mv = AGGREGATEu ∈ N(v) ( MESSAGE( hv, hu, evu ) )
hv′ = UPDATE( hv, mv )
where e_vu is an optional edge feature. The two design choices that distinguish one GNN from another are simply which aggregation and which update you pick. The most cited concrete instance is the graph convolutional network (GCN), which writes the whole layer as one tidy matrix equation:
# H : stack of all node vectors (one row per node)
# W : learnable weight matrix, shared across all nodes
# Â : the normalised adjacency, Â = D^(-1/2) (A + I) D^(-1/2)
Read ·H as “replace each node's vector by a weighted average of itself and its neighbours.” The + I adds a self-loop so a node keeps some of its own signal, and the D^(-1/2) ... D^(-1/2) normalisation stops high-degree hub nodes from dominating. Multiply by W, apply a nonlinearity, and that is one GCN layer. Stack a few of them and you have a GNN.
04 / STACKING LAYERSDepth is reach
Each layer widens the horizon by one hop. This is the GNN analogue of a CNN's growing receptive field, and it is the single most useful intuition for choosing depth.
05 / THE WORKHORSESGCN, GraphSAGE, GAT, GIN
Four architectures cover most of what you will meet. They differ only in the AGGREGATE and UPDATE choices from section 03.
GCN, the convolutional baseline
A degree-normalised weighted average of neighbours, the matrix form above. Simple, fast, and a strong default for node classification. Its weakness is that it must see the whole graph at once, which limits scale.
GraphSAGE, built to scale and to generalise
Instead of using the full neighbourhood, it samples a fixed number of neighbours and learns an aggregator (mean, pooling, or LSTM-style). Sampling makes it tractable on graphs with millions of nodes, and because it learns a rule rather than memorising node positions, it can be applied inductively to nodes and graphs it never saw in training.
GAT, attention over neighbours
Not all neighbours are equally relevant. A graph attention network learns a weight per edge, letting each node decide how much to listen to each neighbour, much like attention in transformers but restricted to the graph's edges. This helps when the graph mixes informative and noisy connections.
GIN, the expressiveness benchmark
The graph isomorphism network uses a sum aggregator plus a small MLP, a choice that, in theory, makes it as discriminative as the classical Weisfeiler-Lehman graph isomorphism test, the strongest a standard message-passing GNN can be. It is the reference point when the question is “can my GNN even tell these two structures apart?”
| Model | Aggregator | Best at |
|---|---|---|
| GCN | normalised mean | simple, strong node-classification baseline |
| GraphSAGE | sampled mean / pool | large graphs, inductive (unseen nodes) |
| GAT | attention-weighted | noisy or unequal neighbours |
| GIN | sum + MLP | maximal structural expressiveness |
06 / SEE IT WORKMessage passing, live
The whole mechanism is visible in one panel. Below is a real graph with two loosely connected communities. Two seed nodes are labelled (one blue, one orange); every other node starts grey, knowing nothing. Each layer runs one genuine round of normalised neighbour aggregation (the GCN operation, computed live, not animated by hand) and you watch the labels spread outward along the edges.
The two toggles expose the most important lesson in the field. With re-inject labels on, the seeds keep their identity each round and the labels diffuse into a clean classification: this is message passing solving a semi-supervised problem. Turn it off and keep adding layers, and you see the dark side: over-smoothing. Every node's value collapses toward the same grey, the variance across nodes drops to near zero, and the network can no longer tell any two nodes apart.
Message-passing sandbox
07 / THREE LEVELSWhat you can actually predict
Once every node has a learned vector, you can ask questions at three scales. The GNN body is the same; only the head on top changes.
Node level
Classify or score individual nodes: which users are bots, which atoms are reactive sites, which components are degrading. The demo above is node classification. This is the most common GNN task and is usually done semi-supervised, labelling a few nodes and letting message passing carry that information to the rest.
Edge level
Predict whether an edge exists or what it means: recommendation (will this user like this item), knowledge-graph completion (does this relation hold), fault propagation (will a failure here reach there). You score a candidate edge from the vectors of its two endpoints.
Graph level
Summarise the whole graph into one prediction: is this molecule toxic, is this circuit faulty. Here you need a readout (also called pooling), an order-independent function, sum, mean, or max, that collapses all node vectors into a single graph vector before the final head. The order-independence requirement is the same one from section 03, now applied to the entire graph.
08 / PRACTICAL NOTESWhat actually goes wrong
GNNs are easy to wire up and have a handful of characteristic failure modes. These are where the research and the engineering pain both live.
Over-smoothing
The pitfall you just watched. Stack too many message-passing layers and every node's vector converges to the same value, because repeated averaging is a smoothing operation. The practical consequence: most GNNs peak at two to four layers. Mitigations: residual / skip connections, normalisation between layers, and designs that deliberately preserve a node's own signal.
Over-squashing
The opposite-feeling but related problem: information from an exponentially growing k-hop neighbourhood has to be squeezed through fixed-size node vectors and narrow bottleneck edges. Long-range dependencies get crushed. This is why some problems need graph rewiring or attention-style shortcuts rather than just more layers.
Limited expressiveness
Standard message passing is provably no more powerful than the Weisfeiler-Lehman test at distinguishing structures, so there exist genuinely different graphs a vanilla GNN simply cannot tell apart. If your task hinges on fine structural distinctions (counting cycles, say), you may need higher-order GNNs or added structural features.
Scale and sampling
Full-graph training does not fit in memory once graphs reach millions of nodes. Neighbour sampling (GraphSAGE) or subgraph / cluster sampling is what makes industrial-scale GNNs possible, at the cost of some variance in each update.
Heterophily
The averaging intuition assumes connected nodes are similar (homophily), which holds for citation and social graphs but not for all. When neighbours tend to be different (some fraud and interaction networks), plain GCN-style smoothing actively hurts, and you need models designed for heterophilous graphs.
| Knob | Sensible default | When to change it |
|---|---|---|
| Depth | 2–3 layers | add skips/norm before going deeper |
| Aggregator | mean (GCN) or attention (GAT) | sum (GIN) when structure must be distinguished |
| Self-loops | on | almost always keep them |
| Training | full-graph for small data | neighbour sampling for large graphs |
| Features | normalise node features | add structural / positional features if needed |
| Readout (graph task) | mean or sum pooling | hierarchical pooling for large graphs |
09 / THE FAMILY TREEVariants you will hear about
Spectral vs spatial Two historical lineages. Spectral GNNs define convolution through the graph Laplacian's eigenbasis; spatial GNNs (the message-passing view used throughout this piece) work directly on neighbourhoods. GCN is the bridge that made the spatial view dominant.
Edge & relational R-GCN and friends handle typed edges, essential for knowledge graphs where “works-for” and “located-in” are different relations that should be processed differently.
Heterogeneous Real graphs often mix node types (users, items, sensors, faults). Heterogeneous GNNs keep separate transforms per type rather than pretending all nodes are alike.
Temporal / dynamic When the graph itself changes over time (a fleet's connectivity, a transaction stream), temporal GNNs fold a time dimension into message passing.
Graph transformers Attention over all nodes, with the graph injected as a structural or positional bias rather than a hard neighbourhood mask. These relax the locality of message passing and help with long-range dependencies and over-squashing.
Geometric deep learning The unifying umbrella: GNNs, CNNs, and transformers are all the same recipe (a shared local operation respecting a symmetry) specialised to grids, sequences, and graphs respectively. A useful frame for seeing why the field hangs together.
10 / IN PRACTICEWhere it earns its keep
GNNs are in production for recommendation, drug and materials discovery, fraud detection, traffic forecasting, chip design, and knowledge-graph reasoning. The common thread is that relationships, not just individual records, carry the signal. Two of these are worth drawing out, because they sit directly on the path of health monitoring and engineering knowledge work.
Knowledge graphs and reasoning
A knowledge graph of components, signals, faults, requirements, and documents is, literally, a graph. GNNs turn it into something you can compute over: link prediction suggests missing relations (this fault code plausibly connects to that subsystem), node classification tags entities, and learned embeddings power semantic retrieval. This is the relational backbone underneath a lot of agentic and retrieval tooling, where the graph supplies the structure that raw text search lacks.
Health monitoring and prognostics
- Sensors as a graph. A set of sensors with physical or correlation-based relationships forms a graph; a GNN can detect anomalies and isolate faults by reasoning over how a deviation propagates between connected channels, rather than treating each channel alone.
- Systems as a graph. Components wired into subsystems form a natural topology. Modelling fault propagation as message passing along that topology mirrors how failures actually cascade through a real system.
- Fleet structure. Units that share parts, duty cycles, or operating conditions can be linked, letting evidence from one unit inform estimates on similar units, the kind of structured transfer that pure per-unit models miss.
The honest framing matches the PINN case: a GNN is not magic, but when the relationships between things are part of what you are trying to predict, it lets the model use that structure instead of throwing it away.
11 / REFERENCESWhere to go next
- Scarselli, F., Gori, M., Tsoi, A. C., Hagenbuchner, M., & Monfardini, G. (2009). The graph neural network model. IEEE Transactions on Neural Networks, 20(1), 61–80. (the original GNN)
- Kipf, T. N., & Welling, M. (2017). Semi-supervised classification with graph convolutional networks. International Conference on Learning Representations (ICLR). (GCN, the workhorse)
- Hamilton, W. L., Ying, R., & Leskovec, J. (2017). Inductive representation learning on large graphs. Advances in Neural Information Processing Systems (NeurIPS). (GraphSAGE)
- Veličković, P., Cucurull, G., Casanova, A., Romero, A., Liò, P., & Bengio, Y. (2018). Graph attention networks. ICLR. (GAT)
- Gilmer, J., Schoenholz, S. S., Riley, P. F., Vinyals, O., & Dahl, G. E. (2017). Neural message passing for quantum chemistry. International Conference on Machine Learning (ICML). (the message-passing framework)
- Xu, K., Hu, W., Leskovec, J., & Jegelka, S. (2019). How powerful are graph neural networks? ICLR. (GIN and expressiveness)
- Li, Q., Han, Z., & Wu, X.-M. (2018). Deeper insights into graph convolutional networks for semi-supervised learning. AAAI Conference on Artificial Intelligence. (over-smoothing)
- Alon, U., & Yahav, E. (2021). On the bottleneck of graph neural networks and its practical implications. ICLR. (over-squashing)
- Wu, Z., Pan, S., Chen, F., Long, G., Zhang, C., & Yu, P. S. (2021). A comprehensive survey on graph neural networks. IEEE Transactions on Neural Networks and Learning Systems, 32(1), 4–24. (survey)
- Hamilton, W. L. (2020). Graph Representation Learning. Synthesis Lectures on AI and Machine Learning, Morgan & Claypool. (the readable textbook)