Abstract
Large Language Models (LLMs) are increasingly deployed for tasks involving implicit structural reasoning. However, their ability to explicitly process graph structures described in natural language remains under-explored. This paper introduces NLGraph, a comprehensive benchmark comprising 29,370 problems across eight graph tasks of varying complexity. Our evaluation reveals that while LLMs exhibit preliminary capabilities on simple tasks, their performance degrades significantly as algorithmic complexity and graph scale increase. We demonstrate that LLMs are susceptible to spurious correlations and that advanced prompting techniques, such as Build-a-Graph (BAG) and Algorithmic prompting, provide only modest improvements on simpler tasks while failing to address complex reasoning failures.
1. Introduction
Graph reasoning is a cornerstone of complex problem-solving, from robotic planning to multi-hop question answering. While LLMs are often expected to navigate implicit structures, their capacity for explicit graph reasoning—mapping textual descriptions to grounded conceptual "mental maps" and executing algorithms—is not well understood. Existing evaluations often rely on narrow tasks or datasets prone to memorization. To address this, we present NLGraph, a synthetic benchmark designed to rigorously test the limits of LLM graph reasoning across diverse tasks and difficulty levels.
2. The NLGraph Benchmark
The NLGraph benchmark consists of eight distinct tasks: Connectivity, Cycle detection, Shortest Path, Topological Sort, Maximum Flow, Bipartite Matching, Hamilton Path, and GNN Simulation. Problems are generated using a Random Graph Generator, allowing for controlled variation in node count and edge density to scale difficulty from "Easy" to "Hard."
3. Methodology
Beyond standard zero-shot and few-shot evaluations, the researchers propose two novel instruction-based prompting techniques:
- Build-a-Graph (BAG) Prompting: Encourages the model to materialize the graph structure (nodes and edges) as an intermediate step before problem-solving. This forces the model to create a grounded representation.
- Algorithmic Prompting: Instructs the model to explicitly state the logic of a relevant algorithm (e.g., Depth-First Search) to provide a structured reasoning framework before attempting the solution.
4. Results and Analysis
Experiments conducted on GPT-family models reveal several key characteristics of LLM graph reasoning:
- Performance Gap: LLMs significantly outperform random baselines on simple tasks like connectivity (37-58% improvement). However, performance craters on complex tasks such as Maximum Flow and Hamilton Path.
- Complexity and Scale Sensitivity: Accuracy drops sharply as graph size increases. For instance, in the shortest path task, performance is highly sensitive to the number of nodes.
- Brittle Reasoning: Models often rely on spurious correlations, such as the frequency of node mentions. In connectivity tasks, removing these correlations (e.g., in "clique" structures) resulted in a performance drop of over 40%.
- The "More is Less" Paradox: In-context learning, typically a performance booster, can actually decrease accuracy for complex tasks like the Hamilton Path, as models become distracted by long reasoning chains.
- Diminishing Returns of Prompting: While BAG and Algorithmic prompting improve performance on easier tasks (Cycle, Shortest Path) by up to 16.85%, they remain largely ineffective for high-complexity tasks.
5. Conclusion
LLMs possess a "preliminary talent" for basic graph reasoning but are currently unable to handle complex algorithmic tasks in natural language. The brittleness of their reasoning and sensitivity to scale suggest that current architectures struggle to maintain stable mental maps of graph structures. Future research should investigate fine-tuning strategies and hybrid approaches that combine LLM reasoning with external code execution to bridge the gap in algorithmic complexity.
Summary updated