Towards A Universal Graph Structural Encoder

Jialin Chen, Haolan Zuo, Haoyu Peter Wang, Siqi Miao, Pan Li, Rex Ying · DOI

Abstract

Foundation models have transformed natural language processing and computer vision, yet a universal foundation model for graphs remains elusive due to the vast diversity in node features across domains. We present GFSE (Graph Foundational Structural Encoder), a domain-agnostic pre-trained encoder that focuses exclusively on universal topological patterns. By learning expressive Positional and Structural Encodings (PSE) through multi-task self-supervised pre-training, GFSE serves as a plug-and-play enhancement for both Graph Neural Networks (GNNs) and Large Language Models (LLMs), significantly improving their structural reasoning capabilities.

Introduction

Graphs from different domains—such as molecular structures, social networks, and citation indices—possess highly heterogeneous node features and semantics. Traditional graph pre-training often fails to generalize across these boundaries because it over-relies on domain-specific attributes. However, these graphs share a common language: topology. Patterns like small-world properties, motifs, and hierarchical communities are universal. GFSE addresses this by stripping away domain-specific features to learn a pure structural representation that can be transferred across any graph dataset.

The GFSE Framework

GFSE utilizes a Graph Transformer architecture enhanced with a biased attention mechanism. Unlike standard transformers, GFSE injects relative random-walk positional encodings directly into the attention bias, allowing it to capture long-range dependencies and achieve higher theoretical expressiveness than standard message-passing GNNs.

Overview of the GFSE pre-training and downstream evaluation pipeline.

The model is pre-trained using four self-supervised tasks designed to capture structural information at various scales:

  1. Shortest Path Distance (SPD) Regression: Learns global proximity between nodes.
  2. Motif Counting: Identifies local subgraph patterns (graphlets).
  3. Community Detection: Groups densely connected nodes via a contrastive objective.
  4. Graph Contrastive Learning: Learns to distinguish between entire graph structures from different datasets.

Integration and Expressiveness

Once pre-trained, GFSE generates a PSE vector for each node. This vector can be integrated into downstream models in two ways:

  • For GNNs: The PSE is concatenated with existing node features.
  • For LLMs: A lightweight MLP projects the PSE into the LLM's embedding space, where it acts as a "structural soft token" prepended to text prompts. This provides the LLM with spatial awareness that is typically lost when graphs are flattened into text.

Theoretically, GFSE is strictly more powerful than the 1-WL isomorphism test. It can distinguish complex symmetric structures, such as strongly regular graphs, which often confound traditional GNNs.

Experimental Results

GFSE was pre-trained on a diverse mixture of 8 datasets across 6 domains, including molecules, proteins, and social networks. In downstream evaluations, GFSE achieved state-of-the-art results in 10 out of 12 real-world tasks.

Performance comparison of different architectures across the four pre-training tasks.

Key highlights include:

  • Transformer Rescue: Adding GFSE encodings to a vanilla Transformer on the Triangle dataset increased accuracy from 21.68% to 92.82%.
  • LLM Synergy: When paired with LLaMA2-7B, GFSE improved link prediction on text-attributed graphs by over 2% compared to existing baselines like InstructGLM.
  • Efficiency: GFSE inference is highly scalable, computing encodings in seconds compared to the minutes required by traditional handcrafted methods like RWSE or LapPE.

Conclusion

GFSE demonstrates that graph structure is a universal feature that can be pre-trained and transferred across domains. By providing a robust structural foundation, GFSE enables existing models—from simple GNNs to massive LLMs—to reason more effectively about the complex topologies inherent in real-world data. Future work will explore expanding the pre-training corpus to include dynamic and heterogeneous graphs.

Summary updated

BibTeX
@inproceedings{chen2026towards,
  author = {Jialin Chen and Haolan Zuo and Haoyu Peter Wang and Siqi Miao and Pan Li and Rex Ying},
  title = {{Towards A Universal Graph Structural Encoder}},
  booktitle = {The Web Conference},
  year = {2026},
  doi = {10.1145/3774904.3792656},
}
Figure