Transformers Meet Directed Graphs
Simon Geisler, Yujia Li, Daniel J. Mankowitz, Ali Taylan Cemgil, Stephan Günnemann, Cosmin Paduraru
Abstract
Transformers were originally proposed as a sequence-to-sequence model for text but have become vital for a wide range of modalities, including images, audio, video, and undirected graphs. However, transformers for directed graphs are a surprisingly underexplored topic, despite their applicability to ubiquitous domains, including source code and logic circuits. In this work, we propose two direction- and structure-aware positional encodings for directed graphs: (1) the eigenvectors of the Magnetic Laplacian - a direction-aware generalization of the combinatorial Laplacian; (2) directional random walk encodings. Empirically, we show that the extra directionality information is useful in various downstream tasks, including correctness testing of sorting networks and source code understanding. Together with a data-flow-centric graph construction, our model outperforms the prior state of the art on the Open Graph Benchmark Code2 relatively by 14.7%.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext bfb634e7-1201-4862-9b5d-fd3597137885Cited by top-tier papers18
- On the Connection Between MPNN and Graph TransformerChen Cai, Truong Son Hy, Rose Yu, Yusu WangICML 2023 · 82 citations
- Transformers over Directed Acyclic GraphsYuankai Luo, Veronika Thost, Lei ShiNeurIPS 2023 · 43 citations
- Comparing Graph Transformers via Positional EncodingsMitchell Black, Zhengchao Wan, Gal Mishne, Amir Nayyeri et al.ICML 2024 · 27 citations
- HoloNets: Spectral Convolutions do extend to Directed GraphsChristian Koke, Daniel CremersICLR 2024 · 25 citations
- Toward Effective Digraph Representation Learning: A Magnetic Adaptive Propagation based ApproachXunkai Li, Daohan Su, Zhengyu Wu, Guang Zeng et al.WWW 2025 · 4 citations
Builds on18
- Open Graph Benchmark: Datasets for Machine Learning on GraphsWeihua Hu, Matthias Fey, Marinka Zitnik, Yuxiao Dong et al.NeurIPS 2020 · 3,935 citations
- Reformer: The Efficient TransformerNikita Kitaev, Lukasz Kaiser, Anselm LevskayaICLR 2020 · 2,878 citations
- Recipe for a General, Powerful, Scalable Graph TransformerLadislav Rampásek, Michael Galkin, Vijay Prakash Dwivedi, Anh Tuan Luu et al.NeurIPS 2022 · 1,216 citations
- Rethinking Graph Transformers with Spectral AttentionDevin Kreuzer, Dominique Beaini, William L. Hamilton, Vincent Létourneau et al.NeurIPS 2021 · 854 citations
- High-Performance Large-Scale Image Recognition Without NormalizationAndy Brock, Soham De, Samuel L. Smith, Karen SimonyanICML 2021 · 613 citations
Related papers
- What Are Good Positional Encodings for Directed Graphs?Yinan Huang, Haoyu Peter Wang, Pan LiICLR 2025
- Homomorphism Counts as Structural Encodings for Graph LearningLinus Bao, Emily Jin, Michael M. Bronstein, Ismail Ilkan Ceylan et al.ICLR 2025
- MagNet: A Neural Network for Directed GraphsXitong Zhang, Yixuan He, Nathan Brugnone, Michael Perlmutter et al.NeurIPS 2021 · 223 citations
- On the Stability of Expressive Positional Encodings for GraphsYinan Huang, William Lu, Joshua Robinson, Yu Yang et al.ICLR 2024 · 32 citations
- Rotary Position Encodings for GraphsIsaac Reid, Arijit Sehanobish, Cederik Höfs, Bruno Mlodozeniec et al.ICML 2026
