Enhancing Graph Transformers with Hierarchical Distance Structural Encoding
Yuankai Luo, Hongkang Li, Lei Shi, Xiao-Ming Wu
Abstract
Graph transformers need strong inductive biases to derive meaningful attention scores. Yet, current methods often fall short in capturing longer ranges, hierarchical structures, or community structures, which are common in various graphs such as molecules, social networks, and citation networks. This paper presents a Hierarchical Distance Structural Encoding (HDSE) method to model node distances in a graph, focusing on its multi-level, hierarchical nature. We introduce a novel framework to seamlessly integrate HDSE into the attention mechanism of existing graph transformers, allowing for simultaneous application with other positional encodings. To apply graph transformers with HDSE to large-scale graphs, we further propose a high-level HDSE that effectively biases the linear transformers towards graph hierarchies. We theoretically prove the superiority of HDSE over shortest path distances in terms of expressivity and generalization. Empirically, we demonstrate that graph transformers with HDSE excel in graph classification, regression on 7 graph-level datasets, and node classification on 11 large-scale graphs, including those with up to a billion nodes.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
14 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Beyond Homophily in Graph Neural Networks: Current Limitations and Effective Designs cites Open Graph Benchmark: Datasets for Machine Learning on Graphs
- Beyond Homophily in Graph Neural Networks: Current Limitations and Effective Designs cites Geom-GCN: Geometric Graph Convolutional Networks
- What Improves the Generalization of Graph Transformers? A Theoretical Dive into the Self-attention and Positional Encoding cites Open Graph Benchmark: Datasets for Machine Learning on Graphs
- What Improves the Generalization of Graph Transformers? A Theoretical Dive into the Self-attention and Positional Encoding cites Geom-GCN: Geometric Graph Convolutional Networks
- What Improves the Generalization of Graph Transformers? A Theoretical Dive into the Self-attention and Positional Encoding cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- What Improves the Generalization of Graph Transformers? A Theoretical Dive into the Self-attention and Positional Encoding cites Do Transformers Really Perform Badly for Graph Representation?
- DualEqui: A Dual-Space Hierarchical Equivariant Network for Large Biomolecules cites Do Transformers Really Perform Badly for Graph Representation?
- Do Transformers Really Perform Badly for Graph Representation? cites Open Graph Benchmark: Datasets for Machine Learning on Graphs
- Do Transformers Really Perform Badly for Graph Representation? cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
Cited by top-tier papers14
- How Do Nonlinear Transformers Learn and Generalize in In-Context Learning?Hongkang Li, Meng Wang, Songtao Lu, Xiaodong Cui et al.ICML 2024 · 37 citations
- What Improves the Generalization of Graph Transformers? A Theoretical Dive into the Self-attention and Positional EncodingHongkang Li, Meng Wang, Tengfei Ma, Sijia Liu et al.ICML 2024 · 23 citations
- Social Recommendation via Graph-Level Counterfactual AugmentationYinxuan Huang, Ke Liang, Yanyi Huang, Xiang Zeng et al.AAAI 2025 · 8 citations
- How Can Mamba Learn In Context with Outliers and Generalize Provably?Hongkang Li, Songtao Lu, Xiaodong Cui, Pin-Yu Chen et al.ICML 2026 · 2 citations
- DualEqui: A Dual-Space Hierarchical Equivariant Network for Large BiomoleculesJunjie Xu, Jiahao Zhang, Mangal Prakash, Xiang Zhang et al.NeurIPS 2025 · 2 citations
Builds on47
- An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn et al.ICLR 2021 · 21,477 citations
- Open Graph Benchmark: Datasets for Machine Learning on GraphsWeihua Hu, Matthias Fey, Marinka Zitnik, Yuxiao Dong et al.NeurIPS 2020 · 3,935 citations
- Do Transformers Really Perform Badly for Graph Representation?Chengxuan Ying, Tianle Cai, Shengjie Luo, Shuxin Zheng et al.NeurIPS 2021 · 1,632 citations
- Beyond Homophily in Graph Neural Networks: Current Limitations and Effective DesignsJiong Zhu, Yujun Yan, Lingxiao Zhao, Mark Heimann et al.NeurIPS 2020 · 1,490 citations
- Geom-GCN: Geometric Graph Convolutional NetworksHongbin Pei, Bingzhe Wei, Kevin Chen-Chuan Chang, Yu Lei et al.ICLR 2020 · 1,445 citations
Related papers
- Homomorphism Counts as Structural Encodings for Graph LearningLinus Bao, Emily Jin, Michael M. Bronstein, Ismail Ilkan Ceylan et al.ICLR 2025
- Simple Path Structural Encoding for Graph TransformersLouis Airale, Antonio Longa, Mattia Rigon, Andrea Passerini et al.ICML 2025
- Graph Positional and Structural EncoderSemih Cantürk, Renming Liu, Olivier Lapointe-Gagné, Vincent Létourneau et al.ICML 2024 · 33 citations
- Transformers over Directed Acyclic GraphsYuankai Luo, Veronika Thost, Lei ShiNeurIPS 2023 · 43 citations
- Generalizable Insights for Graph Transformers in Theory and PracticeTimo Stoll, Luis Müller, Christopher MorrisNeurIPS 2025 · 2 citations
