Part IV's convolution slides a fixed 3×3 window over an image, because every pixel has exactly 8 neighbors in the same fixed arrangement. A social network, a molecule, a road map — none of that holds. What replaces "neighbor" when there's no grid at all?
Click any node. Its neighbors light up — and notice they're not the same number of neighbors every time. Some nodes connect to three others, some to just one. There's no fixed window size that could ever slide over this.
- Nodes, edges, and neighborhoods
A graph is just a set of nodes (things) and edges (connections between them). The only structure a node has is which other nodes it touches — its neighborhood, — and how many, its degree.
- The adjacency matrix encodes it all
The whole graph can be written as an adjacency matrix , where if nodes and share an edge and otherwise.
- Symmetric, zero diagonal, rows sum to degree
is symmetric (an edge goes both ways) with a zero diagonal (no node is its own neighbor), and row 's sum is exactly node 's degree.
Click node 1 or node 3 — both hubs with degree 3 — then click a leaf like node 4 or 5, with degree 1. Whatever comes next (message passing, attention, pooling) has to work correctly for both of these at once, with no assumption about how many neighbors show up.
For this graph — a triangle fused to a two-node tail through hub node :
- Read off the neighborhoods by hand
- , degree
- , degree
- , degree
- , degree
- , degree
- , degree
Degrees — none of them equal.
- Build the adjacency matrix
In node order , row has a in column exactly where :
- Row :
- Row :
- Row :
- Row :
- Row :
- Row :
Every row sums to that node's degree — row sums to , matching exactly.
- Confirm what a grid convolution would get wrong
A 3×3 kernel assumes 8 fixed neighbors, in a fixed spatial layout, for every pixel. Node has one neighbor; node has three, in no particular spatial order at all — there's no way to write a single fixed-size, fixed-shape kernel that covers both.
Click through the nodes until you've found both leaves — the nodes with degree exactly 1. Found so far: none.
Graphs generalize both the grid (an image is a graph where every node's neighborhood is the same fixed shape) and the sequence (a chain is a graph where every node has at most two neighbors, in order). The next chapters build architectures that work correctly no matter how many neighbors a node has, or how they're arranged — starting with the simplest possible rule: average them.