Counting Cycles with AI

Jiashun Jin, Tracy Ke, Bingcheng Sui, Zhenggang WangAI4Research @ ICML 2026

TL;DR

Researchers have developed a "humAI" approach—a collaboration between human mathematical intuition and AI’s coding prowess—to solve a long-standing problem in graph theory: deriving computationally efficient formulas for counting long cycles in networks. By guiding models like DeepSeek-R1 through complex combinatorics, they produced new formulas for cycles up to length 12, significantly outperforming traditional brute-force methods and human-only derivations.

What Problem Does This Paper Address?

In network analysis, counting cycles (closed paths of length $m$) is a fundamental task used to detect "spikes" or signals in noisy data. The "cycle count statistic" ($C_m$) is easy to define but notoriously difficult to compute.

A brute-force approach requires $m$ nested loops, resulting in a computational complexity of $O(n^m)$, which is impossible for large networks and long cycles. Mathematicians seek a Computationally Efficient Equivalent Form (CEEF)—a formula that expresses $C_m$ using simple matrix operations (like traces and Hadamard products) that run in $O(n^3)$ or $O(n^4)$ time.

While humans solved this for small $m$ (up to $m=7$), the complexity explodes as $m$ increases. For example, the formula for $C_{12}$ involves 1,900 distinct terms. Deriving these by hand is an algebraic nightmare where a single typo invalidates the entire result.

Methods

The authors propose a two-step humAI pipeline that treats the AI as a high-level research assistant and coder:

  1. The Merging Process: Humans defined a new framework called Fully Annotated Multi-graphs (FAM). The AI was prompted to generate all possible ways to "merge" nodes in a cycle to create these multi-graphs. Interestingly, the AI (DeepSeek-R1) independently suggested using Möbius inversion on partition lattices to find the correct linear coefficients for the formula—a high-level "Researcher" (Level-R) insight.
  2. The Pruning Process: The authors developed a recursive algorithm to simplify these multi-graphs. They defined "Type-I" and "Type-II" pendant nodes that can be "pruned" to reduce the layers of summation. The AI was tasked with writing the complex Python scripts to implement this pruning logic and output the final formula in LaTeX.

The paper categorizes AI intelligence into three levels: Level-C (Coder) for implementation, Level-A (Assistant) for following step-by-step logic, and Level-R (Researcher) for discovering mathematical connections.

Datasets

As a theoretical and algorithmic paper, the "datasets" consist of:

  • Synthetic Matrices: Gaussian Orthogonal Ensemble (GOE) matrices were used to numerically validate the formulas.
  • Benchmark Algorithms: A Dynamic Programming (DP) approach served as the ground truth for $C_m$ on small matrices ($n \le 16$).
  • LLM Evaluation: The authors tested 11 different models, including DeepSeek-R1, Claude 3.5/4, and GPT-series models, to see which could handle the multi-stage reasoning required.

Key Insights and Ideas

  • The "humAI" Synergy: The paper proves that AI cannot solve open math problems in a "zero-shot" manner. However, when a human provides the "scaffolding" (the graph-theoretic strategy), the AI can execute the "tedious" parts that are prone to human error.
  • Möbius Discovery: One of the most surprising moments was the AI identifying the connection between the cycle count coefficients and the Möbius function on partition lattices, which the human researchers hadn't initially realized.
  • SEA vs. IFS: The paper formalizes two types of terms: Succinct Expressive Algebraic (SEA) terms (computable via matrix ops) and Incompressible Full Sum (IFS) terms (which require some summation but are still much faster than brute force).
  • Higher-Order Utility: They found that using higher-order cycles (e.g., $m=12$) provides significantly better "testing power" for detecting signals in noise compared to the standard $m=3$ or $m=4$ cycles used in most literature.

Key Results

  • New Formulas: The team successfully derived CEEF formulas for $m=3$ up to $m=12$. The $C_{12}$ formula contains 1,666 SEA terms and several IFS terms.
  • Numerical Accuracy: The AI-generated formulas were validated against the DP benchmark, showing discrepancies of less than $10^{-8}$, confirming their correctness.
  • Performance Gain: In signal detection tasks (weak-spike testing), the error rate dropped from ~0.410 at $m=1$ to ~0.130 at $m=12$, proving that the ability to compute these complex formulas has immediate practical applications in statistics.
  • Model Comparison: DeepSeek-R1 and the Claude 3.5/4 series were highly successful, while some other models (like DeepSeek V3.2) failed even the initial merging tasks.

Limitations and Future Work

  • Incompressibility: Not every term can be reduced to a simple matrix trace. Some "IFS" terms still require $O(n^\ell)$ sums where $\ell \le \lfloor m/2 \rfloor$. For $C_{12}$, this means some terms are $O(n^6)$.
  • Human Dependency: The process still requires a human "Researcher" to divide the problem into tasks and write the initial prompts. The authors suggest future work could involve AI taking over more of the "Level-R" strategy formulation.
  • Generalization: While they solved the cycle count problem, applying this "humAI" pipeline to other combinatorial problems (like counting other subgraphs or motifs) remains an open challenge.

Summary updated

BibTeX
@inproceedings{jin2026counting,
  author = {Jiashun Jin and Tracy Ke and Bingcheng Sui and Zhenggang Wang},
  title = {{Counting Cycles with AI}},
  booktitle = {AI4Research @ ICML},
  year = {2026},
  url = {https://openreview.net/forum?id=6rwZo0k4lz},
}
Figure