---
title: Test-Time Graph Search
url: https://www.emergentmind.com/topics/test-time-graph-search-ttgs
type: topic
---

# Test-Time Graph Search

Test-Time Graph Search (TTGS) denotes a family of inference-time procedures that allocate additional computation to search over graph-structured objects in order to improve planning, adaptation, optimization, or generation without modifying the underlying training pipeline. In current usage, the searched object may be a weighted graph over offline states used for subgoal planning, a test graph that is transformed or restored before inference, a coarsening history mined for violated inequalities, or a collaboration or thought graph that organizes large-model reasoning. Across these variants, TTGS is characterized by post-training search, frozen or minimally changed backbone models, and an explicit attempt to use inference-time structure more effectively than one-shot prediction [2510.07257, 2210.03561, 2510.07762, 2501.10069].

## 1. Terminological scope and formal viewpoints

Across the cited literature, TTGS is not restricted to a single canonical algorithm. The survey on LLM test-time compute via search formalizes search-based inference problems as Markov Decision Processes \( \langle S, A, \mathcal{T}, R \rangle \), with states, actions, transitions, and rewards instantiated differently across reasoning, navigation, planning, and code generation [2501.10069]. In graph-centered work, this abstraction reappears in more specialized forms: weighted state graphs in offline goal-conditioned reinforcement learning, graph transformations and restorations in graph test-time adaptation, coarsening trees in combinatorial optimization, and directed acyclic collaboration graphs in multi-LLM inference [2510.07257, 2210.03561, 2511.00086].

This breadth suggests that TTGS is best understood as an inference-time design pattern rather than a single method. What unifies the family is not the graph’s semantics but the role of search: the method constructs or exposes a graph-structured search space at test time, evaluates candidate trajectories or transformations, and uses the result to improve final prediction or control.

| Setting | Graph object | Test-time operation |
|---|---|---|
| Offline GCRL | Weighted graph over dataset states | Shortest-path search and subgoal dispatch |
| Graph adaptation | Test graph or neighborhood graph | Transformation, alignment, or restoration |
| CVRP separation | Graph coarsening history | Stochastic search and partition mining |
| LLM/VLLM inference | Collaboration or thought graph | Traversal or graph optimization |

## 2. State-graph search for planning and control

In offline goal-conditioned reinforcement learning, TTGS is introduced as a lightweight planning procedure that “accepts any state-space distance or cost signal, builds a weighted graph over dataset states, and performs fast search to assemble a sequence of subgoals that a frozen policy executes” [2510.07257]. Nodes are sampled from the offline dataset, edges are weighted by a chosen cost signal, and shortest paths are computed with Dijkstra’s algorithm. When the base learner is value-based, the distance is derived directly from the learned goal-conditioned value function. For sparse terminal rewards, the paper gives \( V^*(s, g) = \gamma^d \Rightarrow \hat d(s, g) = \log_{\gamma} V^*(s, g) \); for per-step penalties, it gives \( V^*(s, g) = -\frac{1-\gamma^d}{1-\gamma} \Rightarrow \hat d(s, g) = \log_{\gamma}\!\big(1 + (1-\gamma)V^*(s, g)\big) \) [2510.07257].

The operational loop is explicitly hierarchical. TTGS first computes a guide path on the weighted graph, then at each environment step selects the farthest subgoal along that path that remains within a dynamic step budget \( T \), and finally conditions the frozen policy on that subgoal. Long edges are discouraged by a superlinear penalty,
\[
p(D_{ij}) = D_{ij} \cdot 1000^{D_{ij}/\tau},
\]
which preserves local geometric fidelity while suppressing unreliable shortcuts [2510.07257]. On OGBench, the method improves success rates of multiple base learners on challenging locomotion tasks; specific examples reported include HIQL on pointmaze-giant-stitch-v0 improving from \(0.0\%\) to \(80.9\%\), GCIQL on the same task improving from \(0.0\%\) to \(98.0\%\), and HIQL on humanoidmaze-giant-stitch-v0 improving from \(4.4\%\) to \(78.1\%\). The overhead is reported as approximately \(45\) seconds for graph construction in state-based environments, approximately \(100\) seconds in visual environments, approximately \(0.8\) seconds for shortest-path computation once per episode, and approximately \(1\) ms per action-selection step [2510.07257].

