---
title: Up-Down Walk on Forests
url: https://www.emergentmind.com/topics/up-down-walk-on-forests
type: topic
---

# Up-Down Walk on Forests

The up-down walk on forests is a family of local Markov chains on acyclic edge sets of a graph, typically realized by adding an edge and then deleting an edge so that the state remains a forest. In redistricting applications, the underlying graph encodes geographic building blocks, and random spanning trees or forests are split into connected subgraphs that serve as districts. The central difficulty is balance: districts must have nearly equal population, whereas naive rejection based on random tree splittings becomes exponentially inefficient in the number of parts. Recent work formulates a balance-preserving variant, the Balanced Up-Down (BUD) walk, while earlier matroidal analyses establish sharp mixing guarantees and near-linear-time implementations for unconstrained down-up walks on forest state spaces [2602.11993; 2004.07220].

## 1. Formal state spaces and transition rules

One standard formulation fixes the number of connected components. For a connected graph \(G=(V,E)\) with \(|V|=n\), let \(F_k\) be the set of all spanning forests of \(G\) with exactly \(k\) connected components. Equivalently, these are bases of the rank-\((n-k)\) truncation of the graphic matroid. From a forest \(F\in F_k\), the original Up-Down walk picks uniformly at random an edge \(e\in E\setminus E(F)\), adds it to \(F\), obtains a unique cycle \(C\) in \(F+e\), chooses uniformly at random an edge \(f\in C\), and deletes \(f\). The resulting forest \(F'\) again lies in \(F_k\). The one-step transition matrix satisfies
\[
P(F\to F')=\frac{\#(\text{ways to add }e\text{ then remove }f\text{ to go from }F\text{ to }F')}{[(|E|-|E(F)|)\cdot |C|]}.
\]
Because this is the usual basis-exchange walk on a matroid, it is irreducible and aperiodic on \(F_k\), reversible, and has the uniform distribution on \(F_k\) as its unique stationary distribution. In this formulation it mixes in \(O(n\log n)\) steps, and each step can be implemented in amortized \(O(\log n)\) time, yielding an \(O(n\log^2 n)\)-time algorithm to sample a random forest in \(F_k\) [2602.11993].

A second formulation fixes the number of edges rather than the number of components. For a graph \(G=(V,E)\) with graphic matroid \(M(G)\), let \(\mathcal F_k(G)=\{F\subseteq E:F\text{ is a forest of size }k\}\), the family of rank-\(k\) independent sets of \(M(G)\). The target law may be uniform or weighted:
\[
\pi_k(F)\propto w(F):=\prod_{e\in F} w_e,\qquad |F|=k,
\]
and can also be extended to all forests by
\[
\pi(F)\propto w(F)\cdot q^{\,r-|F|},\qquad q\ge 0.
\]
The down-up chain on \(\mathcal F_k(G)\) removes a uniformly random edge \(e\in F\), forming \(T=F\setminus\{e\}\), then adds an edge \(e'\in C(T)=\{e'\in E\setminus T:T\cup\{e'\}\text{ is acyclic}\}\) with probability proportional to \(1\) in the unweighted case and to \(w_{e'}\) in the weighted case. Detailed balance is immediate, and the main spectral result gives \(\mathrm{gap}(P)\ge 1/k\), equivalently \(\lambda_2\le 1-1/k\), with mixing time \(T_{\mathrm{mix}}(\epsilon)=O(k\log(k/\epsilon))\). Using dynamic forest data structures such as link-cut trees, each step can be implemented in \(O(\log n)\) time, for total runtime \(O(r\log(r/\epsilon)\log n)\); for spanning trees in a sparse graph this becomes \(\widetilde O(n\log^2 n)\) [2004.07220].

These formulations are closely related but not identical. The component-constrained walk is the one used most directly in balanced partition generation, while the edge-constrained walk is the setting in which the strongest general mixing and implementation guarantees are presently available.

## 2. Balanced splittability and the BUD walk

