Graph Structure and Neighborhood Aggregation
What you'll learn: How graph neural networks gather and combine information from neighboring nodes to create meaningful representations.
The Core Idea
In graph neural networks, each node learns by looking at its neighbors. Think of it like a social network: to understand who you are, we look at your friends, their interests, and how you're connected. Neighborhood aggregation is the fundamental operation where a node collects information from its neighbors, combines it, and updates its own representation.
This process respects the graph structure—the pattern of connections matters. A node with many connections aggregates information differently than an isolated node. The aggregation follows the edges in your adjacency matrix or edge list.
How Information Flows
Consider a simple friendship graph:
- You are connected to Alice and Bob
- Alice likes hiking (feature: [1, 0])
- Bob likes cooking (feature: [0, 1])
To update your representation, you:
- Gather features from Alice and Bob
- Aggregate them (e.g., average: [0.5, 0.5])
- Combine with your own features
- Transform through a neural network layer
This happens simultaneously for all nodes, and can repeat across multiple layers. Each layer expands the "receptive field"—after 2 layers, you've seen neighbors-of-neighbors.
Why It Matters
Neighborhood aggregation is permutation invariant—the order you process neighbors doesn't matter, only their collective information. This respects the fundamental nature of graphs: connections matter, but there's no inherent ordering of nodes.
Key Takeaway: Graph neural networks work by iteratively aggregating neighbor features along edges, allowing each node to build representations that capture both local structure and feature information from its graph neighborhood.