Algorithm Search⌘K

Proofs: Aldous-Broder algorithm

These are the human proofs of Aldous-Broder algorithm, at full length.

The Aldous-Broder algorithm returns each spanning tree with probability proportional to the product of its weights full

This proof shows: correctness, termination.

Claim. Let G=(V,E)G = (V, E) be a finite connected undirected multigraph with n≥1n \ge 1 vertices and a weight ce>0c_e > 0 on each edge; parallel edges and self-loops are allowed. For each start vertex rr, ALDOUS-BRODER stops with probability 1, and its output TT satisfies

Pr⁡[T=t]=c(t)Z,c(t)=∏e∈tce,Z=∑t′c(t′),\Pr[T = t] = \frac{c(t)}{Z}, \qquad c(t) = \prod_{e \in t} c_e, \qquad Z = \sum_{t'} c(t'),

for each spanning tree tt, the sum over all spanning trees t′t'. With all weights 1, Pr⁡[T=t]=1/τ(G)\Pr[T = t] = 1 / \tau(G).

Setup

For a vertex xx, let c(x)c(x) be the sum of cec_e over the edges at xx, with a self-loop counted twice, as in the implementation. The walk at xx takes an edge ee at xx with probability ce/c(x)c_e / c(x) (a self-loop with probability 2ce/c(x)2 c_e / c(x)) and moves to its other end. Write p(x,y)p(x, y) for the probability to move from xx to yy, so p(x,y)=c(x,y)/c(x)p(x, y) = c(x, y) / c(x) for y≠xy \ne x, where c(x,y)c(x, y) is the total weight of the edges between xx and yy.

The walk is reversible with respect to π(x)=c(x)/∑yc(y)\pi(x) = c(x) / \sum_y c(y): for x≠yx \ne y, π(x)p(x,y)=π(y)p(y,x)\pi(x) p(x, y) = \pi(y) p(y, x), since both sides equal c(x,y)/∑zc(z)c(x, y) / \sum_z c(z). So π\pi is a stationary distribution, and a walk started from π\pi looks the same forward and backward in time: for each kk, the sequences (X0,…,Xk)(X_0, \dots, X_k) and (Xk,…,X0)(X_k, \dots, X_0) have the same law.

Termination. From each vertex, a fixed path of at most n−1n - 1 steps reaches any other vertex with probability at least δ>0\delta > 0. So in each block of n(n−1)n(n-1) steps, the walk visits all vertices with probability at least δn\delta^n, independent of the past, and the probability that the walk has not covered the graph after jj blocks is at most (1−δn)j→0(1 - \delta^n)^j \to 0. Since the visited set never shrinks and each new vertex adds one edge that joins it to the visited set, the output is a tree on all nn vertices.

Step 1: vertex trees first

We first ignore which of several parallel edges is used, and work with rooted vertex trees: a pair (t,ρ)(t, \rho) where tt assigns to each vertex x≠ρx \ne \rho a neighbor t(x)≠xt(x) \ne x, its parent, such that following parents from any vertex reaches ρ\rho. Define its weight

w(t,ρ)=∏x≠ρp(x,t(x)).w(t, \rho) = \prod_{x \ne \rho} p(x, t(x)).

Since p(x,y)=c(x,y)/c(x)p(x, y) = c(x, y) / c(x),

w(t,ρ)=c(ρ)∏x∈Vc(x)∏x≠ρc(x,t(x)).(1)w(t, \rho) = \frac{c(\rho)}{\prod_{x \in V} c(x)} \prod_{x \ne \rho} c(x, t(x)). \tag{1}

Step 2: a chain on rooted trees

