Rethinking and Benchmarking Large Language Models for Graph Reasoning

Yuwei Hu, Xinyi Huang, Zhewei Wei, Yongchao Liu, Chuntao Hong · DOI

Introduction

Large Language Models (LLMs) are increasingly deployed for complex tasks requiring structured reasoning, such as drug discovery and network analysis. However, their ability to perform "graph reasoning"—solving problems like finding shortest paths or detecting cycles—remains a subject of debate. Current research typically follows two paradigms: language-based simulation and code-augmented tool use.

Comparison of graph reasoning paradigms: Language-Based, Code-Augmented, and the proposed Simple-RTC.

Language-based methods force LLMs to simulate algorithms step-by-step in natural language. This often fails as graphs scale; the model loses track of state during iterations, leading to hallucinations. Code-augmented methods allow LLMs to call external APIs (e.g., NetworkX). While effective for standard tasks, this approach tests tool-use rather than the model's inherent reasoning ability and fails on novel or complex graph structures not covered by standard libraries.

The Simple-RTC Framework

To address these limitations, the authors introduce Simple-Reasoning-Then-Coding (Simple-RTC). This pipeline shifts the LLM's role from a "manual executor" to an "algorithm designer." Instead of performing the graph math itself, the LLM designs the logic and generates executable code.

The Simple-RTC pipeline: Formatting, Extracting, Reasoning (Algorithm Design), and Coding.

The Simple-RTC process consists of four distinct stages:

  1. Formatting: The LLM standardizes the problem description, removing specific graph data to focus on the abstract logic and I/O requirements.
  2. Extracting: The model generates a Python script to parse raw graph data into a structured format (e.g., adjacency lists).
  3. Reasoning: This is the core innovation. The LLM is prompted to think step-by-step and produce pseudocode or a high-level algorithmic description.
  4. Coding: A final call translates the reasoning into executable Python code, which is then run by a standard interpreter to produce the final answer.

By decoupling algorithm design from data execution, Simple-RTC avoids context window bloat and leverages the precision of a Python interpreter for the heavy lifting of graph traversal.

Benchmarking Graph Reasoning

The study evaluates Simple-RTC against several existing benchmarks, including NLGraph, Talk like a Graph, and GraphArena. Crucially, the authors identify that many existing benchmarks are too simplistic, allowing models to succeed through pattern memorization or simple API calls.

To provide a more rigorous test, the authors introduce GraphAlgorithm, a new benchmark comprising 239 unique problems and over 3,000 test instances sourced from competitive programming platforms like Codeforces and AtCoder. These problems require sophisticated, custom algorithmic solutions that cannot be solved by standard library calls.

Key Results and Insights

Simple-RTC demonstrates significant performance gains across all evaluated benchmarks. Using GPT-4o-mini as a base, the pipeline achieved near-perfect accuracy on existing datasets (e.g., 99.3% on NLGraph), representing a 48% average improvement over the base model.

On the challenging new GraphAlgorithm benchmark, Simple-RTC scored 33.7%. While highlighting the difficulty of competition-level reasoning, this score significantly outperformed the base GPT-4o-mini (14.3%) and specialized models like GraphTeam (8.7%) and GCoder (3.0%).

Key insights from the evaluation include:

  • Design vs. Execution: LLMs are far more capable when asked to design algorithms rather than execute them.
  • Overfitting in Fine-tuning: Models fine-tuned specifically for graph tasks (e.g., GraphWiz) often fail on unseen problems, suggesting they learn rigid templates rather than generalized reasoning.
  • Efficiency: Simple-RTC is significantly faster and cheaper. For a 200-node graph, it reduced processing time from 207.7 seconds (standard LLM execution) to 34.6 seconds.

Conclusion

The findings suggest that the perceived weakness of LLMs in graph reasoning is partly a byproduct of how they are prompted. By adopting the Simple-RTC pipeline, researchers can unlock the latent reasoning capabilities of off-the-shelf models. Future work should focus on improving the specialized algorithm design capabilities of LLMs to tackle the remaining gap in high-level competitive programming benchmarks.

Summary updated

BibTeX
@misc{hu2025rethinking,
  author = {Yuwei Hu and Xinyi Huang and Zhewei Wei and Yongchao Liu and Chuntao Hong},
  title = {{Rethinking and Benchmarking Large Language Models for Graph Reasoning}},
  year = {2025},
  eprint = {2509.24260},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.24260},
}
Figure