ICML 2025

Simple Path Structural Encoding for Graph Transformers
Louis Airale 1 Antonio Longa 1 Mattia Rigon 1 Andrea Passerini 1 Roberto Passerone 1
Abstract
Graph transformers extend global self-attention
to graph-structured data, achieving notable suc-
cess in graph learning. Recently, Relative Ran-
dom Walk Probabilities (RRWP) has been found
to further enhance their predictive power by en-
coding both structural and positional information
into the edge representation. However, RRWP
cannot always distinguish between edges that be-
long to different local graph patterns, which re-
duces its ability to capture the full structural com-
plexity of graphs. This work introduces Simple
Path Structural Encoding (SPSE), a novel method
that utilizes simple path counts for edge encod-
ing. We show theoretically and experimentally
that SPSE overcomes the limitations of RRWP,
providing a richer representation of graph struc-
tures, particularly for capturing local cyclic pat-
terns. To make SPSE computationally tractable,
we propose an efficient approximate algorithm
for simple path counting. SPSE demonstrates sig-
nificant performance improvements over RRWP
on various benchmarks, including molecular and
long-range graph datasets, achieving statistically
significant gains in discriminative tasks. These
results pose SPSE as a powerful edge encoding
alternative for enhancing the expressivity of graph
transformers.
1. Introduction
Graphs are pervasive across diverse domains, representing
complex relationships in areas such as social networks (Otte
& Rousseau, 2002), molecular structures (Quinn et al.,
2017), and citation graphs (Radicchi et al., 2011). Recent ad-
vances in graph neural networks (GNNs) have driven signif-
icant progress in learning from graph-structured data (Kipf
& Welling, 2017; Veliˇckovi´c et al., 2018; Bodnar et al.,
1University of Trento, Trento, Italy.
Correspondence
to: Louis Airale <louis.airale@unitn.it>, Roberto Passerone
<roberto.passerone@unitn.it>.
Proceedin...