NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Visual Graph Reasoning via Knowledge Compilation

Rongzheng Wang, Zhe Wang, Ke Qin, Rongwei Wang, Muquan Li, Yizhuo Ma, Yihong Huang, Jielei Wang, Shuang LiangarXiv 2026

TL;DR

Current vision-language models struggle with visual graph reasoning because they try to guess answers directly from images rather than explicitly parsing the underlying graph structure. To fix this, the authors introduce VGCompiler, a framework that generates executable Python code split into a representation compiler (extracting the graph structure) and an operation compiler (running the graph algorithm). Built on an 8B parameter open-source model, VGCompiler outperforms massive closed-source models by up to 28.9% while maintaining high efficiency.

What Problem Does This Paper Address?

Visual graph reasoning tasks ask a model to answer graph-theoretic questions—such as reachability, shortest paths, or cycle detection—directly from an image. While humans do this easily by following lines and nodes visually, state-of-the-art Vision-Language Models (VLMs) like GPT-4 or Gemini frequently fail, even on simple graphs.

The authors identify two core bottlenecks:

  1. Graph style sensitivity: Minor changes in layout, color, or node shapes break the VLM's ability to perceive the structure.
  2. Graph state sensitivity: Different graph states (e.g., weighted vs. unweighted, directed vs. undirected) require entirely different algorithms, but VLMs struggle to match their internal reasoning steps to these implicit states.

Existing approaches try to map the image directly to the final answer, bypassing the explicit recovery of the graph's topology. As a result, they often produce plausible-sounding but incorrect answers based on flawed structural understanding.

Figure 1: Representative visual graph examples together with a simple reachability evaluation across mainstream VLMs.

Methods

The authors frame visual graph reasoning as a knowledge compilation problem, translating the "weak source language" (the image) into a structured target representation (an attributed adjacency list) and an executable program.

  • Dual-Compiler Architecture: VGCompiler generates code consisting of two blocks: a c_rep (representation compiler) to parse the image into a standardized Python adjacency list, and a c_op (operation compiler) to execute the specific graph algorithm required by the query.
  • Frozen Observer & Code Archive: A frozen VLM acts as an observer to generate a lightweight "condition signature" for the graph style and question type. This signature is used to retrieve and reuse similar code from a dynamic archive, avoiding the need to rewrite code from scratch for similar problems.
  • Layered Objective for Representation and Operation (LORO): Instead of training the model purely on final-answer correctness, the authors use Reinforcement Learning (RL) with a gated, layered reward. The reward checks: Is the code executable? Does it yield a valid graph object? Is the extracted topology accurate? Only if these conditions are met does the model receive full credit for final answer correctness. This prevents the model from finding "shortcut" answers from incomplete graphs.

Datasets

The model was evaluated on three public synthetic benchmarks:

  • GVLQA (Base & AUG): Tests basic graph-theoretic tasks under clean and perturbed rendering styles.
  • VisionGraph: Focuses on node and edge recognition.
  • VGCURE: Evaluates fundamental graph understanding and relation-based reasoning.

Additionally, the authors introduced a new real-world generalization benchmark spanning three distinct domains: metro routing, logistics delivery, and network fault assessment.

Key Insights and Ideas

  • Decoupling Perception from Logic: Trying to make a neural network perform visual perception and execute complex graph algorithms simultaneously in a single forward pass is incredibly brittle. Delegating the algorithmic execution to deterministic code ensures perfect logic once the structure is correctly parsed.
  • The Power of Attributed Adjacency Lists: The authors found that compiling graphs into adjacency lists works significantly better than adjacency matrices or edge lists. Adjacency lists naturally preserve local neighborhood structures, making them more robust to visual layout variations.
  • Gated Rewards Prevent Cheating: Standard RL often suffers from "reward hacking" where models guess the right answer for the wrong reasons. LORO's strict gating ensures the model must get the graph structure right to receive full semantic credit.

Key Results

  • State-of-the-Art Performance: Built on the 8B Qwen3-VL backbone, Qwen-VGCompiler achieved an average accuracy of 91.72%, outperforming the strongest closed-source VLM baseline (Gemini-3.1-pro at 62.83%) by 28.9% and the best code-based baseline (DPR) by 23.7%.
  • Robustness to Style: On the perturbed GVLQA-AUG benchmark, VGCompiler maintained high accuracy, while standard VLMs degraded significantly under layout and style shifts.
  • Efficiency: VGCompiler achieved an average inference latency of 7.7 seconds, nearly twice as fast as Gemini-3.1-pro (13.1s) and DPR (18.9s), thanks to efficient code reuse via the archive.

Limitations and Future Work

The authors note that logistics delivery remains the most challenging real-world domain, as it requires handling complex capacity constraints alongside visual parsing. Future work could explore scaling this compilation paradigm to larger, more complex heterogeneous networks and integrating more diverse algorithmic toolkits to handle broader reasoning tasks.

Summary updated

BibTeX
@misc{wang2026visual,
  author = {Rongzheng Wang and Zhe Wang and Ke Qin and Rongwei Wang and Muquan Li and Yizhuo Ma and Yihong Huang and Jielei Wang and Shuang Liang},
  title = {{Visual Graph Reasoning via Knowledge Compilation}},
  year = {2026},
  eprint = {2609.22327},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2609.22327},
}
Figure