ROOTED SPANNING TREES BY POPPING 181
viewed as a stack of random draws, with S
i,1
on top, followed by S
i,2
, et cetera. The
first random choice of directed tree given the stacks is T = ∪
i=r
{S
i,1
}.
Givenaninfinite stack (aka a sequence) a
1
,a
2
,..., let the popping operator be
f
pop
(a
1
,a
2
,...)=(a
2
,a
3
,...). This has “popped” the first value in the sequence off
of the stack, and moved up all other items in the stack one position.
In AR, if rejection occurs, each stack is popped once, that is, each S
i
is changed to
f
pop
(S
i
). When rejection occurs (so that the {S
i,1
} do not form a tree), there must be
a directed cycle i
1
,...,i
k
in the set of edges {S
i,1
}. Instead of popping all the nodes,
instead try popping just i
1
,...,i
k
. Stop popping when there is n o longer a cycle to
pop.
The question with this approach is twofold. First, does the choice of directed cy-
cle change the outcome? Second, once the popping is done, is the set o f oriented
edges {S
i,1
} independent of what came b efore? The next lemma answers these ques-
tions.
Lemma 9.16 (Theorem 4 of [128]). The set of choices of which cycle to pop next
is irrelevant. Given stacks {S
i
} for i = r, either one of two possibilities must occur.
Either the algorithm never terminates, or the algorithm terminates at the same place
in the stack independent of the set of choices.
Proof. Fix the set of stacks {S
i
} for i = r. Following [128], let C be a cycle that can
be popped. In other words, suppose that there exists some k-tuple of cycles to be
popped C
1
,C
2
,...,C
k
= C where the last cycle C
k
is the same as C.
Suppose that the user decides not to pop C
1
initially, but instead pops
˜
C.If
˜
C
shares no vertices with C
1
,...,C
k
= C, then of course these cycles can still all be
popped, ending with C.Otherwise,letC
i
be the first of these cycles that shares a
vertex with
˜
C.
Suppose C
i
and
˜
C share vertex w.ThenC
1
,...,C
i−1
do not contain w, hence the
stack {S
w
} is the same whether or not C
1
,...,C
i−1
have been popped. Therefore the
next vertices after w in C
i
and
˜
C are actually the same vertex. Continuing this logic,
all the vertices of C
i
and
˜
C must be the same.
Hence popping
˜
C = C
i
,C
i+1
,...,C
k
= C still allows the popping of C.
This means th a t if there is an infinite sequence C
1
,C
2
,... of cycles that can be
popped in the stacks, then no matter what choice
˜
C is made to pop first, every cycle
in the sequence can still be popped. Hence if the algorithm does not terminate, any
change in the order of cycle popping will not change that fact.
On the other hand, if the algorithm terminates after making choices C
1
,...,C
n
,
then any cycle other than C
1
must equal C
i
for some i > 1. Hence popping C
i
first is
merely changing the order in which the cycles are popped.
Once C
1
,...,C
n
have been popped, the choices of the top of the stack are inde-
pendent of what came before. The p robability of a particular cycle C appearing in
the stack is p(C)=
∏
i∈C
deg(i)
−1
. Similar ly, let p(T)=
∏
i=r
deg(i)
−1
be the chance
that tree T is at the top of the stacks. Then the chance of getting stacks that after pop-
ping cycles C
1
,...,C
n
ends at tree T is just [
∏
k
p(C
k
)] p(T ). Since this factors into
the chance of drawing cycles C
1
,...,C
n
and the tree T , they must be independent of
each other.