The balance constraint is imposed on spanning trees rather than arbitrary forests. Fix an integer \(k\ge 2\) and tolerance \(\epsilon\ge 0\). A spanning tree \(T\) of \(G\) is \(\epsilon\)-balanced \(k\)-splittable if there exist \(k-1\) edges whose removal produces \(k\) connected components, each with total population in
\[
\bigl[\,p(G)/k-\epsilon/2,\;p(G)/k+\epsilon/2\,\bigr],
\]
where \(p(v)>0\) are vertex weights and \(p(G)=\sum_v p(v)\). The state space of the Balanced Up-Down walk is denoted \(B^\epsilon_k(G)\), the set of \(\epsilon\)-balanced \(k\)-splittable spanning trees [2602.11993].

From \(T\in B^\epsilon_k(G)\), the BUD kernel draws a uniformly random edge \(e\in E\setminus E(T)\), forms the unique cycle \(C\) in \(T+e\), and then restricts deletion to those \(f\in C\) for which \(T'=(T+e)-f\) remains in \(B^\epsilon_k(G)\). Among those admissible edges, \(f\) is chosen uniformly, and \(T'\) becomes the next state. By symmetry,
\[
P(T\to T')=P(T'\to T),
\]
so the uniform distribution on \(B^\epsilon_k(G)\) is stationary; if the chain is irreducible, this stationary law is unique [2602.11993].

The motivation is algorithmic as well as statistical. In tree-based redistricting, one seeks a large ensemble of random graph partitions by drawing and splitting random spanning trees. Under exact or near-exact population balance, rejection sampling from unconstrained tree or forest walks becomes inefficient: the rejection rate needed to maintain balance grows exponentially with the number of parts. ReCom circumvents this barrier by merging and splitting pairs of districts at a time, which runs fast in practice, but it can have trouble exploring the state space. BUD addresses both issues by preserving splittability at every step and by sampling from a known invariant measure under exact balance [2602.11993].

A common misunderstanding is that balance can be appended as a minor accept-reject correction to any local forest walk without materially changing the chain. The available results point in the opposite direction: once balance is enforced, the admissible state space and the move set become the primary mathematical objects.

## 3. Stationarity, irreducibility, and mixing phenomena

For the unconstrained basis-exchange walk on \(F_k\), irreducibility and aperiodicity are automatic consequences of matroid exchange, and reversibility gives a uniform stationary distribution [2602.11993]. The constrained BUD walk is more delicate. Under exact balance, \(\epsilon=0\), every tree \(T\in B^0_k(G)\) has a unique set of \(k-1\) split edges; writing this edge set as \(T_0\), two trees \(T,T'\) with the same induced partition \(P\) satisfy an internal rearrangement lemma: one can go from \(T\) to \(T'\) in at most \(n-1\) BUD steps while staying within \(P\) at each step [2602.11993].

Irreducibility is proved in several special cases. For \(k=2\) on simple grid graphs, if \(G\) is a simply connected subgraph of the square lattice whose boundary is a simple cycle and \(a+b=|V|\), then BUD is irreducible on the set of trees that split into components of sizes \(a\) and \(b\), and the diameter is \(O(n)\). The proof sketch represents each tree by its “column-components,” eliminates “sandwiched leaves” by local BUD moves, and rotates the boundary transition until any two partitions coincide. For triomino tilings, if \(G\) is an \(m\times \ell\) rectangle with \(3\mid m\ell\) and \(k=\ell m/3\), then BUD is irreducible on \(B^0_k(G)\); the proof sketch reduces any \(3\)-omino tiling to the all-horizontal tiling in \(O(N)\) BUD moves by a finite case analysis on the first non-horizontal cell. At the same time, irreducibility fails in general: there exists an induced grid graph with holes and cut-vertices on which BUD is not irreducible, even for \(k=2\) [2602.11993].

No rigorous mixing-time bound is yet known for BUD. Empirically, its autocorrelation behavior is similar to the unconstrained Up-Down walk. This leaves a characteristic asymmetry in the theory: the invariant law is explicit, and irreducibility is established in several regimes, but general quantitative convergence remains open [2602.11993].

The literature therefore distinguishes sharply between two questions that are often conflated: whether the chain is connected on the constrained state space, and how rapidly it mixes once connected. For BUD, the former is partially resolved, the latter is not.

## 4. Deciding approximate splittability and the hardness of conditional sampling

