Generating random spanning trees 
Feliciano Colella 
18th of November, 2014
Random Walk The Markov Chain Tree Theorem The Swap Chain 
Introduction 
 Given a graph G with n vertices, produces a spanning trees of 
G chosen uniformly at random among the spanning trees of G. 
 The expected running time is O(n log n) while is O(n3) in the 
worst case. 
 A Markov chain is called rapidly mixing if it gets close to the 
limit distribution in time polynomial in the log of the number 
of states. 
Feliciano Colella Generating random spanning trees
Random Walk The Markov Chain Tree Theorem The Swap Chain 
Random Walk 
Feliciano Colella Generating random spanning trees
Random Walk The Markov Chain Tree Theorem The Swap Chain 
The Algorithm Generate 
Input: G = (V; E), with jVj = n nodes and jEj = m edges. 
1 Simulate a random walk on G starting at an arbitrary vertex s 
until every vertex is visited. For each i 2 V  s collect the 
edge (i ; j) that corresponds to the
rst entrance to vertex i . 
Let T be this collection of edges. 
2 Output the set T. 
Feliciano Colella Generating random spanning trees
Random Walk The Markov Chain Tree Theorem The Swap Chain 
The Markov Chain Tree Theorem 
Some notations ... 
 M is a Markov chain with V = f1; : : : ; ng and matrix P. 
 GM = (V; E) is a digraph s.t. E = f[i ; j ]jPi ;j  0g. 
 For each edge [i ; j ] 2 E, its weight, w([i ; j ]) is Pi ;j . 
 Directed spanning tree of GM rooted at i . 
 Weight of a spanning tree T is w(T) = e2Tw(e). 
 Family of all directed ST of GM rooted at i is Ti (GM). 
 Family of all directed ST of GM is T(GM). 
Feliciano Colella Generating random spanning trees
Random Walk The Markov Chain Tree Theorem The Swap Chain 
The Markov Chain Tree Theorem 
Theorem 1 
Let M be an irreducible Markov Chain on n states with stationary 
distribution i ; : : : ; n. Let GM be the directed graph associated 
with M. Then: 
i = 
P 
T2Ti (GM) w(T) 
P 
T2T(GM) w(T) 
Feliciano Colella Generating random spanning trees
Random Walk The Markov Chain Tree Theorem The Swap Chain 
The Markov Chain Tree Theorem 
We use the Backwards tree to prove the theorem. 
 Calculate the probability of being in a certain tree T after a 
cover time C, namely FC . 
Feliciano Colella Generating random spanning trees
Random Walk The Markov Chain Tree Theorem The Swap Chain 
The Markov Chain Tree Theorem 
We use the Backwards tree to prove the theorem. 
 Calculate the probability of being in a certain tree T after a 
cover time C, namely FC . 
 Show that FC is uniformly distributed over all directed 
spanning trees rooted at i . 
Feliciano Colella Generating random spanning trees
Random Walk The Markov Chain Tree Theorem The Swap Chain 
The Markov Chain Tree Theorem 
We use the Backwards tree to prove the theorem. 
 Calculate the probability of being in a certain tree T after a 
cover time C, namely FC . 
 Show that FC is uniformly distributed over all directed 
spanning trees rooted at i . 
 Show that the previous property still holds when the graph is 
undirected. 
Feliciano Colella Generating random spanning trees
Random Walk The Markov Chain Tree Theorem The Swap Chain 
Quasi-uniform Generation 
The algorithm Generate cannot be applied to directed graphs, 
because in this case the simple random walk is not reversible. 
Feliciano Colella Generating random spanning trees
Random Walk The Markov Chain Tree Theorem The Swap Chain 
Quasi-uniform Generation 
The algorithm Generate cannot be applied to directed graphs, 
because in this case the simple random walk is not reversible. 
What can we do ? 
Feliciano Colella Generating random spanning trees
Random Walk The Markov Chain Tree Theorem The Swap Chain 
Quasi-uniform Generation 
The algorithm Generate cannot be applied to directed graphs, 
because in this case the simple random walk is not reversible. 
What can we do ? 
We need to modify all the transitions to have the same probability; 
thus every tree has the same weight. 
This is done by adding self-loops to the graph. 
If the graph is already out-degree regular then the running time is 
only O(E(C)) 
Feliciano Colella Generating random spanning trees
Random Walk The Markov Chain Tree Theorem The Swap Chain 
The Swap Chain 
A new approach ... 
 Starting from an undirected graph G. 
 Let S0 
