ACL 2025 · Main · CCF-A

Can Graph Descriptive Order Affect Solving Graph Problems with LLMs?

Edges have no order — yet a prompt must list them one by one. We show that hidden choice quietly changes what an LLM understands, and how to order it well.

1Institute of Computing Technology, Chinese Academy of Sciences  ·  2UC Merced  ·  3University of Science and Technology of China  ·  4Tsinghua University
† Corresponding author
Scroll
The one-graph story

Same graph. Same question.
Reorder the edges — the answer flips.

Ask an LLM "is there a cycle in this graph?" List the edges in a random order and GPT scores 64.50%. Feed the very same edges in BFS order and it jumps to 72.71%. Nothing changed but the sequence — and the model was never even told an order exists.

The intuition

A graph is a set — but you must describe it as a sequence.

Take a benzene ring. List its bonds in ring order and you see it instantly; shuffle them and you have to reassemble it in your head. LLMs are no different — yet edge order is a choice every graph prompt makes silently.

Random ordershuffled bonds
Bonds land scattered — you only recognize the ring after mentally reassembling them.
Ring ordereach bond continues the last
The ring traces itself — the structure is obvious from the very first bonds.
Interactive

Reorder the same graph, watch the description change.

This is the graph from the paper. Pick a strategy: the traversal replays on the graph while the edge list the LLM reads is rebuilt — random scatters the hub, ordered strategies surface the structure first.

Description order

Random

Edges in arbitrary order — the model must reconstruct the structure with no hints.

Question: "Is there a cycle?" Random 64.50% → BFS 72.71%
Method

Encode → reorder → prompt → solve.

We serialize a graph to an edge list, permute that list by a chosen strategy, wrap it in the task prompt with zero-shot CoT, and measure accuracy — without ever telling the model an order was applied.

Step 1 · Encode

Graph → edges

"(i, j) means node i and node j are connected." A plain edge list.

Step 2 · Reorder

Permute by f

Apply BFS / DFS / PageRank / PPR — or random as the baseline.

Step 3 · Prompt

Ask + CoT

Append the task question and "let's think step by step." Order is never disclosed.

Step 4 · Solve

Measure

Score across 6 graph tasks × 6 mainstream LLMs.

The six graph tasks — one graph, six questions

Same eight-node graph throughout. Pick a task and watch what the question actually asks the model to trace — from a single local hop to a global tour. The harder the trace, the more the edge order matters.

Graph task

Connectivity

Is there a path between two nodes?

Results

Order helps almost everywhere.

Across the six tasks and six models, ordered descriptions top the random baseline — and the gains grow with task difficulty. The smallest effect is on the easiest, most local tasks; the largest on global, structure-tracing ones.

0
Graph tasks
0
Mainstream LLMs
0
Ordering strategies
0
Peak gain · PageRank on Pubmed
Same graphs, same model (GPT-3.5) — only the edge order changes. Random baseline vs the best order per task (avg. accuracy over prompt styles):
Connectivity local · BFS best
Random
78.36%
BFS
89.43%  ▲ +11.07
Cycle detection local · BFS best
Random
64.50%
BFS
72.71%  ▲ +8.21
Shortest path global · BFS best
Random
30.14%
BFS
51.29%  ▲ +21.15
Topological sort global · DFS best
Random
46.93%
DFS
63.21%  ▲ +16.28
Hamilton path global · DFS best
Random
31.50%
DFS
52.43%  ▲ +20.93
PROBABILITY > TRAVERSAL

PageRank & PPR lead

Probability-based orders generally beat traversal-based BFS/DFS, with the biggest node-classification gains.

COMPLEXITY ⇒ SENSITIVITY

Hard tasks swing more

Connectivity & cycle are robust; shortest path, Hamilton path and topological sort move the most with order.

ROBUST TO PROMPTING

Holds across prompts

Zero-shot, few-shot or CoT — the ordering benefit persists in every prompting regime.

Deep-dive · is it just path overlap?

We added two probe orders — Shortest-path and Longest-path. The shortest order (highest overlap with the answer path) wins; the longest (lowest overlap) loses, sometimes dropping below random. But overlap isn't the whole story: DFS overlaps the answer more than BFS, yet BFS still wins — so a structure-aware order genuinely improves the model's understanding, not just its luck.

Shortest BFS DFS Random Longest
The hypothesis

It's attention bias — and it's actionable.

Why does it help? The paper's hypothesis: positional encodings can't fully capture an unordered edge set, so attention gives undue priority to some positions over others — and a scattered description becomes hard to follow. Reordering the edges so the structure reads coherently works with that bias instead of against it.

Position-based attention is uneven across the sequence; the four tokens are the edges that define the structure.
token 1 · first edge readlast edge read
Attention on structural edges
0%

In a random order, the structural edges scatter across positions — some land where attention is low, so the structure is easy to miss.

The fix is free: reorder the edges before you ask. And the right order is task-shaped — connectivity wants a local view, a Hamiltonian path wants a global one — so the best strategy follows the task, not a single rule.

Citation

Cite GraphDO

@inproceedings{ge2025graphdo,
  title     = {Can Graph Descriptive Order Affect Solving Graph Problems with LLMs?},
  author    = {Yuyao Ge and Shenghua Liu and Baolong Bi and Yiwei Wang and
               Lingrui Mei and Wenjie Feng and Lizhe Chen and Xueqi Cheng},
  booktitle = {Proceedings of the 63rd Annual Meeting of the Association for
               Computational Linguistics (ACL)},
  year      = {2025},
  url       = {https://aclanthology.org/2025.acl-long.321/}
}