A related but distinct line of work learns search heuristics rather than performing explicit inference-time graph planning. PHIL learns a GNN-based heuristic usable inside A* or greedy best-first search, with evaluation function \( f(v) = g(v) + \hat h_\theta(v; z_t, G) \), constant-time heuristic computation relative to graph size under bounded neighborhoods, and a reported \(58.5\%\) average reduction in explored nodes relative to state-of-the-art methods [2212.03978]. This is not presented as TTGS proper, but it clarifies the relationship between learned graph priors and classical search at inference.

## 3. Test-time modification of the input graph

A major branch of TTGS treats the graph presented at inference as the object of search or adaptation. GTrans takes a data-centric position: rather than adapting the model, it refines the test graph itself before inference. With a pretrained GNN \( f_\theta \) fixed, it seeks graph modifications \( (\mathbf{A}', \mathbf{X}') \) by solving
\[
\underset{g}{\arg\min}\; \mathcal{L}\big(f_\theta^*(g(G_\text{Te})), \mathcal{Y}_\text{Te}\big), \quad \text{s.t. } g(G_\text{Te}) \in \mathcal{P}(G_\text{Te}),
\]
and replaces unavailable test labels with a parameter-free contrastive surrogate loss [2210.03561]. The paper proves that if the gradients of the surrogate loss and true classification loss with respect to the graph are positively correlated, then optimizing the surrogate reduces the true test loss. Empirically, GTrans reports improvements “up to \(2.8\%\), \(8.2\%\) and \(3.8\%\) over the best baselines on three experimental settings,” covering distribution shift, abnormal features, and adversarial attacks [2210.03561].

Test-Time Structural Alignment (TSA) narrows the focus to structural distribution shift in graphs and aligns graph structures during inference without source data, except for summary statistics [2502.18334]. Its central reweighting rule is
\[
\gamma_{i,j} = \frac{P_s(Y_v=j \mid Y_u=i, v \in N_u)}{P_t(Y_v=j \mid Y_u=i, v \in N_u)},
\]
applied only when pseudo-label entropy is sufficiently low, \( H(\hat y_u) \leq \rho_1 \cdot \ln |\mathcal{Y}| \), in order to avoid noisy assignments [2502.18334]. TSA complements this neighborhood alignment with adaptive balancing between self-node and aggregated neighborhood representations through a degree-dependent coefficient \( [\alpha]_k \), and with decision-boundary refinement via standard non-graph TTA schemes. The paper reports consistent outperformance over both non-graph TTA methods and GTTA baselines, including gains “by up to \(12\%\) in accuracy” on synthetic CSBM settings dominated by neighborhood shift [2502.18334].

GRAIL extends this direction by recasting Test-Time Graph Domain Adaptation as generative graph restoration: the target graph is “restored” to a source-domain-like state without source examples [2510.07762]. The pipeline first compresses variable-size node embeddings with a Q-Former, then models restoration as the reverse of a graph diffusion process,
\[
Z_0 \xrightarrow{\phi} Z_1 \xrightarrow{\phi} \cdots \xrightarrow{\phi} Z_t \xrightarrow{\psi} \hat Z_{t-1} \xrightarrow{\psi} \cdots \xrightarrow{\psi} \hat Z_0,
\]
quantizes the restoration trajectory into discrete tokens, and fine-tunes an LLM to autoregressively generate restoration token sequences [2510.07762]. A reinforcement-learning stage further optimizes restoration with an alignment reward based on Maximum Mean Discrepancy and a confidence reward based on negative entropy of the source GNN’s predictions. The reported outcome is that GRAIL “significantly outperforms prior TT-GDA baselines across six cross-domain benchmarks,” with “Macro-F1 increases by \(>2\%\) over next-best,” while ablations show performance drops when the encoder, diffusion, or either reward is removed [2510.07762]. In the authors’ comparison, this is presented as a trajectory-based restoration view of TTGS rather than static augmentation or patching.

