Handling Directed and Weighted Graphs
You'll learn how to adapt message passing operations to respect edge directionality and incorporate edge weights in graph neural networks.
The Core Challenge
So far, most graph convolution examples assume undirected edges with uniform importance. Real-world graphs often have directed edges (where A→B differs from B→A) and weighted connections (where some relationships matter more than others). Think of social networks with follower relationships (directed) or citation networks where recent papers carry more weight.
Directed Graphs in Message Passing
In directed graphs, you must distinguish between incoming and outgoing neighbors. When aggregating messages for node i:
- Standard GCN: aggregates from all neighbors regardless of direction
- Directed approach: aggregate only from source nodes whose edges point into node i
Some architectures maintain separate weight matrices for in-edges and out-edges, or reverse edges during preprocessing to enable bidirectional message flow.
Incorporating Edge Weights
Edge weights modify the aggregation step. Instead of treating all neighbor contributions equally:
h_i^(k+1) = σ(Σ_{j∈N(i)} w_{ji} · W^(k) · h_j^(k))
Where w_{ji} is the edge weight from node j to i. This naturally extends mean/sum aggregation—weights act as attention coefficients determined by graph structure rather than learned parameters.
Practical Considerations
- Normalization: Weight by degree and edge weights to prevent exploding values
- Edge features: Weights can be one feature among many passed through MLPs
- Sparsity: Weighted adjacency matrices remain sparse; computational efficiency is preserved
Key Takeaway: Directed graphs require distinguishing message flow direction in aggregation, while weighted graphs scale neighbor contributions by connection strength—both modifications happen naturally within the message passing framework you've already learned.