Graphs have nodes and edges. GNNs learn by message passing: each node aggregates information from its neighbors. Graph convolutions are the neural network equivalent for graphs. Applications include social networks, molecular graphs, and knowledge graphs.
Message Passing
Code Snippet
For each node v:
1. Aggregate neighbor messages: m_v = AGG({h_u : u ∈ neighbors(v)})
2. Update node: h_v_new = UPDATE(h_v, m_v)
Graph Convolution
Code Snippet
import torch.nn as nn
from torch_geometric.nn import GCNConv
class GCN(nn.Module):
def __init__(self, in_channels, hidden_channels, out_channels):
super().__init__()
self.conv1 = GCNConv(in_channels, hidden_channels)
self.conv2 = GCNConv(hidden_channels, out_channels)
def forward(self, x, edge_index):
x = self.conv1(x, edge_index)
x = F.relu(x)
x = self.conv2(x, edge_index)
return x
Conclusion
GNNs extend deep learning to structured graph data. Message passing is the key abstraction enabling powerful graph representations. Understanding GNNs enables modeling structured domains: molecules, social networks, knowledge graphs. Next: attention is all you need—the Transformer architecture applied to graphs.






