Code Evolution Graphs: Understanding Large Language Model Driven Design of Algorithms

Niki van Stein, Anna V. Kononova, Lars Kotthoff, Thomas BäckarXiv 2025

TL;DR

This paper introduces Code Evolution Graphs (CEGs), a novel visualization and analysis framework that unpacks the "black box" of Large Language Model (LLM) driven algorithm design. By mapping structural and complexity features of code across evolutionary generations, the authors reveal that different LLMs possess distinct, non-overlapping "coding fingerprints" and that repeated prompting consistently drives up code complexity—though more complex code isn't always better.

What Problem Does This Paper Address?

Automated Algorithm Design (AAD) has taken a massive leap forward by embedding LLMs into evolutionary computation loops (e.g., frameworks like LLaMEA or EoH). These systems iteratively prompt LLMs to generate, mutate, and crossover code to solve complex optimization problems.

However, these setups typically operate as black boxes. When the evolutionary process stalls or fails to produce competitive algorithms, researchers have little visibility into why. We lack tools to understand how code structures change over time, how different LLMs explore the "code space," and how structural code properties directly impact algorithmic performance.

Methods

The authors bridge the gap between software engineering metrics and evolutionary computation by introducing Code Evolution Graphs (CEGs).

  1. AST Feature Extraction: For every generated algorithm, the authors parse the source code into an Abstract Syntax Tree (AST). They extract over 20 structural and graph-theoretic features (e.g., node count, edge density, clustering coefficients, and depth entropy) along with standard code complexity metrics like cyclomatic complexity and token counts.
  2. Graph Construction: A CEG is defined as a directed graph $G = (V, E)$, where each node $V$ represents a specific code instance (storing its performance fitness, standardized AST features, and metadata), and directed edges $E$ map the parent-to-child lineage of mutations.
  3. Dimensionality Reduction: To make these massive code trajectories human-readable, the authors project the high-dimensional AST features into 2D spaces using Principal Component Analysis (PCA) and t-SNE.

Datasets

The framework was evaluated across three distinct optimization benchmark tasks:

  • Black-Box Optimization (BBO): Evolving continuous metaheuristics tested on 24 noiseless functions from the standard BBOB suite.
  • Online Bin Packing (OBP): Evolving heuristic scoring rules for real-time combinatorial item placement.
  • Traveling Salesperson Problem (TSP): Evolving strategies to dynamically penalize edges within a Guided Local Search (GLS) framework.

Key Insights and Ideas

  • LLM Coding Fingerprints: t-SNE projections reveal that different LLMs (GPT-4, GPT-4o, GPT-3.5) occupy completely distinct, non-overlapping regions of the code feature space. Each model has a unique structural "style" when generating code.
  • The Multi-LLM Advantage: Because different models possess distinct fingerprints, the authors suggest that mixing multiple LLMs within a single evolutionary framework could prevent stagnation by injecting much-needed structural diversity.
  • Complexity Creep: Across almost all frameworks, repeated prompting and evolution lead to an upward trend in code complexity and token counts.
  • Task-Dependent Complexity Returns: More complex code is not universally better. While higher complexity strongly correlates with better fitness in BBO and OBP tasks, the opposite is true for TSP, where simpler code structures actually yielded superior performance.

Key Results

The t-SNE visualization clearly demonstrates how distinct the code spaces are for each model configuration, with random search lacking any structured trajectory:

Figure 1: t-SNE visualisation of the 26 code features for dif- ferent LLaMEA configurations, 5 independent runs per con- figuration and 5 Random Search runs. The color denotes the method, different shapes denote different independent runs and different sizes denote different normalized fitness (big- ger is better).

When looking at the actual CEGs for Black-Box Optimization, the authors mapped out how the first principal component of AST features and total token counts evolve over successive evaluations. The graphs highlight the stark difference between LLaMEA's $1+1$ evolutionary strategy (clear lineages) and Random Search (scattered points):

Figure 2: Code Evolution Graphs for LLaMEA using different LLMs and a baseline Random Search on BBO. On the left side are CEGs using the first PCA component of the AST graph metrics on the 𝑦-axis, with the number denoting the fraction of the total variance accounted for by this dimension. On the right side are CEGs using the total token count on the 𝑦-axis. Each row represents a different algorithm configuration (LLM) and each column is one independent run (3 runs in total).

Finally, the authors quantified these relationships using Spearman correlation indices, showing exactly which structural features drive performance across different problem-method combinations:

Figure 5: Spearman correlation index for each code feature (column) with the performance of the algorithms (fitness) for all benchmarks and methods (rows).

Limitations and Future Work

A primary limitation of relying purely on static AST features is that a poorly configured algorithm might share the exact same AST structure as a highly optimized one if the changes are purely parametric. To combat this, the authors suggest integrating dynamic execution features into future iterations of CEGs.

Additionally, given the observed "complexity creep," developing explicit complexity control mechanisms (such as parsimony pressure or diversity-aware mutation operators) is highlighted as a crucial next step to keep LLM-generated code efficient and human-interpretable.

Summary updated

BibTeX
@misc{stein2025code,
  author = {Niki van Stein and Anna V. Kononova and Lars Kotthoff and Thomas Bäck},
  title = {{Code Evolution Graphs: Understanding Large Language Model Driven Design of Algorithms}},
  year = {2025},
  eprint = {2503.16668},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.16668},
}
Figure