arXiv:2611.07925cs.SINov 2026

Manuscript Offprint

arXiv:2611.07925

Efficiently Estimating Cycle Statistics on Graphs via Spanning Trees

Josef Hoppe, Michael T. Schaub

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

Josef Hoppe and Michael T. Schaub*

RWTH Aachen University

(Dated: November 6, 2026)

Simple cycles encode feedback and alternative routes in networks and are important for routing problems, the convergence of dynamical processes on networks, message passing and belief propagation, or even static network characterizations such as structural balance in signed networks. Being able to assess and sample from the cycle structure of a graph is thus of interest in many analysis contexts. However, due to the combinatorial growth of the cycle space with graph size, the computational cost for such sampling is high. Therefore, we here introduce a sampling framework that enables us to sample from the cycle structure without enumerating all cycles. Specifically, the method draws uniform spanning trees and collects the fundamental cycles created by their non-tree edges, such that each tree provides an informative subset of simple cycles. Because cycles are included with unequal probabilities and are dependent within each subset, we formulate an inclusion-probability-based Horvitz-Thompson estimator, which we average over random subsets, a procedure we call Monte Carlo Horvitz-Thompson. For this, we sample multiple Horvitz-Thompson estimators and introduce a method to further subsample the individual estimators for increased computational performance. For sampling cycles, the estimator is unbiased if exact cycle inclusion probabilities are known. To extend the method to larger networks, we derive an efficient mean-field approximation for the inclusion probabilities and characterize the graph regimes in which it remains accurate. Experiments on synthetic and real-world networks demonstrate the computational scaling and statistical performance of the framework. We then illustrate the utility of Monte Carlo Horvitz-Thompson estimation by estimating cycle counts and cycle-level frustration statistics in signed spin systems. An implementation is available in the py-raccoon package.

Keywords: Simple cycles, uniform spanning trees, inclusion-probability estimation, cycle counting, signed networks

I. INTRODUCTION

Simple cycles, i.e., closed paths with no repeated vertices other than the initial and terminal vertex, are among the most basic nonlinear structures in a graph. They identify alternative routes, feedback, topological holes, and local redundancy, and their abundance across different lengths provides information that is not accounted for by degrees or pairwise distances alone. Cycle structure consequently appears in a broad range of network-analysis problems. In graph classification, cycle counts can provide features that increase the expressive power of graph neural networks [1] beyond the Weisfelter-Leman limit [2, 3]. In signed social networks, the parity of negative edges around cycles is central to structural balance and polarization [4–6]. Cycles also describe circular exchange opportunities in financial networks [7] and can be used to reconstruct cyclic structure from observed flows [8]. In cellular pathway analysis, elementary flux modes are directed cycles that form positive feedback loops [9, 10] and are widely studied. In ecological network analysis, the relevance of cycles compared to non-cyclical paths is described by different cycle-based metrics [11–13].

However, computing simple-cycle statistics presents a computational bottleneck. The number of simple cycles can grow exponentially with graph size, and exact counting is computationally hard in general [14, 15]. Exact

enumeration is therefore most practical for graphs with manageable numbers of cycles or analyses restricted to short cycles [15, 16]; enumerating longer cycles is typically expensive even with strong algorithmic optimizations [5, 17].

This limitation is noted and dealt with differently in a wide variety of works. For some applications, researchers limit their analysis to graphs where an exhaustive enumeration or exact computation is possible [13, 18]. In research on elementary flux modes, many different task-specific optimizations exist, but do not fully meet the need for scalability yet and research is ongoing [10]. Another alternative is to replace simple cycles by closed walks, which are more amenable to methods from linear algebra [6]. This substitution is always possible, but a closed walk may revisit vertices and edges and therefore need not represent the same structural object as a simple cycle.

Moreover, counting is only one of several relevant tasks associated with cycles. Applications may require the computation of the distribution of a cycle statistic, an average over all cycles of a given length, or the fraction of cycles satisfying a property. Examples include the fraction of unbalanced cycles in a signed network, the distribution of gains over circular exchanges, and cycle-based anomaly or feedback scores. These tasks motivate sampling methods that expose individual simple cycles without first enumerating the full population. Ideally, we would draw cycles uniformly at random from all cycles of a chosen length. In practice, direct uniform sampling is difficult because this population can be too large to enumerate and its size is generally unknown.

  • {hoppe, schaub}@rwth-aachen.de

Figure

FIG. 1: Overview of Monte-Carlo Horvitz-Thompson with spanning trees to estimate cycle statistics.

We address this problem by indirectly sampling simple cycles through their association with uniform spanning trees. Every spanning tree provides a compact view of the graph's cycle structure: adding any non-tree edge to the tree creates one fundamental simple cycle. Sampling a uniform spanning tree therefore produces an entire subset of cycles in one iteration, and efficient algorithms such as Wilson's algorithm make the tree draw itself tractable. This construction has two important consequences. First, the cycles within a sampled subset are dependent, since they share the same tree. Second, different cycles need not have the same probability of appearing: a cycle is included exactly when the sampled tree contains all but one of its edges. Treating the observed cycles as uniform individual samples would consequently lead to biased estimates.

The appropriate correction for a single uniform spanning tree can be naturally accounted for in terms of inclusion probabilities via a Horvitz-Thompson [19] estimator. It needs only the marginal probability that each object is included and does not require independence among objects within a subset or an explicit probability distribution over all possible subsets. Thus, cycles may share edges or vertices without compromising unbiasedness, although this dependence affects the variance. Using Monte Carlo averages over multiple such uniform spanning trees, we can then estimate the desired cycle statistics, closing the methodological gap we identified.

Here, the inclusion probabilities are determined by the spanning-tree sampling process, which contrasts with the standard usage of HT estimators, in which the sampling design can typically be chosen. To further reduce the cost of evaluating these inclusion probabilities, we also consider an estimator that subsamples one cycle of the chosen length from each nonempty subset. This additional sampling step preserves unbiasedness for totals when exact inclusion probabilities are used, with potentially higher variance than using the full subset. We refer to Monte Carlo averaging of the per-tree HT estimates as Monte Carlo Horvitz-Thompson (MCHT) estimation.

Contributions. Our main contributions are as follows. First, we develop Monte Carlo Horvitz-Thompson estimat-

tors for arbitrary object populations and apply them to compute cycle statistics as seen in Figure 1. We clarify the relation of our estimators to importance sampling 1^{1} and compare the full-subset estimator with one that selects one cycle from each nonempty sampled subset.

Second, we derive an exact expression for the inclusion probability of each fundamental cycle induced by a uniform spanning tree.

Third, we derive a mean-field approximation that permits near-linear evaluation of the inclusion probabilities for cycles of a fixed length induced by each sampled tree, in addition to the cost of generating the tree. Using this approximation can introduce bias into the estimates.

Fourth, we characterize the limitations on sampled cycle lengths arising from uniform spanning tree diameters and empirically study runtime, probability-approximation error, and estimator convergence on synthetic and real-world graphs.

Finally, we demonstrate the framework for two tasks: estimating cycle counts and estimating frustration statistics in signed spin systems.

Outline. Section II introduces notation and preliminaries. Section III describes the spanning-tree construction and exact inclusion probabilities, and Section IV develops Monte Carlo Horvitz-Thompson estimation. Section V presents the scalable inclusion-probability approximation, Section VI discusses the lengths of cycles that can be sampled, and Section VII evaluates runtime and the probability approximation. We then apply the estimators to cycle counting in Section VIII and cycle-level frustration in Section IX.