## 4. Coarsening histories and combinatorial optimization

TTGS also appears in combinatorial optimization, where the graph being searched is not the input graph to a predictor but the sequence of graph contractions induced by a neural separation procedure. In neural graph coarsening for the Capacitated Vehicle Routing Problem, deterministic greedy contraction yields highly correlated candidate subsets and therefore low cut diversity [2510.00958]. To address this, stochasticity is introduced into edge selection through
\[
\tilde q_{ij} = q_{ij} + \pi_{ij}, \qquad \pi_{ij} \sim \mathcal{U}(0, 0.001),
\]
with
\[
q_{ij} =
\begin{cases}
p_i p_j + (1-p_i)(1-p_j), & i,j \neq 0,\\
0, & \text{otherwise}.
\end{cases}
\]
Multiple stochastic runs then generate a more diverse pool of subsets at test time [2510.00958].

The second component, Graph Coarsening History-based Partitioning (GraphCHiP), exploits the full coarsening history to separate both Rounded Capacity Inequalities and, “for the first time,” Framed capacity inequalities via a neural approach [2510.00958]. For RCIs it checks subsets \( h = \mathcal{M}_t(u) \) against
\[
x(\delta(h)) < 2 \left\lceil \frac{d(h)}{Q} \right\rceil,
\]
and for FCIs it checks partitions \( \Omega = \{S_1,\dots,S_k\} \) using
\[
x(\delta(H)) + \sum_{i \in I} x(\delta(S_i)) < 2 r(\Omega) + 2 \sum_{i \in I} \left\lceil \frac{d(S_i)}{Q} \right\rceil.
\]
The reported worst-case number of RCI checks is \( \frac{\gamma}{1-\gamma}|V| \), while FCI separation has time complexity \( O(|V|(\log |V|)^2) \) [2510.00958]. Experiments report dual-gap reductions “by up to \(2\)–\(3\) percentage points,” a \(10\)–\(40\%\) increase in the average number of RCI cuts found on large instances, and on the real-world instance X-n153-k22 the discovery of \(324\) FCIs versus \(4\) for CVRPSEP, improving the dual gap “by over \(1\%\)” [2510.00958]. Here, TTGS is distinctly stochastic, search-based, and test-time-only: the gains are obtained without retraining the separator.

## 5. Graph-structured test-time compute in language and multimodal models

The LLM test-time compute literature provides a more general vocabulary for TTGS-like procedures. The survey on LLM inference via search defines modular “profiled roles” for the model—policy, transition model, and evaluator—and decomposes search into sampling, evaluation, simulation, selection, expansion, and backpropagation procedures [2501.10069]. Classical algorithms such as BFS, DFS, best-first search, A*, and MCTS are then adapted to settings with open-ended action spaces and LLM-generated successors. The survey emphasizes that these systems often depart from standard algorithmic guarantees because action spaces are not enumerable and LMPR-based heuristics may be non-admissible; it also notes that tree search is often “\(10\)-\(20\times\) slower than iterative refinement” and that evaluator quality can become the principal bottleneck [2501.10069].

One direct graph formulation of test-time scaling defines inference as search over a multi-LLM collaboration graph, a DAG
\[
G = (\mathcal{V}, \mathcal{E}, \mathbf{R}, \mathbf{M}),
\]
whose nodes encode both roles and model assignments, and whose edges encode information flow [2511.00086]. The optimization problem is
\[
G^\star = \arg\max_{G \in \mathcal{G}(\mathcal{M}, B)} u_T(G; \mathcal{D}_{\text{train}}),
\]
subject to a budget constraint, with graph cost modeled as
\[
f_{\text{cost}}(G, T) = \sum_{v_i \in \mathcal{V}} \left[\alpha_i\, d(v_i)^2 + \beta_i\, d(v_i) + \gamma_i\right].
\]
The search space is explicitly described as combinatorially prohibitive: with realistic node counts and model pools, the number of candidate graphs is estimated between \(10^{18}\) and \(10^{26}\) [2511.00086]. Agent-REINFORCE addresses this with probabilistic graph optimization and LLM-generated textual feedback. The reported headline results show higher sample efficiency and stronger final performance than several baselines; on MATH, MMLU, and HumanEval the paper reports \(56\), \(54\), and \(73\), respectively, versus \(39\), \(44\), and \(63\) for random search [2511.00086].

