Berlin Tech Meetup: The Future of Relational Foundation Models, Systems, and Real-World Applications

Register now:
PyG/Guide7 min read

Spatial Methods: GNNs Based on Local Neighborhood Operations

Spatial methods are how GNNs actually work in practice. Every modern GNN layer operates by aggregating information from each node's local neighbors. Scalable, inductive, and intuitive, spatial methods dominate enterprise GNN deployment.

PyTorch Geometric

TL;DR

  • 1Spatial GNNs define convolution as local neighborhood operations: each node aggregates features from its direct neighbors, combines with its own, and updates. This IS message passing.
  • 2All modern GNN layers are spatial: GCNConv (degree-normalized mean), GATConv (attention-weighted), SAGEConv (sample + aggregate), GINConv (sum + MLP). The differences are in aggregation strategy.
  • 3Spatial methods dominate because they are O(|E|) per layer, naturally inductive, and compatible with neighbor sampling. Spectral methods are O(n^3) and transductive.
  • 4For enterprise data: start with GCNConv, upgrade to GATConv for variable neighbor importance, use SAGEConv with NeighborLoader for large-scale graphs.
  • 5In PyG, all spatial layers inherit from MessagePassing. The framework handles sparse operations, GPU acceleration, and batching. You choose the layer; PyG handles the rest.

Spatial graph neural network methods define convolution as local neighborhood operations where each node aggregates feature vectors from its direct neighbors and updates its own representation, operating directly in the graph domain rather than a spectral frequency domain. Every modern GNN layer (GCNConv, GATConv, SAGEConv, GINConv) is a spatial method. They are scalable (O(|E|) per layer), naturally inductive (generalize to unseen nodes), and compatible with mini-batch training via neighbor sampling. Spatial methods are the only practical choice for enterprise-scale graph neural networks.

Why it matters for enterprise data

Enterprise graphs have millions of nodes and billions of edges. Spatial methods are the only GNN paradigm that can handle this scale:

  • Scalability: Each node only looks at its neighbors. Computation scales with the number of edges, not nodes squared.
  • Inductive inference: New customers, transactions, and products can be scored immediately without retraining. The learned aggregation function works on any node.
  • Mini-batch training: Neighbor sampling creates manageable mini-batches from massive graphs. Not possible with spectral methods.

The spatial methods family

spatial_methods_comparison.py
from torch_geometric.nn import GCNConv, GATConv, SAGEConv, GINConv
from torch.nn import Sequential, Linear, ReLU

# GCNConv: degree-normalized mean aggregation + linear transform
# Best for: homophilous graphs, simple baselines, maximum speed
gcn = GCNConv(in_channels=64, out_channels=64)

# GATConv: learned attention weights per neighbor
# Best for: variable neighbor importance, interpretable weights
gat = GATConv(64, 64, heads=8)

# SAGEConv: sample + aggregate with separate self/neighbor transforms
# Best for: large-scale inductive settings, production deployment
sage = SAGEConv(64, 64, aggr='mean')

# GINConv: sum aggregation + MLP for maximum expressiveness
# Best for: tasks requiring fine structural discrimination
gin_nn = Sequential(Linear(64, 64), ReLU(), Linear(64, 64))
gin = GINConv(gin_nn)

# All four are spatial methods. All inherit from MessagePassing.
# The difference is HOW they aggregate neighbor information.

Four spatial methods, four aggregation strategies. All operate locally on neighborhoods. PyG's MessagePassing base class provides the shared infrastructure.

Concrete example: choosing a spatial method for enterprise churn prediction

A telecom company building a churn model on a customer call graph:

  • Graph: 50M customers, 2B call/text edges
  • Features: tenure, plan, monthly charge, support calls
  • Task: predict which customers will churn next month

Architecture choice:

  1. SAGEConv for the layers (designed for large-scale inductive learning)
  2. NeighborLoader with [15, 10] sampling for mini-batch training
  3. 2 layers (customer sees 2-hop social network influence)
  4. Linear classification head

Spatial vs. spectral: a practical comparison

  • Computation: Spatial O(|E|) per layer. Spectral O(n^3) for eigendecomposition + O(n^2) per layer.
  • Scalability: Spatial works on billion-edge graphs with sampling. Spectral is limited to thousands of nodes.
  • Inductive: Spatial generalizes to new nodes. Spectral is graph-specific.
  • Theory: Spectral provides cleaner mathematical foundations. Spatial is more intuitive and practical.

Limitations and what comes next

  1. Local receptive field: Each layer sees only 1-hop neighbors. k layers = k hops. Long-range dependencies require many layers, which causes over-smoothing.
  2. Expressiveness ceiling: All spatial methods are bounded by the 1-WL test. Positional and structural encodings help overcome this.
  3. No global context: Spatial methods cannot capture graph-wide patterns without stacking many layers. Graph transformers address this with global attention.

Frequently asked questions

What are spatial methods in GNNs?

Spatial methods define graph neural network operations directly on the graph structure by aggregating features from each node's local neighborhood. Rather than transforming to a spectral domain, spatial methods operate in the 'node domain': each node collects information from its neighbors, combines it with its own features, and produces an updated representation. All modern GNN layers (GCNConv, GATConv, SAGEConv, GINConv) are spatial methods.

How are spatial methods different from spectral methods?

Spectral methods define convolution via the graph Laplacian's eigendecomposition (frequency domain). Spatial methods define convolution as local neighborhood operations (node domain). Spectral methods are O(n^3) and transductive. Spatial methods are O(|E|) and naturally inductive. In practice, GCN is both: derived from spectral theory but implemented as a spatial operation.

Why do spatial methods dominate in practice?

Three reasons: (1) Scalability - local operations are O(|E|), not O(n^3). Compatible with neighbor sampling for large graphs. (2) Inductive - work on unseen nodes and new graphs because they learn parameterized functions, not graph-specific operations. (3) Intuitive - 'aggregate neighbor information' is easy to understand and implement. These properties make spatial methods the only practical choice for enterprise deployment.

What is the relationship between spatial methods and message passing?

Spatial methods and message passing are essentially synonymous. The message passing framework (message, aggregate, update) is the formal description of how spatial methods operate. Every spatial GNN layer is a message passing layer. The terms are used interchangeably in the literature.

Which spatial method should I use for enterprise data?

Start with GCNConv for simplicity and speed. If neighbor importance varies, use GATConv (attention). For large-scale inductive settings, use SAGEConv with neighbor sampling. For maximum expressiveness, use GINConv. For production-grade performance across tasks, graph transformers combine spatial message passing with global attention.

Learn more about graph ML

PyTorch Geometric is the open-source foundation for graph neural networks. Explore more layers, concepts, and production patterns.