Manuscript Offprint

arXiv:2609.07204

Agentic Algorithm Engineering: Improving Shared-Memory Exact Minimum Cuts

David A. Bader, Adil Chhabra, Ernestine Großmann, Monika Henzinger, Alexander Noe, Christian Schulz

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

The minimum cut problem for an undirected edge-weighted graph asks us to divide its set of nodes into two blocks while minimizing the weighted sum of the cut edges. Over the last years, we engineered a range of fast algorithms for this problem. Our fastest exact algorithm uses an inexact algorithm to obtain a better bound for the problem, reductions that depend on this bound, improved data structures and parallel contraction routines. It is available in the open-source package VieCut and, on real-world instances, outperformed the previously fastest solvers by a factor of up to 2.5 sequentially and up to 12.9 when run in parallel.

We improve this algorithm using agentic algorithm engineering (AAE), a methodology that we introduce here, in which autonomous large language model agents run the algorithm engineering cycle on an existing code base: they form hypotheses about where running time is lost, implement them, benchmark the result on a fixed instance set and keep or discard the change. Even though we had already tuned our algorithm by hand extensively, the agent finds significant optimizations, in particular on the DIMACS core instances: factors of 1.28 (sequential) and 1.63 (32 threads) on real-world k-cores, and 6.26 and 127 on the DIMACS core instances.

1 Introduction

Given an undirected graph with non-negative edge weights, the minimum cut problem asks for a partition of the vertices into two sets that minimizes the total weight of the edges between them; its value is also called the edge connectivity of the graph [36, 26]. Minimum cuts are used in network reliability [28, 43], VLSI design [31] and as a subroutine in branch-and-cut algorithms for the traveling salesman and other combinatorial problems [40], so they have to be computed quickly on large inputs. All exact algorithms have non-linear running time, and those of Hao et al. [20] and Nagamochi et al. [36, 37], which are orders of magnitude faster than the others in practice [9, 24, 27], do not parallelize easily. Appendix A surveys related work.

Over the last years, we engineered a range of algorithms for the minimum cut problem and its variants. We first gave a practical shared-memory parallel heuristic algorithm, available in the open-source package VieCut [24, 25], which computes near-optimal and often exact minimum cuts very quickly. We then used this algorithm to obtain a better bound λ^\hat{\lambda} and engineered a shared-memory parallel exact algorithm [23] on top of it. It outperformed the previously fastest solvers, the implementations of the algorithms of Nagamochi et al. and of Hao and Orlin, by a factor of up to 2.5 sequentially and up to 12.9 when run in parallel on real-world instances.

*New Jersey Institute of Technology, Newark, NJ, USA †Heidelberg University, Heidelberg, Germany. Christian Schulz is the corresponding author. ‡Institute of Science and Technology Austria (ISTA), Klosterneuburg, Austria §Amazon.com, New York, NY, USA. Work done prior to joining Amazon.

Recently, large language models (LLMs) have been used not only to generate code, but also to discover and improve algorithms [45, 38]. This includes low-level optimizations that so far required a large amount of manual work. We use the algorithm engineering methodology as a starting point and introduce agentic algorithm engineering, a methodology in which autonomous LLM agents run the algorithm engineering cycle on an existing code base. The agent receives the code and a fixed set of benchmark instances, and modifies the code to make it faster on the whole set rather than on a single instance. Unlike classical auto-tuning [2], which searches a fixed parameter space of an unchanged code, the agent modifies the code itself, reaching changes without a tuning knob, such as replacing a data structure or repartitioning parallel work.

Contribution. First, we summarize our shared-memory parallel exact minimum cut algorithm [23] in a self-contained way. Second, we introduce agentic algorithm engineering (AAE), in which an autonomous LLM agent runs the algorithm engineering cycle on an existing code base: it inspects the code and the experimental infrastructure, forms hypotheses about where running time is lost, implements candidate optimizations and benchmarks them on a fixed set of instances. Improvements are kept as the starting point of the next round; the rest is discarded together with the reason for its failure, so that later iterations can build on it. Third, we run the agent, Claude Opus 5 [3], on our exact algorithm on the challenge instances and on the instances of the original publication. It finds further optimizations, factors of 1.28 sequentially and 1.63 at 32 threads on the real-world k-cores, and 6.26 and 127 on the DIMACS core instances, for about $350 in API usage (1.1 million output tokens). The agent tunes on the same 53 instances on which we report these speedups; we ask how much an agent gains by tuning a hand-optimized code to a given workload, not how the result fares on unseen instances (Section 4.1).

References (39)