t be the current tree; pick and edge e from G  S0 
t 
uniformly at random. 
 Add e to T. 
 Delete uniformly at random an edge from the new cycle to 
obtain S0 
t+1. 
Feliciano Colella Generating random spanning trees
Random Walk The Markov Chain Tree Theorem The Swap Chain 
The Swap Chain 
A new approach ... 
 Starting from an undirected graph G. 
 Let S0 
t be the current tree; pick and edge e from G  S0 
t 
uniformly at random. 
 Add e to T. 
 Delete uniformly at random an edge from the new cycle to 
obtain S0 
t+1. 
The authors show that this chain get close to stationary 
distribution in time polynomial in n. 
Feliciano Colella Generating random spanning trees
Random Walk The Markov Chain Tree Theorem The Swap Chain 
The Swap Chain 
Sketch of the proof. 
Lemma 5 Fs (Pt )  tFs (P) 
Lemma 6 Fs ( 1 
2 (P + PT )) = Fs (P) 
Lemma 7 Fs  d 
d0 Fs (P) 
Feliciano Colella Generating random spanning trees
Random Walk The Markov Chain Tree Theorem The Swap Chain 
The Swap Chain 
Sketch of the proof. 
Lemma 5 Fs (Pt )  tFs (P) 
Lemma 6 Fs ( 1 
2 (P + PT )) = Fs (P) 
Lemma 7 Fs  d 
d0 Fs (P) 
Theorem 8 
The swap chain fStg gets close to the uniform distribution in time 
polynomial in the size of the underlying graph 
 Use Lemma 5 for a bound for fBtg 
 Transform the graph for fBtg to the graph for fStg 
 The second eigenvalue is bounded by the matrix P of fStg 
 Implies that fStg is rapidly mixing 
Feliciano Colella Generating random spanning trees

