What Is a Sheaf? From Topology to Graph Learning
Published:

Sheaves in Ordinary Mathematics
Intuition First: Imagine you’re assembling a jigsaw puzzle. Each piece (node) has part of the picture. Two adjacent pieces (connected by an edge) must agree along their shared border — but the border on piece A’s side is the same physical border as on piece B’s side, viewed from slightly different angles. The “restriction maps” are exactly the rotation/flip transforms that make A’s border match B’s border. A global section is a completed puzzle where every adjacent pair agrees perfectly after applying those transforms.
In mathematics, a sheaf is a tool for tracking local data (defined on open sets of a topological space) and understanding when local data can be assembled into global data.
The key property: local-to-global consistency. Data is consistent locally at every overlap → data assembles into a unique global section.
For our purposes (cellular sheaves on graphs), we use a discretisation: the “topological space” is the graph, “open sets” are nodes and edges, and “local data” are vectors in the stalks.
Cellular Sheaves on Graphs
A cellular sheaf \(\mathcal{F}\) on a graph \(G = (V, E)\) assigns:
- Node stalks: a vector space \(\mathcal{F}(v) = \mathbb{R}^{d_v}\) to each node \(v\)
- Edge stalks: a vector space \(\mathcal{F}(e) = \mathbb{R}^{d_e}\) to each edge \(e\)
- Restriction maps: for each edge \(e = (u,v)\) and each incident node \(w \in \{u,v\}\), a linear map
Notation: \(w \trianglelefteq e\) reads “\(w\) is a face of \(e\)”, i.e. \(w\) is an endpoint of the edge \(e\). Throughout this book we fix a common stalk dimension \(d_v = d_e = d\), so every restriction map is a \(d \times d\) matrix.
The Cochain Complex
The stalks and restriction maps define a cochain complex:
Where:
- \(C^0(G;\mathcal{F}) = \bigoplus_{v \in V} \mathcal{F}(v)\): the space of all node assignments (0-cochains)
- \(C^1(G;\mathcal{F}) = \bigoplus_{e \in E} \mathcal{F}(e)\): the space of all edge assignments (1-cochains)
- \(\delta : C^0 \to C^1\) is the coboundary map, defined for an oriented edge \(e = (u,v)\) by
The coboundary \(\delta x\) measures the disagreement between \(u\)’s and \(v\)’s contributions to edge \(e\). (The choice of orientation only flips the sign of \((\delta x)_e\), so nothing below depends on it.)
Global Sections
A global section is a 0-cochain \(x \in C^0(G;\mathcal{F})\) such that
i.e. \(\mathcal{F}_{v \trianglelefteq e}\, x_v = \mathcal{F}_{u \trianglelefteq e}\, x_u\) for every edge \(e = (u,v)\). The two endpoints “agree” at every edge.
The space of global sections is the zeroth sheaf cohomology,
and it measures how much consistent global data the sheaf supports.
Special case — trivial sheaf: \(\mathcal{F}(v) = \mathbb{R}\), \(\mathcal{F}(e) = \mathbb{R}\), all restriction maps equal to \(1\). Then \((\delta x)_e = x_v - x_u\) is just the ordinary graph gradient, and global sections are the functions that are constant on each connected component. This is exactly the setting in which the sheaf Laplacian becomes the ordinary graph Laplacian.
The Standard Graph as a Trivial Sheaf
The graph Laplacian is the special case of the sheaf Laplacian in which
Then \((\delta x)_e = x_v - x_u\) is the edge-difference operator and
the ordinary \(\lvert V \rvert \times \lvert V \rvert\) graph Laplacian. If instead the stalks are \(\mathbb{R}^d\) with identity restriction maps, one gets the block version \(L \otimes I_d\), which applies the same scalar Laplacian independently to each of the \(d\) coordinates. Either way, no per-edge structure is available — the sheaf is trivial.
GCN’s propagation \(\hat{A} H = (I - \tilde{\Delta})H\), with \(\tilde{\Delta}\) the symmetric normalised Laplacian of the self-looped graph, is one Euler step of heat diffusion; and heat diffusion \(\dot{x} = -Lx\) is precisely gradient flow on the Dirichlet energy \(\tfrac12\sum_{(u,v) \in E} \lVert x_u - x_v \rVert^2\). Each layer therefore decreases that energy — which is another way of saying it pushes neighbours toward equality.
Non-Trivial Sheaves Allow Disagreement
With non-trivial restriction maps, the “agreement” condition becomes \(\mathcal{F}_{u \trianglelefteq e} x_u = \mathcal{F}_{v \trianglelefteq e} x_v\) — \(x_u\) and \(x_v\) are not required to be equal, only to agree after transformation.
This allows adjacent nodes to have different but compatible features. In a heterophilic graph, two nodes with different labels might have very different features, but a learned sheaf map could rotate one into the other’s space — making them “consistent” under the sheaf even though they are numerically different.
Worked Example: Global Section on a Triangle Graph
Setup: triangle graph with nodes \(u, v, w\) and edges \(e_{uv}, e_{vw}, e_{uw}\), all stalks \(\mathbb{R}\). Restriction maps:
Orienting each edge from the alphabetically earlier node to the later one, the coboundary is
Global section condition (all three coboundaries vanish):
- Edge \(e_{uv}\) gives \(x_v - x_u = 0\), hence \(x_v = x_u\).
- Edge \(e_{vw}\) gives \(x_w - 2 x_v = 0\), hence \(x_w = 2 x_u\).
- Edge \(e_{uw}\) gives \(3 x_w - x_u = 0\), and substituting gives \(3(2 x_u) - x_u = 5 x_u = 0\), hence \(x_u = 0\).
Conclusion: \(H^0(G;\mathcal{F}) = 0\) — the only global section is the zero vector, so this sheaf carries no non-trivial consistent signal. What killed it is the cycle: going around the triangle multiplies a value by \(2 \cdot 3 / 1 \neq 1\), so the three edge constraints are mutually incompatible. On a tree the same maps would leave a one-dimensional space of sections, because there is no cycle to close.
Why Sheaves for Graphs?
The sheaf framework provides:
- Richer aggregation: edges have their own “mediation” structure (restriction maps)
- Heterophily handling: adjacent nodes with different features are not forced to agree — the restriction maps can accommodate difference
- Mathematical guarantees: the sheaf Laplacian inherits spectral theory from the standard Laplacian, with richer structure
- Interpretability: the consistency defect \(\lVert \delta x \rVert^2\) measures “how inconsistent” the data is under the learned sheaf
Summary
| Concept | Standard GCN | Cellular Sheaf |
|---|---|---|
| Node data | Vectors \(h_v \in \mathbb{R}^d\) | Vectors \(x_v \in \mathcal{F}(v)\) |
| Edge data | None | Vectors \(x_e \in \mathcal{F}(e)\) |
| Agreement condition | \(h_u = h_v\) at edges | \(\mathcal{F}_{u \trianglelefteq e} x_u = \mathcal{F}_{v \trianglelefteq e} x_v\) |
| Laplacian | \(L = D - A\) | \(L_{\mathcal{F}} = \delta^{\top}\delta\) |
| Global sections | Constant functions | \(H^0(G;\mathcal{F}) = \ker\delta\) |
The sheaf framework generalises the standard graph to a richer structure that can encode per-edge relational information. The sheaf Laplacian, covered in the next post, is the key operator that makes this actionable for graph learning.
References
- Hansen, J., & Gebhart, T. (2020). Sheaf Neural Networks. NeurIPS 2020 GRL+ Workshop (first use of cellular sheaves for graph learning, with a hand-crafted sheaf Laplacian).
- Hansen, J., & Ghrist, R. (2019). Toward a Spectral Theory of Cellular Sheaves. Journal of Applied and Computational Topology (defines the sheaf Laplacian, its harmonic space, and the isomorphism \(\ker L_{\mathcal{F}} \cong H^0(G;\mathcal{F})\)).
- Bodnar, C., Di Giovanni, F., Chamberlain, B. P., Liò, P., & Bronstein, M. M. (2022). Neural Sheaf Diffusion: A Topological Perspective on Heterophily and Oversmoothing in GNNs. NeurIPS 2022 (NSD: learns sheaf restriction maps from node features, building on the cellular sheaf theory above).
- Curry, J. (2014). Sheaves, Cosheaves and Applications. PhD Thesis, University of Pennsylvania (mathematical foundation of cellular sheaf theory underlying sheaf neural networks).
