Cycling in the forest with Wilson's algorithm

Michaël Fanuel, Rémi Bardenet

Abstract: We consider a probability measure on cycle-rooted spanning forests (CRSFs) introduced by Kenyon. CRSFs are spanning subgraphs, each connected component of which has a unique cycle; they generalize spanning trees. A generalization of Wilson's celebrated CyclePopping algorithm for uniform spanning trees has been proposed for CRSFs, and several concise proofs have been given that the algorithm samples from Kenyon's distribution. In this survey, we flesh out all the details of such a proof of correctness, progressively generalizing a proof by Marchal for spanning trees. This detailed proof has several interests. First, it serves as a modern tutorial on Wilson's algorithm, suitable for applied probability and computer science audiences. Compared to uniform spanning trees, the more sophisticated motivating application to CRSFs brings forth connections to recent research topics such as loop measures, partial rejection sampling, and heaps of cycles. Second, the detailed proof \emph{à la} Marchal yields the law of the time complexity of the sampling algorithm, shedding light on practical situations where the algorithm is expected to run fast.

Introduction

In graph theory and randomized algorithms, Wilson’s algorithm is the gold standard for sampling Uniform Spanning Trees (USTs). It is renowned for its elegance and efficiency, utilizing a process known as "loop-erased random walks." However, many modern problems in data science and physics require sampling more complex structures, such as Cycle-Rooted Spanning Forests (CRSFs).

A CRSF is a spanning subgraph where every connected component contains exactly one cycle. These structures generalize spanning trees and are often weighted by a U(1)-connection, which can represent physical phenomena like magnetic fields or geometric properties like relative rotations in 3D point clouds. While a version of Wilson's algorithm for CRSFs was proposed by Kenyon in 2011, the existing proofs of its correctness were often concise or required high-level expertise. This work provides a detailed, accessible guide to the algorithm, its correctness, and its time complexity.

Examples of Cycle-Rooted Spanning Forests (CRSFs) on a grid graph, where each component contains exactly one cycle.

The CyclePopping Algorithm

The core of the sampling process is Algorithm 1: CyclePopping. The procedure follows a simple yet powerful logic:

  1. Initialization: Start a random walk from an unvisited node.
  2. Growth: If the walk hits an existing part of the forest, it becomes a new branch.
  3. Cycle Formation: If the walk hits itself, it forms a cycle. Depending on the "weight" of that cycle (determined by the U(1)-connection), the cycle is either "popped" (erased, with the walk continuing) or accepted as part of the forest.

To prove the algorithm's correctness, the authors employ last-exit decomposition, following the style of Marchal. This approach breaks down the probability of forming a specific forest into a telescopic product of Green functions, essentially counting the revisits to a node before it is finally accepted into the structure.

Theoretical Insights: Heaps and Rejection Sampling

A key contribution of this research is reinterpreting the algorithm through the lens of Partial Rejection Sampling (PRS). In this framework, the "popped" cycles are not merely wasted computation but are elements in a combinatorial structure called a "heap of cycles."

The authors demonstrate that the cycles popped during the algorithm form a Viennot pyramid. In this visualization, the accepted cycle serves as the maximal element at the base, with all subsequently popped cycles stacked on top of it. This connection bridges the gap between the "stacks-of-cards" perspective (deterministic popping) and the "random walk" perspective (stochastic popping).

Complexity and Performance

One of the most significant results is the derivation of the exact law of the algorithm's running time. The total number of steps $T$ is shown to follow the law:

$$T \stackrel{\text{law}}{=} n + \sum_{[\gamma] \in \mathcal{X}} |\gamma|$$

where $\mathcal{X}$ is a Poisson point process of loops. This reveals that the running time is intrinsically tied to the "loopiness" of the graph. Furthermore, in determinantal cases where weights relate to the Magnetic Laplacian, the expected running time is bounded by the inverse of the smallest eigenvalue of the Laplacian ($E[T] \leq n / \lambda_{\min}$), linking algorithmic speed to the graph's spectral properties.

Numerical simulations on synthetic graphs, such as Erdős-Rényi unicycle models and grid graphs, validate these theoretical predictions. Monte Carlo runs show an almost perfect overlap with the derived exact curves for both the mean and variance of the steps taken.

Conclusion and Future Directions

While the algorithm is highly efficient, its performance can degrade if cycles are "very consistent" (close to a tree), as the intensity of the Poisson process of loops increases. Future work may explore ways to "skip" these loops to maintain speed. Additionally, extending this framework from U(1) connections to non-abelian connections, such as 3D rotation matrices, remains a significant open challenge in the field.

Summary updated

Abstract

We consider a probability measure on cycle-rooted spanning forests (CRSFs) introduced by Kenyon. CRSFs are spanning subgraphs, each connected component of which has a unique cycle; they generalize spanning trees. A generalization of Wilson's celebrated CyclePopping algorithm for uniform spanning trees has been proposed for CRSFs, and several concise proofs have been given that the algorithm samples from Kenyon's distribution. In this survey, we flesh out all the details of such a proof of correctness, progressively generalizing a proof by Marchal for spanning trees. This detailed proof has several interests. First, it serves as a modern tutorial on Wilson's algorithm, suitable for applied probability and computer science audiences. Compared to uniform spanning trees, the more sophisticated motivating application to CRSFs brings forth connections to recent research topics such as loop measures, partial rejection sampling, and heaps of cycles. Second, the detailed proof \emph{à la} Marchal yields the law of the time complexity of the sampling algorithm, shedding light on practical situations where the algorithm is expected to run fast.
BibTeX
@misc{fanuel2024cycling,
  author = {Michaël Fanuel and Rémi Bardenet},
  title = {{Cycling in the forest with Wilson's algorithm}},
  year = {2024},
  eprint = {2404.14803},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.14803},
}
Figure