A CNN assumes your data sits on a grid. An RNN assumes it sits on a line. A GNN drops both assumptions: it learns on arbitrary graphs, where each node has features and the edges say who is related to whom. It does this by repeatedly letting every node listen to its neighbours and rewrite its own representation from what it hears.
That single line is the whole family. Change AGG and you change the algorithm: mean gives GCN, learned weights give GAT, sampled neighbours give GraphSAGE.
Each edge carries a message from source to target. Nothing is global — all computation is local, which is exactly why a GNN generalises to graphs of any size or shape.
Neighbour messages are pooled by a permutation-invariant function (sum, mean, max, attention). Invariance is non-negotiable: a node's neighbours have no natural order.
The pooled message plus the node's own previous state pass through a learned transform and a nonlinearity. Weights are shared across all nodes — the graph analogue of a convolution kernel.
For a whole-graph prediction, collapse all node embeddings into one vector (sum/mean/max or hierarchical pooling). Skip readout for node- or edge-level tasks.
1. Why must the aggregation function be permutation-invariant, and what breaks if you naively concatenate neighbour features instead?
Hint: a node's neighbours arrive in no particular order, and different nodes have different degrees. What would concatenation imply about both?2. A colleague reports that their 8-layer GNN performs worse than their 2-layer one on node classification. What is the likely mechanism, and what does it tell you about depth on graphs versus depth on images?
Hint: think about what repeated neighbourhood averaging does to the variance between node embeddings as the receptive field approaches the whole graph.3. When would you choose a GNN over simply flattening the graph into a feature table (node degree, neighbour-count stats) and running gradient boosting?
Hint: hand-engineered features fix the relational patterns you can express in advance. What does a GNN get to learn instead — and when is that worth the extra cost?