GraphEval36K: Benchmarking Coding and Reasoning Capabilities of Large Language Models on Graph Datasets

Qiming Wu, Zichen Chen, Will Corcoran, Misha Sra, Ambuj K. Singh

TL;DR

Researchers have introduced GraphEval36K, a new benchmark specifically designed to test how well Large Language Models (LLMs) can solve complex graph problems through code generation. Alongside the dataset, they propose Structured Symbolic Decomposition (SSD), a prompting strategy that significantly boosts LLM performance by breaking down complex reasoning into manageable "cognitive" and "action" steps.

What Problem Does This Paper Address?

While LLMs have mastered many natural language tasks, they often stumble when dealing with structured data, particularly graphs. Solving a graph problem requires more than just knowing a definition; it requires algorithmic reasoning, pathfinding, and the ability to translate these concepts into executable code.

Existing benchmarks often focus on simple natural language queries (e.g., "Is this graph connected?") or are limited to very small, toy-like graphs. There is a clear gap in evaluating how LLMs handle professional-level coding challenges involving diverse graph structures—like sparse, dense, or power-law graphs—that are common in real-world engineering and research.

Methods

The authors developed a two-pronged approach: a robust evaluation framework and a novel prompting technique.

  1. Evaluation Framework: The team built a pipeline that takes a problem statement, data examples, and a code framework, feeds them to an LLM, and then automatically evaluates the generated code against thousands of test cases. Unlike platforms like LeetCode, this framework provides immediate feedback on failed test cases to help analyze model failures.

    Figure 1: Overview of the Evaluation Framework. For each problem, we input problem statement, data examples, and code framework to LLMs. The LLMs generate the corresponding code and provide explanations. Finally, we evaluate the code on GraphEval36K and return the score details.
  2. Structured Symbolic Decomposition (SSD): To help models navigate complex tasks, the authors introduced SSD. This method forces the model to follow a specific four-part structure:

  3. Problem Clarification: Understanding inputs/outputs and constraints.
  4. Problem Breakdown: Decomposing the task into symbolic sub-problems.
  5. Solution Formulation: Defining the specific algorithms (e.g., BFS, DFS) for each sub-problem.
  6. Program Implementation: Writing the actual code and verifying it against examples.

Datasets

The primary contribution is GraphEval36K, which consists of:

  • 40 coding problems sourced from LeetCode, balanced between directed and undirected graphs.
  • 36,900 test cases covering a wide spectrum of graph types, including Sparse, Planar, Regular, Dense, Complete, Small-world, Erdos-Renyi, and Power-law graphs.
  • Difficulty levels ranging from Easy to Hard, with a focus on Medium and Hard problems where LLMs currently struggle.
Figure 2: The GraphEval36K dataset is constructed through a pipeline that begins with data collection from code contests (LeetCode). Next, problems are randomly sampled according to their difficulty levels, and corresponding graphs are generated using NetworkX. These graphs are then clustered and labeled based on whether they are connected (c), disconnected (dc), cyclic (cy), or acyclic (acy). Verification steps ensure labeling accuracy, though the exact labels may vary depending on each graph’s characteristics.

Key Insights and Ideas

  • The "Private Model" Lead is Shrinking: While private models like GPT-4o still lead, open-source models like DeepSeek-V3 and Qwen2.5-Coder are rapidly closing the gap, even outperforming private models on specific graph types like sparse and planar graphs.
  • Concept Difficulty Variance: LLMs are surprisingly good at "Easy Concepts" like Topological Sorting and Cycle Detection but struggle immensely with "Difficult Concepts" like Path Finding and complex Graph Construction.

    Figure 6: Passing rate of LLMs on graph concepts. Part (a) presents the passing rate on easy concepts, and part (b) presents the passing rate on difficult concepts.
  • Directed vs. Undirected Disparity: Most models perform significantly better on directed graphs. The authors suggest this might be due to the inherent hierarchical structure in directed graphs, which aligns better with the way LLMs process sequential information.

  • Prompting Matters: The success of SSD suggests that the bottleneck for LLMs isn't just "knowledge" of algorithms, but the ability to organize that knowledge into a logical execution plan without "hallucinating" incorrect logic mid-stream.

Key Results

  • SSD Performance Boost: The SSD method improved the average passing rate for GPT-4 by 8.38%, GPT-4o by 6.78%, Gemini-Pro by 29.28%, and Claude-3-Sonnet by 25.28%.
  • Top Performer: GPT-4o emerged as the most robust model, achieving a near-perfect 99% passing rate on complex graph types like Small-world and Power-law when using the SSD method.
  • Efficiency: GPT-3.5 was noted as the most "balanced" model in terms of execution time and memory usage, while Llama-3-70B showed notable inefficiencies in memory consumption despite its high reasoning capabilities.

Limitations and Future Work

The authors acknowledge that while 40 problems is a solid start, it is a relatively small sample compared to massive general coding benchmarks. The fast-paced nature of LLM development also means that newer models (like the o1 series or newer DeepSeek iterations) were not all included in the initial study.

Future work will likely focus on expanding the dataset to include even more diverse graph problems and refining the SSD method to be more automated, perhaps allowing the model to self-correct based on the execution feedback provided by the framework.

Summary updated

BibTeX
@inproceedings{wu2025grapheval,
  author = {Qiming Wu and Zichen Chen and Will Corcoran and Misha Sra and Ambuj K. Singh},
  title = {{GraphEval36K: Benchmarking Coding and Reasoning Capabilities of Large Language Models on Graph Datasets}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  doi = {10.18653/v1/2025.findings-naacl.452},
}
Figure