The key algorithmic subroutine for BUD is the decision problem of whether a given tree is \(\epsilon\)-balanced \(k\)-splittable. In the formulation called TAPP, the input is a tree \(T\) with vertex weights summing to \(1\), an integer \(k\), and a tolerance \(\epsilon\); the question is whether \(T\in B^\epsilon_k(G)\). This decision problem is solvable in polynomial time [2602.11993].

The algorithmic basis is a dynamic program due to Ito–Uno–Zhou–Nishizeki (2008). Root \(T\) at an arbitrary vertex. For each vertex \(v\) and \(\ell=0,\dots,k\), define \(S_\ell(v)\) to be the set of possible surplus weights of the partial district containing \(v\) if one partitions the subtree \(T(v)\) into \(\ell\) valid districts plus one leftover piece. To keep these sets polynomially bounded, replace \(S_\ell(v)\) by its \(\epsilon\)-closure \(f_\ell(v)=C_\epsilon(S_\ell(v))\), which is a union of \(O(k)\) intervals. The recursion combines children by taking Minkowski sums of their \(f_\cdot\) sets, cropping to \([0,1/k+\epsilon/2]\), and then applying \(\epsilon\)-closure again. At the root, one checks whether \(0\in f_k(\mathrm{root})\). The naive runtime is \(O(k^4 n)\) [2602.11993].

The improved analysis proves that for any \(v,\ell\), \(f_\ell(v)\) has at most \(1+k|T(v)|\) connected components. Amortizing interval merges yields an \(O(k^3 n)\) runtime in general, and \(O(kn)\) when \(\epsilon=O(1/k^2)\). The underlying reason is that near leaves the number of connected components is proportional to subtree size, so expensive merges occur only near the root [2602.11993].