A more domain-specific example is Thought Graph Traversal for radiology report generation. TGT constructs a hierarchical graph with a root node for the case, first-level organ nodes, and second-level diagnostic-question nodes, then traverses this structure at test time to query organ-specific findings, verify answers, retrieve organ-specific in-context examples, and synthesize organ-level report segments [2506.11989]. The method adds a reasoning-budget forcing mechanism that increases inference depth without changing the underlying model. On IU X-Ray with HuatuoGPT-Vision, BLEU-4 rises from \(1.14\) in zero-shot prompting and \(9.90\) in few-shot prompting to \(12.14\) with TGT; on MIMIC-CXR the corresponding TGT BLEU-4 is \(11.34\) [2506.11989]. The paper also reports that report quality is sensitive to organ order, with ROUGE-L correlated with deviation from expert ordering at Spearman \( \rho = -0.6163 \), exposing dataset-level structural biases [2506.11989].

## 6. Representation, diversity, and recurrent limitations

Several adjacent results clarify why some TTGS procedures scale better than others. In autoregressive image generation, search efficiency depends strongly on token structure: 1D ordered, coarse-to-fine tokens yield semantically meaningful intermediate prefixes that verifiers can evaluate, whereas 2D grid tokens often do not [2604.15453]. Under beam search on COCO, the paper reports that beam search improves FlexTok by “\(+13\) pts CLIPScore,” but only “\(+2.5\)” for grid tokens; on ImageNet the reported gains are “\(+10.4\) (1D ordered) vs. \(+3.5\) (2D grid)” [2604.15453]. The authors further show that, thanks to ordered structure, “pure test-time search over token sequences” can perform training-free text-to-image generation when guided by a verifier [2604.15453]. A plausible implication is that TTGS effectiveness depends not only on the search algorithm but also on whether partial states are semantically legible to the evaluator.

Diversity of candidate solutions is another recurrent constraint. Vector Policy Optimization replaces scalar-reward post-training with a set-level objective
\[
R(S) = \mathbb{E}_{w \sim \mathrm{Dir}(\alpha)} \left[ \max_{y \in S} w^\top r(x,y) \right],
\]
so that different outputs in a candidate set specialize to different reward trade-offs [2605.22817]. The paper reports that VPO “matches or beats the strongest scalar RL baselines on test-time search (e.g. pass@k and best@k), with the gap widening as the search budget grows,” and that in evolutionary search it “unlock[s] problems that GRPO models cannot solve at all” [2605.22817]. This suggests that in TTGS regimes based on sampling, pruning, or evolutionary selection, upstream training that preserves output diversity can be as important as the search procedure itself.

A common misconception is that TTGS is merely classical graph search executed at inference. The surveyed literature indicates otherwise. Many methods are source-free or training-free at deployment, but they rely on learned value functions, learned evaluators, learned tokenizations, or learned graph priors; many also depart substantially from textbook A* or MCTS because their action spaces are generated rather than enumerated, their heuristics are non-admissible, or their verifiers are imperfect [2501.10069]. The principal recurring failure modes are likewise heterogeneous: inaccurate value estimation and sparse dataset coverage in offline GCRL, unreliable pseudo-labels in structural alignment, verifier hacking in generative search, and low candidate diversity in stochastic search. In this sense, TTGS is less a single algorithmic object than a broad inference-time methodology for exploiting graph structure whenever one-shot prediction is insufficient.

Source: https://www.emergentmind.com/topics/test-time-graph-search-ttgs