Generating random spaning trees

  • 1.
    Generating random spanningtrees Feliciano Colella 18th of November, 2014
  • 2.
    Random Walk TheMarkov Chain Tree Theorem The Swap Chain Introduction Given a graph G with n vertices, produces a spanning trees of G chosen uniformly at random among the spanning trees of G. The expected running time is O(n log n) while is O(n3) in the worst case. A Markov chain is called rapidly mixing if it gets close to the limit distribution in time polynomial in the log of the number of states. Feliciano Colella Generating random spanning trees
  • 3.
    Random Walk TheMarkov Chain Tree Theorem The Swap Chain Random Walk Feliciano Colella Generating random spanning trees
  • 4.
    Random Walk TheMarkov Chain Tree Theorem The Swap Chain The Algorithm Generate Input: G = (V; E), with jVj = n nodes and jEj = m edges. 1 Simulate a random walk on G starting at an arbitrary vertex s until every vertex is visited. For each i 2 V s collect the edge (i ; j) that corresponds to the
  • 5.
    rst entrance tovertex i . Let T be this collection of edges. 2 Output the set T. Feliciano Colella Generating random spanning trees
  • 6.
    Random Walk TheMarkov Chain Tree Theorem The Swap Chain The Markov Chain Tree Theorem Some notations ... M is a Markov chain with V = f1; : : : ; ng and matrix P. GM = (V; E) is a digraph s.t. E = f[i ; j ]jPi ;j 0g. For each edge [i ; j ] 2 E, its weight, w([i ; j ]) is Pi ;j . Directed spanning tree of GM rooted at i . Weight of a spanning tree T is w(T) = e2Tw(e). Family of all directed ST of GM rooted at i is Ti (GM). Family of all directed ST of GM is T(GM). Feliciano Colella Generating random spanning trees
  • 7.
    Random Walk TheMarkov Chain Tree Theorem The Swap Chain The Markov Chain Tree Theorem Theorem 1 Let M be an irreducible Markov Chain on n states with stationary distribution i ; : : : ; n. Let GM be the directed graph associated with M. Then: i = P T2Ti (GM) w(T) P T2T(GM) w(T) Feliciano Colella Generating random spanning trees
  • 8.
    Random Walk TheMarkov Chain Tree Theorem The Swap Chain The Markov Chain Tree Theorem We use the Backwards tree to prove the theorem. Calculate the probability of being in a certain tree T after a cover time C, namely FC . Feliciano Colella Generating random spanning trees
  • 9.
    Random Walk TheMarkov Chain Tree Theorem The Swap Chain The Markov Chain Tree Theorem We use the Backwards tree to prove the theorem. Calculate the probability of being in a certain tree T after a cover time C, namely FC . Show that FC is uniformly distributed over all directed spanning trees rooted at i . Feliciano Colella Generating random spanning trees
  • 10.
    Random Walk TheMarkov Chain Tree Theorem The Swap Chain The Markov Chain Tree Theorem We use the Backwards tree to prove the theorem. Calculate the probability of being in a certain tree T after a cover time C, namely FC . Show that FC is uniformly distributed over all directed spanning trees rooted at i . Show that the previous property still holds when the graph is undirected. Feliciano Colella Generating random spanning trees
  • 11.
    Random Walk TheMarkov Chain Tree Theorem The Swap Chain Quasi-uniform Generation The algorithm Generate cannot be applied to directed graphs, because in this case the simple random walk is not reversible. Feliciano Colella Generating random spanning trees
  • 12.
    Random Walk TheMarkov Chain Tree Theorem The Swap Chain Quasi-uniform Generation The algorithm Generate cannot be applied to directed graphs, because in this case the simple random walk is not reversible. What can we do ? Feliciano Colella Generating random spanning trees
  • 13.
    Random Walk TheMarkov Chain Tree Theorem The Swap Chain Quasi-uniform Generation The algorithm Generate cannot be applied to directed graphs, because in this case the simple random walk is not reversible. What can we do ? We need to modify all the transitions to have the same probability; thus every tree has the same weight. This is done by adding self-loops to the graph. If the graph is already out-degree regular then the running time is only O(E(C)) Feliciano Colella Generating random spanning trees
  • 14.
    Random Walk TheMarkov Chain Tree Theorem The Swap Chain The Swap Chain A new approach ... Starting from an undirected graph G. Let S0 t be the current tree; pick and edge e from G S0 t uniformly at random. Add e to T. Delete uniformly at random an edge from the new cycle to obtain S0 t+1. Feliciano Colella Generating random spanning trees
  • 15.
    Random Walk TheMarkov Chain Tree Theorem The Swap Chain The Swap Chain A new approach ... Starting from an undirected graph G. Let S0 t be the current tree; pick and edge e from G S0 t uniformly at random. Add e to T. Delete uniformly at random an edge from the new cycle to obtain S0 t+1. The authors show that this chain get close to stationary distribution in time polynomial in n. Feliciano Colella Generating random spanning trees
  • 16.
    Random Walk TheMarkov Chain Tree Theorem The Swap Chain The Swap Chain Sketch of the proof. Lemma 5 Fs (Pt ) tFs (P) Lemma 6 Fs ( 1 2 (P + PT )) = Fs (P) Lemma 7 Fs d d0 Fs (P) Feliciano Colella Generating random spanning trees
  • 17.
    Random Walk TheMarkov Chain Tree Theorem The Swap Chain The Swap Chain Sketch of the proof. Lemma 5 Fs (Pt ) tFs (P) Lemma 6 Fs ( 1 2 (P + PT )) = Fs (P) Lemma 7 Fs d d0 Fs (P) Theorem 8 The swap chain fStg gets close to the uniform distribution in time polynomial in the size of the underlying graph Use Lemma 5 for a bound for fBtg Transform the graph for fBtg to the graph for fStg The second eigenvalue is bounded by the matrix P of fStg Implies that fStg is rapidly mixing Feliciano Colella Generating random spanning trees