Counting and conditional sampling are harder. Fix \(T,k,\epsilon\) and an edge \(e\). Computing the probability that a uniformly random \(\epsilon\)-balanced \(k\)-partition of \(T\) cuts \(e\) is \(\#P\)-complete. The proof reduces from counting \(0/1\) Knapsack solutions by constructing a caterpillar tree whose leaf branches have weights proportional to item sizes \(x_i=w_i\cdot (\epsilon/C)\), together with two large root branches; then the probability that \(e\) is split equals
\[
\frac{\#\text{knapsack-solutions}}{\#\text{knapsack-solutions}+1}.
\]
This hardness result explains why the natural edge-by-edge sampling strategy—deciding at each step whether to remove or contract an edge according to the correct conditional probability—does not yield an efficient exact sampler, even after splittability has been decided [2602.11993].

## 5. Empirical behavior on grids and redistricting instances

Empirical tests in the BUD study serve two distinct purposes: validating the invariant law on small instances and comparing autocorrelation behavior against alternative partition samplers on larger ones [2602.11993].

On the \(4\times 4\) grid with \(k=4\) under exact balance, BUD exactly recovers the uniform splittable-tree distribution. On the \(4\times 4\) grid with \(k=5\), where districts have size \(3\) or \(4\), the Cycle Walk fails to connect all partitions, but BUD mixes rapidly, with total-variation distance tending to \(0\). On the \(8\times 8\) grid with \(k=5\), under their respective natural target measures, BUD makes approximately \(55\%\) “internal” proposals, meaning proposals within a part, and \(45\%\) “external” proposals, meaning proposals spanning cuts. When the Cycle Walk is tuned to the same \(1\)- versus \(2\)-tree frequencies, BUD’s autocorrelation on key observables decays roughly twice as fast per non-internal step, and its effective sample rate is approximately \(2\times\) higher, although the per-iteration cost is approximately \(9\times\) larger in unoptimized code [2602.11993].

A separate comparison considers the unconstrained Up-Down walk and BUD on an \(8\times 8\) grid with \(k=4\), using tree diameter as the observable. Their autocorrelations and effective sample rates are nearly identical for this metric, despite BUD’s much smaller state space. This suggests that the balance constraint need not degrade local mixing behavior on all observables, although no theorem currently formalizes that observation [2602.11993].

In North Carolina redistricting with \(14\) districts and \(2\%\) tolerance, BUD, which is uniform on splittable trees, is compared with Linked-Forest ReCom, which is uniform on forests. The ordered distribution of 2020 Presidential vote share in each district is tracked. Both chains converge to similar marginals, and BUD has comparable mixing. Under its stationary measure, BUD tends to produce more cut edges, hence less “compact” trees, than uniform-forest ReCom; this is reported as expected from the stationary laws [2602.11993].

These experiments do not constitute a general mixing theorem, but they delineate the tradeoff that currently defines the method: stronger structural control over balance, at the cost of a more expensive move.

## 6. Dense random graphs, rejection sampling, and the ReCom comparison

A complementary line of work studies the up-down walk on balanced forests in dense random graphs. Here the state space is
\[
\Omega_k=\{F\subseteq E:F\text{ is a forest in }G\text{ with exactly }k\text{ components}\}.
\]
From \(F\in\Omega_k\), the chain picks uniformly an edge \(e\in E\setminus F\) joining two distinct components of \(F\), adds it to obtain a forest with \(k-1\) components, then removes a uniformly random edge \(f\) from the resulting forest. There are no further Metropolis-Hastings rejections. The chain is irreducible and aperiodic on \(\Omega_k\), and its unique stationary distribution is uniform over \(\Omega_k\) [2507.12707].

For fixed \(k\), the quoted mixing bound is
\[
t_{\mathrm{mix}}(\epsilon)=O\bigl(N^2\log(N/\epsilon)\bigr),
\]
with spectral gap \(\lambda\ge c/N^2\) for some absolute \(c>0\). This leads to a rejection sampler for balanced forests: run the chain for \(T=O(N^2\log N)\) steps to near stationarity, test whether each of the \(k\) connected components has exactly \(n\) vertices when \(N=kn\), and restart otherwise. If
\[
p_{\mathrm{bal}}=\pi\bigl(\{F\in\Omega_k:F\text{ is balanced}\}\bigr),
\]
then the expected number of restarts is \(1/p_{\mathrm{bal}}\) [2507.12707].

The key bridge to tree splittings is an equivalence between balanced \(k\)-forests and \(k\)-splittable spanning trees. Let
\[
p_{\mathrm{tree}}=\Pr[\text{a uniform random spanning tree of }G\text{ is }k\text{-splittable}],
\]
and let \(p_{\mathrm{bal}}\) denote the probability that a uniform random \(k\)-forest under the up-down walk is balanced. For constant \(k\),
\[
p_{\mathrm{tree}}=\Omega(n^{-O(1)})\quad\Longleftrightarrow\quad p_{\mathrm{bal}}=\Omega(n^{-O(1)}),
\]
with explicit bounds
\[
n^{-2(k-1)}\le \frac{p_{\mathrm{bal}}}{p_{\mathrm{tree}}}\le n^{2(k-1)}.
\]
In the dense random graph model \(G(N,m)\), with \(N=kn\), \(m=p\binom N2\), and \(p=\Omega(1/\log n)\), the splitting probability satisfies
\[
p_{\mathrm{tree}}\ge C_k\,n^{-\frac k2-O(1)},
\]
and consequently \(p_{\mathrm{bal}}=\Omega(n^{-\frac k2-O(1)})\). The same conclusion transfers to \(G(N,p)\) under the same density assumption and conditioning on connectedness. In that regime, the rejection sampler runs in overall polynomial time [2507.12707].

The comparison with ReCom is explicit. ReCom-style chains choose two adjacent districts, recombine them into one region, sample a uniform spanning tree of that region, and split it by removing one edge. The dense-random-graph analysis emphasizes three limitations: the state space can be disconnected when perfect balance is enforced, no general polynomial-time mixing-time bound is known, and even allowing slack of one node per district can lead to exponentially small acceptance probabilities when splitting. By contrast, the up-down walk on \(\Omega_k\) is irreducible and aperiodic for every graph, and when balanced forests occur with inverse-polynomial probability—as they do in dense random graphs—it yields a provably polynomial-time approximate sampler for balanced forests under the spanning-tree weight [2507.12707].

The resulting picture is nuanced rather than uniform. Unconstrained up-down walks on forest state spaces are among the best-understood local samplers in this area; balance-preserving variants such as BUD repair the rejection barrier and some irreducibility failures of pairwise recombination methods, but they shift the main open problems toward constrained connectivity and quantitative mixing.

Source: https://www.emergentmind.com/topics/up-down-walk-on-forests