Define a Markov chain QQ on rooted vertex trees. From (t,ρ)(t, \rho), take one step of the walk from ρ\rho to uu.

  • If u=ρu = \rho (a self-loop), stay at (t,ρ)(t, \rho).
  • Otherwise, move to (t′,u)(t', u), where t′(ρ)=ut'(\rho) = u, t′(x)=t(x)t'(x) = t(x) for x∉{ρ,u}x \notin \{\rho, u\}, and uu has no parent.

(t′,u)(t', u) is a rooted tree: in tt, the path from uu to ρ\rho ends at ρ\rho; after the change, every vertex whose path in tt passed through uu now stops at uu, and every other vertex reaches ρ\rho and then uu.

Lemma 1. The weight ww is stationary for QQ: for each rooted tree (t′,u)(t', u), ∑(t,ρ)w(t,ρ)Q((t,ρ),(t′,u))=w(t′,u)\sum_{(t, \rho)} w(t, \rho) Q((t, \rho), (t', u)) = w(t', u).

Proof. The term for the self-loop step is w(t′,u)p(u,u)w(t', u) p(u, u). The other predecessors of (t′,u)(t', u) are the trees (t,ρ)(t, \rho) that the rule maps to (t′,u)(t', u) with ρ≠u\rho \ne u. For such a tree, t′(ρ)=ut'(\rho) = u, so ρ\rho is a child of uu in t′t'. Removing the edge from ρ\rho to uu from t′t' splits it into the subtree SρS_\rho of ρ\rho and the rest, which holds uu. The tree tt agrees with t′t' except that ρ\rho has no parent and uu has a parent x=t(u)x = t(u). For tt to be a tree rooted at ρ\rho, the path from xx must reach ρ\rho without passing through uu, which holds exactly when x∈Sρx \in S_\rho. So the predecessors with ρ≠u\rho \ne u are the pairs (ρ\rho a child of uu in t′t', x∈Sρx \in S_\rho a neighbor of uu), and for each,

w(t,ρ) p(ρ,u)=w(t′,u)p(ρ,u) p(u,x) p(ρ,u)=w(t′,u) p(u,x).w(t, \rho) \, p(\rho, u) = \frac{w(t', u)}{p(\rho, u)} \, p(u, x) \, p(\rho, u) = w(t', u) \, p(u, x).

The subtrees SρS_\rho of the children of uu partition V∖{u}V \setminus \{u\}, so the sum over all predecessors is

w(t′,u)(p(u,u)+∑x≠up(u,x))=w(t′,u).□w(t', u) \Big( p(u, u) + \sum_{x \ne u} p(u, x) \Big) = w(t', u). \qquad \square

Lemma 2. The marginal of ww on roots is proportional to π\pi: ∑tw(t,ρ)=π(ρ)⋅K\sum_{t} w(t, \rho) = \pi(\rho) \cdot K for a constant K>0K > 0 that does not depend on ρ\rho.

Proof. By (1), ∑tw(t,ρ)=c(ρ)∏xc(x)∑t∏x≠ρc(x,t(x))\sum_t w(t, \rho) = \frac{c(\rho)}{\prod_x c(x)} \sum_t \prod_{x \ne \rho} c(x, t(x)). A rooted vertex tree is an unrooted spanning tree of the simple graph underlying GG with an orientation toward ρ\rho, and each unrooted tree has exactly one such orientation; so the last sum is ∑s∏xy∈sc(x,y)\sum_s \prod_{xy \in s} c(x, y) over unrooted vertex trees ss, which does not depend on ρ\rho. □\square

Step 3: last exits in the past

Let W=∑(t,ρ)w(t,ρ)W = \sum_{(t, \rho)} w(t, \rho) and let μ=w/W\mu = w / W, a probability distribution. Fix N≥1N \ge 1. Draw (t−N,X−N)(t_{-N}, X_{-N}) from μ\mu, and run QQ for NN steps, which runs the walk X−N,…,X0X_{-N}, \dots, X_0 and updates the tree. By Lemma 2, X−NX_{-N} has law π\pi, so the walk is stationary. By Lemma 1, (t0,X0)(t_0, X_0) has law μ\mu.

By the update rule, after the walk leaves a vertex xx at time jj by a step to y≠xy \ne x, the parent of xx is yy, until xx becomes the root again. So if every vertex other than X0X_0 is visited during [−N,0)[-N, 0), then t0t_0 is the last-exit tree LL: each x≠X0x \ne X_0 has as parent the vertex to which the walk moved at its last exit from xx before time 0. This tree is a function of the walk alone, not of t−Nt_{-N}. Let ANA_N be the event that the walk covers VV during [−N,0][-N, 0]. Then for each rooted tree (t,ρ)(t, \rho),

∣Pr⁡[L=t,X0=ρ]−μ(t,ρ)∣≤Pr⁡[not AN].\big| \Pr[L = t, X_0 = \rho] - \mu(t, \rho) \big| \le \Pr[\text{not } A_N].

The law of (L,X0)(L, X_0) on the event ANA_N does not depend on how the walk before −N-N is extended, and by termination Pr⁡[not AN]→0\Pr[\text{not } A_N] \to 0. For a stationary walk indexed by all integers, which exists by the Kolmogorov extension theorem, LL is defined with probability 1, and letting N→∞N \to \infty gives Pr⁡[L=t,X0=ρ]=μ(t,ρ)\Pr[L = t, X_0 = \rho] = \mu(t, \rho).

Step 4: reversal turns last exits into first entrances

Let Yi=X−iY_i = X_{-i} for i≥0i \ge 0. By reversibility, (Yi)(Y_i) is a walk with the same transition probabilities, started from π\pi. The last exit of xx before time 0 in XX, at time j<0j < 0 with Xj+1=yX_{j+1} = y, is the first visit of xx by YY, at time i=−j>0i = -j > 0, coming from Yi−1=yY_{i-1} = y. So LL is the first-entrance tree of YY, with each x≠Y0x \ne Y_0 pointing to the vertex from which YY first entered it. Hence, by Step 3 and (1),

Pr⁡[first-entrance tree of Y=t, Y0=ρ]=μ(t,ρ)=c(ρ)W∏xc(x)∏x≠ρc(x,t(x)).\Pr[\text{first-entrance tree of } Y = t, \ Y_0 = \rho] = \mu(t, \rho) = \frac{c(\rho)}{W \prod_x c(x)} \prod_{x \ne \rho} c(x, t(x)).

Divide by Pr⁡[Y0=ρ]=π(ρ)=c(ρ)/∑xc(x)\Pr[Y_0 = \rho] = \pi(\rho) = c(\rho) / \sum_x c(x). The factor c(ρ)c(\rho) cancels, and

Pr⁡[first-entrance tree=t∣Y0=ρ]=K′∏xy∈tc(x,y)\Pr[\text{first-entrance tree} = t \mid Y_0 = \rho] = K' \prod_{xy \in t} c(x, y)

for a constant K′K' that does not depend on ρ\rho or tt. A walk conditioned on Y0=ρY_0 = \rho is the walk started at ρ\rho, which is what the algorithm runs with r=ρr = \rho; its first-entrance tree up to the cover time is the vertex tree of the output.

Step 5: parallel edges

Given the sequence of vertices of the walk, the edge used in a step from xx to y≠xy \ne x is the edge ee between them with probability ce/c(x,y)c_e / c(x, y), independently of all other steps. So, for an edge set tt that is a spanning tree with vertex tree ss,

Pr⁡[T=t]=Pr⁡[vertex tree=s]∏e∈tcec(e)=K′∏e∈tc(e)⋅∏e∈tcec(e)=K′ c(t),\Pr[T = t] = \Pr[\text{vertex tree} = s] \prod_{e \in t} \frac{c_e}{c(e)} = K' \prod_{e \in t} c(e) \cdot \prod_{e \in t} \frac{c_e}{c(e)} = K' \, c(t),

where c(e)c(e) is the total weight between the ends of ee. Summing over tt gives K′=1/ZK' = 1 / Z. ■\blacksquare

Disconnected graphs. The implementation runs an independent walk in each component. Each walk gives a tree of its component with probability proportional to its weight product, so a spanning forest FF with the components of GG has probability proportional to ∏e∈Fce\prod_{e \in F} c_e, which is uniform when all weights are 1.

Back to Aldous-Broder algorithm