Papers › Can Language Models Solve Graph Problems in Natural Language?

Can Language Models Solve Graph Problems in Natural Language?

17 May 2023NeurIPS 2023 11arXiv:2305.10037archive 2025-07-28

Heng Wang, Shangbin Feng, Tianxing He, Zhaoxuan Tan, Xiaochuang Han, Yulia Tsvetkov

Large language models (LLMs) are increasingly adopted for a variety of tasks with implicit graphical structures, such as planning in robotics, multi-hop question answering or knowledge probing, structured commonsense reasoning, and more. While LLMs have advanced the state-of-the-art on these tasks with structure implications, whether LLMs could explicitly process textual descriptions of graphs and structures, map them to grounded conceptual spaces, and perform structured operations remains underexplored. To this end, we propose NLGraph (Natural Language Graph), a comprehensive benchmark of graph-based problem solving designed in natural language. NLGraph contains 29,370 problems, covering eight graph reasoning tasks with varying complexity from simple tasks such as connectivity and shortest path up to complex problems such as maximum flow and simulating graph neural networks. We evaluate LLMs (GPT-3/4) with various prompting approaches on the NLGraph benchmark and find that 1) language models do demonstrate preliminary graph reasoning abilities, 2) the benefit of advanced prompting and in-context learning diminishes on more complex graph problems, while 3) LLMs are also (un)surprisingly brittle in the face of spurious correlations in graph and problem settings. We then propose Build-a-Graph Prompting and Algorithmic Prompting, two instruction-based approaches to enhance LLMs in solving natural language graph problems. Build-a-Graph and Algorithmic prompting improve the performance of LLMs on NLGraph by 3.07% to 16.85% across multiple tasks and settings, while how to solve the most complicated graph reasoning tasks in our setup with language models remains an open research question. The NLGraph benchmark and evaluation code are available at https://github.com/Arthur-Heng/NLGraph.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2305.10037")

Code

Syntology Ran 2 of 22 code samples harvested from 1 repository linked to this paper; 20 have no recorded run. Of those that ran: 2 ran · our draft was wrong.

By repository: official repository: 22 samples from 1 repository, 2 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

arthur-heng/nlgraph officialmentioned in papermentioned on GitHubMIT report
Samyu0304/thought-propagation mentioned on GitHubNOASSERTION report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

22 samples harvested; 2 ran; 0 honoured the contract we drafted; 20 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

2ran · our draft was wrong
20unverified

Licence: 0 of the 22 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from arthur-heng/nlgraph. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

translate arthur-heng/nlgraph/evaluation/connectivity.py official repository ran · our draft was wrong MIT (permissive) · fac4585dd50fc9b7 · report
translate arthur-heng/nlgraph/evaluation/cycle.py official repository ran · our draft was wrong MIT (permissive) · 38fdd534407c8c15 · report
check Arthur-Heng/NLGraph/evaluation/hamilton.py official repository unverified MIT (permissive) · 782c581cdb1bbb73 · report
check Arthur-Heng/NLGraph/evaluation/topology.py official repository unverified MIT (permissive) · 5c1d56344deffa84 · report
evaluate Arthur-Heng/NLGraph/evaluation/flow.py official repository unverified MIT (permissive) · daa7ab27ed6a2874 · report
evaluate Arthur-Heng/NLGraph/evaluation/gnn.py official repository unverified MIT (permissive) · 4c51f0221b1060a1 · report
evaluate Arthur-Heng/NLGraph/evaluation/matching.py official repository unverified MIT (permissive) · e3ef6dfd5527c2c2 · report
evaluate Arthur-Heng/NLGraph/evaluation/shortest_path.py official repository unverified MIT (permissive) · 87574d66dd58d6c4 · report
predict Arthur-Heng/NLGraph/evaluation/connectivity.py official repository unverified MIT (permissive) · cbe4067d5b14ce7d · report
predict Arthur-Heng/NLGraph/evaluation/cycle.py official repository unverified MIT (permissive) · dad997d21261794f · report
predict Arthur-Heng/NLGraph/evaluation/flow.py official repository unverified MIT (permissive) · 4d787eb13e705643 · report
predict Arthur-Heng/NLGraph/evaluation/gnn.py official repository unverified MIT (permissive) · d1eee01b3266712e · report
predict Arthur-Heng/NLGraph/evaluation/hamilton.py official repository unverified MIT (permissive) · 50e688855b366fbc · report
predict Arthur-Heng/NLGraph/evaluation/matching.py official repository unverified MIT (permissive) · 755ec6742596b4eb · report
predict Arthur-Heng/NLGraph/evaluation/shortest_path.py official repository unverified MIT (permissive) · 415f590e6388b0be · report
predict Arthur-Heng/NLGraph/evaluation/topology.py official repository unverified MIT (permissive) · f317ee318e2fe255 · report
translate Arthur-Heng/NLGraph/evaluation/flow.py official repository unverified MIT (permissive) · 8e91c3d4139b8193 · report
translate Arthur-Heng/NLGraph/evaluation/gnn.py official repository unverified MIT (permissive) · 04daf61e489de501 · report
translate Arthur-Heng/NLGraph/evaluation/hamilton.py official repository unverified MIT (permissive) · 503a4252204da5ca · report
translate Arthur-Heng/NLGraph/evaluation/matching.py official repository unverified MIT (permissive) · 92ac2d6e4ce50246 · report
translate Arthur-Heng/NLGraph/evaluation/shortest_path.py official repository unverified MIT (permissive) · 8ac657fd99c70d31 · report
translate Arthur-Heng/NLGraph/evaluation/topology.py official repository unverified MIT (permissive) · c8139334cc727e15 · report

Tasks

In-Context LearningKnowledge ProbingMulti-hop Question AnsweringQuestion Answering

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections