Next Article in Journal
Dual Market Facility Network Design under Bounded Rationality
Next Article in Special Issue
Distributed Combinatorial Maps for Parallel Mesh Processing
Previous Article in Journal
Introduction to Reconfiguration
Article Menu

Export Article

Algorithms 2018, 11(4), 53; doi:10.3390/a11040053

Article
Linking and Cutting Spanning Trees
INESC-ID and the Department of Computer Science and Engineering, Instituto Superior Técnico, Universidade de Lisboa, Avenida Rovisco Pais 1, 1049-001 Lisboa, Portugal
*
Author to whom correspondence should be addressed.
Received: 12 March 2018 / Accepted: 11 April 2018 / Published: 19 April 2018

Abstract

:
We consider the problem of uniformly generating a spanning tree for an undirected connected graph. This process is useful for computing statistics, namely for phylogenetic trees. We describe a Markov chain for producing these trees. For cycle graphs, we prove that this approach significantly outperforms existing algorithms. For general graphs, experimental results show that the chain converges quickly. This yields an efficient algorithm due to the use of proper fast data structures. To obtain the mixing time of the chain we describe a coupling, which we analyze for cycle graphs and simulate for other graphs.
Keywords:
spanning tree; uniform generation; Markov chain; mixing time; link-cut tree
PACS:
02.10.Ox; 02.50.Ga; 02.50.Ng; 02.70.Uu
MSC:
05C81; 05C85; 60J10; 60J22; 65C40; 68R10

1. Introduction

A spanning tree A of an undirected connected graph G is a connected set of edges without cycles that spans every vertex of G. Every vertex of G occurs at an edge of A. Figure 1 shows an example. The  vertices of the graph are represented by circles. The set of vertices is denoted by V. The edges of G are represented by dashed lines, and the set of edges is represented by E. The edges of the spanning tree A are represented by thick gray lines. We also use V and E to denote the size of the set V and the size of set E, respectively, i.e., the number of vertices and the number of edges. In case the expression can be interpreted as a set instead of a number, we avoid the ambiguity by writing | V | and | E | , respectively.
We aim to compute one such spanning tree, A, uniformly among all possible spanning trees. The number of these trees may vary significantly, from 1 to V V 2 , depending on the underlying graph ([1,2,3], Chapter 22). Computing such a tree uniformly and efficiently is challenging for several reasons: the number of such trees is usually exponential; and the structure of the resulting trees is largely heterogeneous as the underlying graphs change. The contributions of this paper are as follows:
  • We present a new algorithm, which given a graph G, generates a spanning tree of G uniformly at random. The algorithm uses the link-cut tree data structure to compute randomizing operations in O ( log V ) amortized time per operation. Hence, the overall algorithm takes O ( τ log V ) time to obtain a uniform spanning tree of G, where τ is the mixing time of a Markov chain that is dependent on G. Theorem 1 summarizes this result.
  • We propose a coupling to bound the mixing time τ . The analysis of the coupling yields a bound for cycle graphs (Theorem 2), and for graphs which consist of simple cycles connected by bridges or articulation points (Theorem 3). We also simulate this procedure experimentally to obtain bounds for other graphs. The link-cut tree data structure is also key in this process. Section 4.3  shows experimental results, including other classes of graphs.
This paper is structured as follows. In Section 2 we introduce the problem and explain its subtle nature. In Section 3 we explain our approach and point out that using the link-cut tree data structure is much faster than repeating depth first searches (DFSs). In Section 4 we thoroughly justify our results, proving that the underlying Markov chain has the necessary properties and providing experimental results of our algorithm. In Section 5 we describe the related work concerning random spanning trees, link-cut trees, and mixing times of Markov chains. In Section 6 we present our conclusions.

2. The Challenge

We start by describing an intuitive process for generating spanning trees that does not obtain a uniform distribution. It produces some trees with a higher probability than others. This serves to illustrate that the problem is more difficult than it may seem at first glance. Moreover, we explain why this process is biased, using a counting argument.
A simple procedure to build A consists in using a union-find data structure [4] to guarantee that A does not contain a cycle. Note that these structures are strictly incremental, meaning that they can be used to detect cycles but can not be used to remove an edge from the cycle. Therefore the only possible action is to discard the edge that creates the cycle.
Let us analyze a concrete example of the resulting distribution of spanning trees. We shall show that this distribution is not uniform. First, generate a permutation p of E and then process the edges in this order. Each edge that does not produce a cycle is added to A, edges that would otherwise produce cycles are discarded, and the procedure continues with the next edge in the permutation.
Consider the complete graph on four vertices, K 4 , and focus on the probability of generating a star graph, centered at the vertex labeled 1. Figure 2 illustrates the star graph. The K 4 graph has 6 edges, hence there are 6 ! = 720 different permutations. To produce the star graph, from one such permutation, it is necessary that the edges ( 1 , 2 ) and ( 1 , 3 ) are selected before the edge ( 2 , 3 ) appears; in general the edges ( 1 , u ) and ( 1 , v ) must occur before ( u , v ) . One permutation that generates the star graph is ( 1 , 2 ) , ( 1 , 3 ) , ( 2 , 3 ) , ( 1 , 4 ) , ( 2 , 4 ) , ( 3 , 4 ) . Now, ( 2 , 3 ) can be moved to the right to any of three different locations, so we know four sequences that generate the star graph. The same reasoning can be applied to ( 2 , 4 ) which can be moved once to the right. In total we count 8 different sequences that generate the star graph, centered at 1. For each of these sequences it is possible to permute the vertices 2 , 3 , 4 , amongst themselves. Hence, we multiply the previous count by 3 ! = 6 . In total we count 48 = 8 × 6 sequences that generate the star graph, and therefore the total probability of obtaining a star graph is 48 / 6 ! = 1 / 15 . According to Cayley’s formula, the probability of obtain the star graph centered at 1 should be 1 / 4 2 = 1 / 16 . Hence, too many sequences generate the star graph centered at 1.
In the next section we fix this bias by discarding some edge in the potential cycle, not necessarily the edge that creates it.

3. Main Idea

To generate a uniform spanning tree, start by generating an arbitrary spanning tree A. One  way to obtain this tree is to compute a depth first search in G, in which case the necessary time is O ( V + E ) . In general, we want the mixing time of our chain to be much smaller than O ( E ) , especially for dense graphs. This initial tree is only generated once, and subsequent trees are obtained by the randomizing process. To randomize A, repeat the next process several times. Choose an edge ( u , v ) from E uniformly at random, and consider the set A { ( u , v ) } . If ( u , v ) already belongs to A the process stops, otherwise A { ( u , v ) } contains a cycle C. To complete the process, choose an edge ( u , v ) uniformly from C { ( u , v ) } and remove it. Hence, at each step the set A is transformed into the set ( A { ( u , v ) } ) { ( u , v ) } . An illustration of this process is shown in Figure 3.
This edge-swapping process can be adequately modeled by a Markov chain, where the states corresponds to different spanning trees and the transitions among states correspond to the process we have just described. In Section 4.1 we study the ergodic properties of this chain. For now let us focus on which data structures can be used to compute the transition procedure efficiently. A  simple solution to this problem would be to compute a depth first search (DFS) on A, starting at u and terminating whenever v is reached. This allows us to identify C in O ( V ) time. Recall that A contains exactly V 1 elements. The edge ( u , v ) can then be easily removed. Besides G the elements of A also need to be represented with the adjacency list data structure. For our purposes, this approach is inefficient. This  computation is central to our algorithm and its complexity becomes a factor in the overall performance. Hence, we will now explain how to perform this operation in only O ( log V ) amortized time with the link-cut tree data structure.
The link-cut tree (LCT) is a data structure that can used to represent a forest of rooted trees. The representation is dynamic so that edges can be removed and added. Whenever an edge is removed, the original tree is cut in two. Adding an edge between two trees links them. This structure was proposed by Sleator and Tarjan [5]. Both the link and cut operations can be computed in O ( log V ) amortized time.
The LCT can only represent trees; therefore the edge swap procedure must first cut the edge ( u , v ) and afterwards insert the edge ( u , v ) with the Link operation. The randomizing process needs to identify C and select ( u , v ) from it. The LCT can also compute this process in O ( log V ) amortized time. The LCT works by partitioning the represented tree into disjoint paths. Each path is stored in an auxiliary data structure, so that any of its edges can be accessed efficiently in O ( log V ) amortized time. To compute this process we force the path D = C { ( u , v ) } to become a disjoint path. This means that D will be completely stored in one auxiliary data structure. Hence, it is possible to efficiently select an edge from it. Moreover the size of D can also be computed efficiently. The exact process, to force D into an auxiliary structure, is to make u the root of the represented tree and then access v. Algorithm 1 shows the pseudo-code of the edge-swapping procedure. We can confirm, by inspection, that this process can be computed in the O ( log V ) amortized time bound that is crucial for our main result.
Algorithm 1 Edge-swapping process
1: procedure EdgeSwap(A)A is an LCT representation of the current spanning tree
2:      ( u , v ) Chosen uniformly at random from E
3:     if ( u , v ) A then O ( log V ) time
4:          ReRoot ( A , u ) ▹ Makes u the root of A
5:          D Access ( A , v ) ▹ Obtains a representation of the path C { ( u , v ) }
6:          i Chosen uniformly from { 1 , , | D | }
7:          ( u , v ) Select ( D , i ) ▹ Obtain the i-th edge from D
8:          Cut ( A , u , v )
9:          Link ( A , u , v )
10:    end if
11: end procedure
Theorem 1.
If G is a graph and A is a spanning tree of G, then a spanning tree A can be chosen uniformly from all spanning trees of G in O ( ( V + τ ) log V ) time, where τ is the mixing time of an ergodic edge-swapping Markov chain.
In Section 4.1 we prove that the process we described is indeed an ergodic Markov chain, thus establishing the result. We finish this section by pointing out a detail in Algorithm 1. In the comment in line 3 we point out that the property ( u , v ) A must be checked in at most O ( log V ) time. This can be achieved in O ( 1 ) time by keeping an array of Booleans indexed by E. Moreover it can also be achieved in O ( log V ) amortized time by using the LCT data structure, essentially by delaying the verification until D is determined and verifying if | D | 1 .

4. The Details

4.1. Ergodic Analysis

In this section, we analyze the Markov chain M t induced by the edge-swapping process. It should be clear that this process has the Markov property because the probability of reaching a state depends only on the previous state. In other words the next spanning tree depends only on the current tree.
To prove that our procedure is correct we must show that the stationary distribution is uniform for all states. Let us first establish that such a stationary distribution exists. Note that, for a given finite graph G, the number of spanning trees is also finite. More precisely, for complete graphs, Cayley’s formula yields V V 2 spanning trees. This value is an upper bound for other graphs, as all spanning trees of a certain graph are also spanning trees of the complete graph with the same number of vertices. Therefore, the chain is finite. If we show that it is irreducible and aperiodic, it follows that it is ergodic ([6], Corollary 7.6) and therefore it has a stationary distribution ([6], Theorem 7.7).
The chain is aperiodic because self-loops may occur, i.e., transitions where the underlying state does not change. Such transitions occur when ( u , v ) is already in A, and therefore their probability is at least ( V 1 ) / E , because there are V 1 edges in a spanning tree A.
To establish that the chain is irreducible it is sufficient to show that for any pair of states i and j there is a non-zero probability path from i to j. First note that the probability of any transition on the chain is at least 1 / ( E V ) , because ( u , v ) is chosen out of E elements and ( u , v ) is chosen from C { ( u , v ) } , that contains at most V 1 edges. To obtain a path from i to j let A i and A j represent the respective trees. We consider the following cases:
  • If i = j we use a self-loop transition.
  • Otherwise, when i j , it is possible to choose ( u , v ) from A j A i , and ( u , v ) from ( C { ( u , v ) } ) ( A i A j ) = C A j ; note that the set equality follows from the assumption that ( u , v ) belongs to A j . For the last property, note that if no such ( u , v ) exists then C A j , which is a contradiction because A j is a tree and C is a cycle. As mentioned above, the probability of this transition is at least 1 / ( E V ) . After this step the resulting tree is not necessarily A j , but it is closer to that tree. More precisely ( A i { ( u , v ) } ) { ( u , v ) } is not necessarily A j , however the set A j ( ( A i { ( u , v ) } ) { ( u , v ) } ) is smaller than the original A j A i . Its size decreases by 1 because the edge ( u , v ) exists on the second set but not on the first. Therefore, this process can be iterated until the resulting set is empty and therefore the resulting tree coincides with A j . The maximal size of A j A i is V 1 , because the size of A j is at most V 1 . This value occurs when A i and A j do not share edges. Multiplying all the probabilities in the process of transforming A i into A j we obtain a total probability of at least 1 / ( E V ) V 1 .
Now that the stationary distribution is guaranteed to exist, we will show that it coincides with the uniform distribution by proving that the chain is time-reversible ([6], Theorem 7.10). We prove that for any pair of states i and j, with j i , for which there exists a transition from i to j, with probability P i , j , there exists, necessarily, a transition from j to i with probability P j , i = P i , j . If the transition from i to j exists it means that there are edges ( u , v ) and ( u , v ) such that ( A i { ( u , v ) } ) { ( u , v ) } = A j , where  ( u , v ) belongs to the cycle C contained in A i { ( u , v ) } . Hence, we also have that ( A j { ( u , v ) } ) { ( u , v ) } = A i , which means that the tree A i can be obtained from the tree A j by adding the edge ( u , v ) and removing the edge ( u , v ) . In other words, the process in Figure 3 is similar both top down or bottom up. This process is a valid transition in the edge-swap chain, where the cycle C is the same in both transitions, i.e., C is the cycle contained in A i { ( u , v ) } and in A j { ( u , v ) } . Now we obtain our result by observing that P i , j = 1 / ( E ( C 1 ) ) = P j , i . In the transition from i to j, the factor 1 / E comes from the choice of ( u , v ) and the factor 1 / ( C 1 ) from the choice of ( u , v ) . In the transition between j to i, the factor 1 / E comes from the choice of ( u , v ) and the factor 1 / ( C 1 ) from the choice of ( u , v ) . Hence, we established that the algorithm we propose correctly generates spanning trees uniformly, provided we can sample from the stationary distribution. Hence, we need to determine the mixing time of the chain, i.e., the number of edge swap operations that need to be performed on an initial tree until the distribution of the resulting trees is close enough to the stationary distribution.
Before analyzing the mixing time of this chain we point out that it is possible to use a faster version of this chain by choosing ( u , v ) uniformly from E A , instead of from E. This makes the chain faster, but proving that it is aperiodic is trickier. In this chain we have that Pr ( M t + 1 = i | M t = i ) = 0 , for any state i. We will now prove that Pr ( M t + s = i | M t = i ) 0 , for any state i and s > 1 . It is enough to show for s = 2 and s = 3 , all other values follow from the fact that the greatest common divisor of 2 and 3 is 1. For the case of s = 2 we use the time reverse property and the following deduction: Pr ( M t + 2 = i | M t = i ) P i , j P j , i ( 1 / E V ) 2 > 0 . For the case of s = 3 we observe that the cycle C must contain at least three edges ( u , v ) , ( u , v ) and ( u , v ) . To obtain A j we insert ( u , v ) and remove ( u , v ) ; now we move from this state to state A k by inserting ( u , v ) and removing ( u , v ) . Finally we move back to A i by inserting ( u , v ) and removing ( u , v ) . Hence, for this case we have Pr ( M t + 3 = i | M t = i ) ( 1 / E V ) 3 > 0 .

4.2. Coupling

In this section, we focus on bounding the mixing time. We did not obtain general analytical bounds from existing analysis techniques, such as couplings [6,7], strong stopping times [7] and canonical paths [8]. The coupling technique yielded a bound only for cycle graphs and moreover a simulation of the resulting coupling converges for ladder graphs.
Before diving into the reasoning in this section, we first need a finer understanding of the cycles generated in our process. We consider a closed walk to be a sequence of vertices v 0 , , v n = v 0 , starting and ending at the same vertex, such that any two consecutive vertices v i and v i + 1 are adjacent; in our case ( v i , v i + 1 ) A { ( u , v ) } . The cycles we consider are simple in the sense that they consist of a set of edges for which a closed walk can be formed that traverses all the edges in the cycle, and moreover no vertex repetitions are allowed, except for the vertex v 0 , which is only repeated at the end. Formally this can be stated as: if 0 i , j < n and i j , then v i v j .
The cycles that occur in our randomizing process are even more regular. A cordless cycle in a graph is a cycle such that no two vertexes of the cycle are connected by an edge that does not itself belong to the cycle. The cycles we produce also have this property, otherwise if such a chord existed then it would form a cycle on our tree A, which is a contradiction. In fact, a spanning tree over a graph can alternatively be defined as a set of edges such that for any pair of vertices v and v there is exactly one path linking v to v .
A coupling is an association between two copies of the same Markov chain X t and Y t , in our case the edge-swapping chain. The goal of a coupling is to make the two chains meet as fast as possible, i.e., to obtain X τ = Y τ , for a small value of τ . At this point we say that the chains have coalesced. The two chains may share information and cooperate towards this goal. However, when analyzed in isolation, each chain must be indistinguishable from the original chain M t . Obtaining X τ = Y τ with a high probability implies that at time τ the chain is well mixed. Precise statements of these claims are given in Section 5.
We use the random variable X t to represent the state of the first chain, at time t. The variable Y t represents the state of the second chain. We consider the chain X t in state x and the chain Y t in state y. In one step, the chain X t will transition to the state x = X t + 1 and the chain Y t will transition to state y = Y t + 1 .
The set A x A y contains the edges that are exclusive to A x and likewise the set A y A x contains the edges that are exclusive to A y . The number of such edges provides a distance d ( x , y ) = | A x A y | = | A y A x | that measures how far apart the two states are. We refer to this distance as the edge distance. We define a coupling when d ( x , y ) 1 , which can be extended for states x and y that are farther apart by using the path-coupling technique [9].
To use the path-coupling technique we cannot alter the behavior of the chain X t as, in general, it is determined by the previous element in the path. We denote by i x the edge that gets added to A x , and by o x the edge that gets removed from the corresponding cycle C x A x { i x } , in the case such a cycle exists. Likewise, i y represents the edge that is inserted into A y and o y the edge that gets removed from the corresponding cycle C y A y { i y } , in the case such a cycle exists. The edge i x is chosen uniformly at random from E and o x is chosen uniformly at random from C x { i x } . The edges i y and o y will be obtained by trying to mimic the chain X t , but still exhibiting the same behavior as M t . In  this sense the information flows from X t to Y t . Let us now analyze d ( x , y ) .

4.2.1. d ( x , y ) = 0

If d ( x , y ) = 0 then x = y , which means that the corresponding trees are also equal, A y = A x . In this case Y t uses the same transition as X t , by inserting i x , i.e., set  i y = i x , and by removing o x , i.e., set  o y = o x .

4.2.2. d ( x , y ) = 1

If d ( x , y ) = 1 then the edges e x A x A y and e y A y A x exist and are distinct. We also need the following sets: I = C x C y , E x = C x I and E y = C y I . The set I represents the edges that are common to C x and C y . The set E x represents the edges that are exclusive to C x , from the cycle point of view. This should not be confused with e x which represents the edge that is exclusive to A x , i.e., from a tree point of view. Likewise, E y represents the edges that are exclusive to C y . Also we consider the cycle C e as the cycle contained in A x { e y } , which necessarily contains e x . The following Lemma describes the precise structure of these sets.
Lemma 1.
When i y = i x we either have C x = C y = I and therefore E x = E y = , or E x , E y and I form simple paths, and the following properties hold:
  • e x E x , e y E y , i x I
  • E x E y = , E x I = , E y I =
  • E x I = C x , E y I = C y , E x E y = C e .
Notice that in particular this means that, in the non-trivial case, E x and E y partition C e . A schematic representation of this Lemma is shown in Figure 4.
We have several different cases described below. Aside from the lucky cases 2 and 3, we will usually choose i y = i x , as Y t tries to copy X t . Likewise, if possible, we would like to set o y = o x . When this is not possible we must choose o y E y , ideally we would choose o y = e y , but we must be extra careful with this process to avoid losing the behavior of M t . To maintain this behaviour, we must sometimes choose o y E y { e y } . Since X t provides no information on this type of edges, we use o y = s y chosen uniformly from this E y { e y } , i.e., select from C y but not e y nor edges that are also in  C x .
There is a final twist to this choice, which makes the coupling non-Markovian, i.e., it does not verify the conditions in Equations (1a) and (1b). We can choose o y = e y more often than would otherwise be permissible by keeping track of how e y was determined. If e y is obtained deterministically, for example by the initial selection of x and y, then this is not possible. In general e y might be determined by the changes in X t , in which case we want to take advantage of the underlying randomness. Therefore, we keep track of the random processes that occur. The exact information we store is a set of edges U y C e { e x } , such that e y U y , and moreover this set contains the edges that are equally likely to be e y . This information can be used to set o y = e y when s y U y , however after such an action the information on U y must be purged.
To illustrate the possible cases we use Figure 5, Figure 6, Figure 7, Figure 8, Figure 9, Figure 10, Figure 11, Figure 12, Figure 13, Figure 14 and Figure 15, where the edges drawn with double lines represent a generic path that may contain several edges, or none at all. The precise cases are as follows:
  • If the chain X t loops ( x = x ), because i x A x , then Y t also loops and therefore y = y . The set U y does not change, i.e., set U y = U y .
  • If i x = e y and o x = e x then set i y = e x and o y = e y . In this case the chains do not coalesce; they swap states because x = y and y = x (see Figure 5). Set U y = C e { e x } .
  • If i x = e y and o x e x then set i y = e x and o y = o x . In this case the chains coalesce, i.e., x = y (see Figure 6). When the chains coalesce, the edges e x and e y no longer exist and the set U y is no longer relevant.
  • If i x e y set i y = i x . We now have three sub-cases, which are further sub-divided. These cases depend on whether | C x | = | C y | , | C x | < | C y | or | C x | > | C y | . We start with | C x | = | C y | which is simpler and establishes the basic situations. When | C x | < | C y | or | C x | > | C y | we use some Bernoulli random variables to balance out probabilities and whenever possible reduce to the cases considered for | C x | = | C y | . When this is not possible we present the corresponding new situation.
    (a)
    If | C x | = | C y | we have the following situations:
    (i)
    If o x = e x then set o y = e y . In this case the chains coalesce (see Figure 7).
    (ii)
    If o x I { i x } then set o y = o x . In this case the chains do not coalesce, in fact the exclusive edges remain unchanged, i.e., e x = e x and e y = e y (see Figure 8 and Figure 9). When o x C e the set C e remains equal to C e and likewise U y remains equal to U y (see Figure 8). Otherwise, when o x C e , the set C e is different from C e , and we assign U y = U y C e (see Figure 9).
    (iii)
    If o x E x { e x } then select s y uniformly from E y { e y } . If s y U y then set o y = e y (see Figure 10). In this case set U y = E x { e x } . The alternative, when s y U y , is considered in the next case (4.a.iv).
    (iv)
    If o x E x { e x } and s y U y , then set o y = s y . This case is shown in Figure 11. In this case the distance of the coupled states increases, i.e., d ( x , y ) = 2 . Therefore  we include a new state z in between x and y and define e z to be the edge in A z A x ; e y the edge in A y A z ; and e x the edge in A x A z . The  set U z should contain the edges that provide alternatives to e z . In this case set U z = E x { e x } and U y = ( U y E y ) { o y } .
    (b)
    If | C x | < | C y | then X t will choose o x I with a higher probability then what Y t should. Therefore, we use a Bernoulli random variable B with a success probability p defined as follows:
    p = C x 1 C y 1
    In Lemma 2 we prove that p properly balances the necessary probabilities. For now note that when | C x | = | C y | the expression for p yields p = 1 . This is coherent with the following cases, because when B yields true we use the choices defined for | C x | = | C y | . The following situations are possible:
    (i)
    If o x = e x then we reduce to the case 4.a.i, both when B yields true or when B fails and s y U y . Set o y = e y (see Figure 7). The new case occurs when B fails and s y U y , in this situation set o y = s y and U y = ( U y C y ) { o y } (see Figure 12).
    (ii)
    If o x I { i x } then we reduce to the case 4.a.ii when B yields true. Set o y = o x (see  Figure 8 and Figure 9). When B fails and s y U y we have a new situation. Set  o y = e y and U y = I { i x } . The chains preserve their distance, i.e., d ( x , y ) = 1 (see Figure 13). The alternative, when s y U y , is considered in the next case (4.b.iii).
    (iii)
    If o x I { i x } and B fails and s y U y . We have a new situation,;set o y = s y . The distance increases, d ( x , y ) = 2 (see Figure 14). Set U z = I { i x } and U y = ( U y E y ) { o y } .
    (iv)
    If o x E x { e x } then if s y U y use case 4.a.iii (Figure 10), otherwise, when s y U y , use case 4.a.iv (Figure 11).
    (c)
    If | C x | > | C y | we have the following situations:
    (i)
    If o x = e x then use case 4.a.i and set o y = e y (see Figure 7). The chains coalesce.
    (ii)
    If o x I { i x } then use case 4.a.ii and set o y = o x (see Figure 8 and Figure 9).
    (iii)
    If o x E x { e x } then we use a new Bernoulli random variable B * with a success probability p * defined as follows:
    p * = 1 C y 1 1 C x 1 × ( C x 1 ) ( I 1 ) E x 1
    In Lemma 2 we prove that B * properly balances the necessary probabilities. For now, note that when | C x | = | C y | the expression for p * yields p * = 0 , because 1 / ( C y 1 ) 1 / ( C x 1 ) becomes 0. This is coherent because when B * returns false we will use the choices defined for | C x | = | C y | . The case when B * fails is considered in the next case (4.c.iv).
    If B * is successful we have a new situation. Set o y = s i , where s i is chosen uniformly from I { i y } (see Figure 15). We have e y = e y , U y = ( U y E y ) { o y } , e z = o x and U z = E x { e x } .
    (iv)
    If o x E x { e x } and B * fails we use another Bernoulli random variable B with a success probability p defined as follows:
    p = 1 ( C x 1 ) ( E y 1 ) ( C y 1 ) ( E x 1 ) ( 1 p * )
    In Lemma 2 we prove that B properly balances the necessary probabilities. In case B yields true, use case 4.a.iii and set o y = e y (see Figure 10). Otherwise, if  s y U y , use case 4.a.iii (Figure 10) or, if s y U y , use case 4.a.iv (Figure 11).
Notice that the case 4.a.ii applies when C x = C y , thus solving this situation as a particular case. This case is shown in Figure 8. It may even be the case that C x = C y and C x and C e are disjointed, i.e.,  C x C e = . This case is not drawn.
Formally, a coupling is Markovian when Equations (1a) and (1b) hold, where Z t is the coupling, which is defined as a pair of chains ( X t , Y t ) . The chain M t represents the original chain.
Pr ( X t + 1 = x | Z t = ( x , y ) ) = Pr ( M t + 1 = x | M t = x )
Pr ( Y t + 1 = y | Z t = ( x , y ) ) = Pr ( M t + 1 = y | M t = y )
To establish vital insight into the coupling structure we will start by studying it when it is Markovian.
Lemma 2.
When U y = { e y } , the process we described is a Markovian coupling.
Proof. 
The coupling verifies Equation (1a), because we do not alter the behavior of the chain X t . Hence the main part of the proof focuses on Equation (1b).
First, let us prove that for any edge i E the probability that i y = i is 1 / E , i.e., Pr ( i y = i ) = 1 / E . The possibilities for i y are the following:
  • i A y : this occurs only in case 1, when i x A x . It may be that i = e y ; this occurs when i x = e x , in which case i y = e y = i and this is the only case where i y = e y . In this case Pr ( i y = i ) = Pr ( i x = e x ) = 1 / E . Otherwise, i A y A x , in these cases i y = i x , and therefore Pr ( i y = i ) = Pr ( i x = i ) = 1 / E .
  • i = e x : this occurs in cases 2 and 3, i.e., when i x = e y , which is the decisive condition for this choice. Therefore Pr ( i y = i ) = Pr ( i x = e y ) = 1 / E .
  • i E A y : this occurs in case 4. In this case i y = i x so again we have that Pr ( i y = i ) = Pr ( i x = i ) = 1 / E .
Before focusing on o x we will prove that the Bernoulli random variables are well defined, i.e., that the expressions on the denominators are not 0 and that the values of p, p * , p are between 0 and 1.
  • Analysis of B. We need to have C y 1 0 for p to be well defined. Any cycle must contain at least three edges; therefore 3 C y and hence 0 < 2 C y 1 . This guarantees that the denominator is not 0. The same argument proves that 0 < C x 1 , thus implying that 0 < p , as both expressions are positive. We also establish that p < 1 because of the hypothesis of case 4.b which guarantees C x < C y and therefore C x 1 < C y 1 .
  • Analysis of B * . As in seen the analysis of B we have that 0 < C y 1 and 0 < C x 1 , therefore those denominators are not 0. Moreover we also need to prove that E x 1 0 . In general we have that 1 E y , because e y E y . Moreover, the hypothesis of case 4.c.iii is that C y < C x and therefore E y < E x , which is obtained by removing I from the both sides. This implies that 1 < E x and therefore 0 < E x 1 , thus establishing that the last denominator is also not 0.
    Let us now establish that 0 p * and p * < 1 . Note that p * can be simplified to the expression ( C x C y ) ( I 1 ) / ( ( C y 1 ) ( E x 1 ) ) , where all the expressions in parenthesis are non-negative, so 0 p * . For the second property we use the new expression for p * and simplify p * < 1 to ( E x E y ) ( I 1 ) < ( E x 1 ) ( C y 1 ) . The deduction is straightforward using the equality C x C y = E x E y that is obtained by removing I from the left side. The properties E x E y E x 1 and I 1 < C y 1 establish the desired result.
  • Analysis of B . We established, in the analysis of B, that C y 1 is non-zero. In the analysis of B * we also established that E x 1 is non-zero. Note that case 4.c.iv also assumes the hypothesis that C y < C x . Moreover, in the analysis of B * we also established that p * < 1 , which implies that 0 < 1 p * and therefore the last denominator is also non-zero.
    Let us also establish that 0 p and p 1 . For the second property we instead prove that 0 1 p , where 1 p = ( C x 1 ) ( E y 1 ) / ( ( C y 1 ) ( E x 1 ) ( 1 p * ) ) and all of the expressions in parenthesis are non-negative. We use the following deduction of equivalent inequalities to establish that 0 p :
    0 p p 0 1 p 1 ( C x 1 ) ( E y 1 ) ( C y 1 ) ( E x 1 ) ( 1 p * ) ( C x 1 ) ( E y 1 ) ( C y 1 ) ( E x 1 ) 1 ( C x C y ) ( I 1 ) ( C y 1 ) ( E x 1 ) ( C x 1 ) ( E y 1 ) ( C y 1 ) ( E x 1 ) ( C x C y ) ( I 1 ) ( E x 1 ) ( E y 1 ) + I ( E y 1 ) ( E y 1 ) ( E x 1 ) + I ( E x 1 ) ( E x E y ) ( I 1 ) I ( E y 1 ) I ( E x 1 ) ( E x E y ) ( I 1 ) I ( ( E y 1 ) + E x E y ) I ( E x 1 ) + E x E y I ( E x 1 ) + E y I ( E x 1 ) + E x E y E x C y C x
    This last inequality is part of the hypothesis of case 4.c.iv.
Now, let us focus on the edge o x . We wish to establish that for any o C y { i y } we have that Pr ( o y = o ) = 1 / ( C y 1 ) . We analyze this edge according to the following cases:
  • When the cycles are equal C x = C y . This involves cases 2 and 3.
    • o = e y : this occurs only in case 2 and it is determined by the fact that o x = e x . Therefore, Pr ( o y = o ) = Pr ( o x = e x ) = 1 / ( C x 1 ) = 1 / ( C y 1 ) .
    • o e y : this occurs only in case 3 and it is determined by the fact that o x e x , in this case o y = o x . Therefore Pr ( o y = o ) = Pr ( o x = o ) = 1 / ( C x 1 ) = 1 / ( C y 1 ) .
  • When the cycles have the same size | C x | = | C y | (case 4.a). The possibilities for o are as follows:
    • o = e y : this occurs only in the case 4.a.i. This case is determined by the fact that o x = e x . Therefore, Pr ( o y = o ) = Pr ( o x = e x ) = 1 / ( C x 1 ) = 1 / ( C y 1 ) . Note that according to the Lemma’s hypothesis, case 4.a.iii never occurs.
    • o I { i y } : this occurs only in case 4.a.ii. This case is determined by the fact that o x I { i x } and sets o y = o x = o . Therefore, Pr ( o y = o ) = Pr ( o x = o ) = 1 / ( C x 1 ) = 1 / ( C y 1 ) .
    • o E y { e y } : this occurs only in case 4.a.iv. This case is determined by the fact that o x X { e x } and moreover sets o y = s y , which was uniformly selected from E y { e y } . We  have the following deduction where we use the fact that the events are independent and that | C x | = | C y | implies | E x | = | E y | :
      Pr ( o y = o ) = Pr ( o x E x { e x } and s y = o ) = Pr ( o x E x { e x } ) Pr ( s y = o ) = E x 1 C x 1 × 1 E y 1 = 1 / ( C x 1 ) = 1 / ( C y 1 )
  • When C x < C y this involves case 4.b. The cases for o are as follows:
    • o = e y : this occurs only in the case 4.b.i and when B is true. This case occurs when o x = e x . We make the following deduction, that uses the fact that the events are independent and the success probability of B:
      Pr ( o y = o ) = Pr ( o x = e x and B = true ) = Pr ( o x = e x ) Pr ( B = true ) = 1 C x 1 × C x 1 C y 1 = 1 / ( C y 1 )
    • o I { i y } : this occurs only in case 4.b.ii and when B is true. This case is determined by the fact that o x I { i x } and sets o y = o x = o . We make the following deduction, that uses the fact that the events are independent and the success probability of B:
      Pr ( o y = o ) = Pr ( o x = o and B = true ) = Pr ( o x = o ) Pr ( B = true ) = 1 C x 1 × C x 1 C y 1 = 1 / ( C y 1 )
    • o E y { e y } : this occurs in case 4.b.iv, but also in cases 4.b.iii and 4.b.i when B is false. We have the following deduction, that uses event independence, the fact that the cases are disjoint events, and the success probability of B:
      Pr ( o y = o ) = Pr ( 4 . b . iv or ( 4 . b . iii and B = false ) or ( 4 . b . i and B = false ) ) = Pr ( 4 . b . iv ) + Pr ( 4 . b . iii and B = false ) + Pr ( 4 . b . i and B = false ) = Pr ( o x E x { e x } and s y = o ) + Pr ( o x I and B = false and s y = o ) + Pr ( o x = e x and B = false and s y = o ) = Pr ( o x E x { e x } ) Pr ( s y = o ) + Pr ( o x I ) Pr ( B = false ) Pr ( s y = o ) + Pr ( o x = e x ) Pr ( B = false ) Pr ( s y = o ) = Pr ( o x E x { e x } ) Pr ( s y = o ) + Pr ( o x I { e x } ) Pr ( B = false ) Pr ( s y = o ) = [ Pr ( o x E x { e x } ) + Pr ( o x I { e x } ) ( 1 Pr ( B = true ) ) ] Pr ( s y = o ) = [ Pr ( o x C x ) Pr ( o x I { e x } ) Pr ( B = true ) ] Pr ( s y = o ) = [ 1 Pr ( o x I { e x } ) Pr ( B = true ) ] Pr ( s y = o ) = 1 I 1 + 1 C x 1 × C x 1 C y 1 Pr ( s y = o ) = 1 I C y 1 Pr ( s y = o ) = C y 1 I C y 1 × 1 E y 1 = 1 C y 1
  • When C x > C y , this concerns case 4.c. The cases for o are the following:
    • o = e y : this occurs in the case 4.c.i and case 4.c.iv when B is true. We use the following  deduction:
      Pr ( o y = o ) = Pr ( 4 . c . i or ( 4 . c . iv and B = true ) ) = Pr ( 4 . c . i ) + Pr ( 4 . c . iv and B = true ) = Pr ( o x = e x ) + Pr ( o x E x { e x } and B * = false and B = true ) = 1 C x 1 + E x 1 C x 1 ( 1 p * ) 1 ( C x 1 ) ( E y 1 ) ( C y 1 ) ( E x 1 ) ( 1 p * ) = 1 C x 1 + E x 1 C x 1 1 p * ( C x 1 ) ( E y 1 ) ( C y 1 ) ( E x 1 ) = 1 C x 1 + E x 1 C x 1 E x 1 C x 1 p * E y 1 C y 1 = 1 C x 1 + E x 1 C x 1 1 C y 1 1 C x 1 ( I 1 ) E y 1 C y 1 = 1 C x 1 + E x 1 C x 1 I 1 C y 1 + I 1 C x 1 E y 1 C y 1 = E x + I 1 C x 1 E y + I 1 C y 1 + 1 C y 1 = C x 1 C x 1 C y 1 C y 1 + 1 C y 1 = 1 C y 1
    • o I { i y } : this occurs in case 4.c.ii and case 4.c.iii when B * is true. We make the following deduction:
      Pr ( o y = o ) = Pr ( 4 . c . ii or 4 . c . iii ) = Pr ( 4 . c . ii ) + Pr ( 4 . c . iii ) = Pr ( o x = o ) + Pr ( o x E x { e x } and B * = true and s i = o ) = Pr ( o x = o ) + Pr ( o x E x { e x } ) Pr ( B * = true ) Pr ( s i = o ) = 1 C x 1 + E x 1 C x 1 × 1 C y 1 1 C x 1 × ( C x 1 ) ( I 1 ) E x 1 × 1 I 1 = 1 C x 1 + 1 C y 1 1 C x 1 = 1 C y 1
    • o E y { e y } : this occurs in case 4.c.iv when B is false. We have the following deduction:
      Pr ( o y = o ) = Pr ( 4 . c . iv and B = false ) = Pr ( o x E x { e x } and B * = false and B = false and s y = o ) = Pr ( o x E x { e x } ) Pr ( B * = false ) Pr ( B = false ) Pr ( s y = o ) = E x 1 C x 1 ( 1 p * ) ( C x 1 ) ( E y 1 ) ( C y 1 ) ( E x 1 ) ( 1 p * ) × 1 E y 1 = 1 C y 1
Lemma 3.
The process we described is a non-Markovian coupling.
Proof. 
In the context of a Markovian coupling we analyze the transition from y to y given the information about x. In the non-Markovian case we will use less information about x. We assume that e y is a random variable and that x provides only e x and U y ; we know only that e y U y and moreover that Pr ( e y = e ) = 1 / U y for any e U y and Pr ( e y = e ) = 0 otherwise. Then the chain X t makes its move and provides information about i x and o x . Let us consider only the cases when Y t and choose i y = i x , because nothing changes in the cases where this does not happen. Now, i x can be used to define C x and C y and, therefore, E x and E y . We focus our attention on E y U y because, except for the trivial cases, we must have e y ( E y U y ) . Hence, we instead alter our condition to Pr ( e y = e ) = 1 / | E y U y | , for any e ( E y U y ) and 0 otherwise.
Note that this is a reasonable process because we established in Lemma 1 that, in the non-trivial case, E x and E y partition C e and, therefore, because U y C e { e x } , we have that E x and E y also partition U y . This means that U y I = and so we are not losing any part of U y in this process; we are only dividing it into cases. This process is also the reason why, even when s y U y , we define U y = ( U y C y ) { o y } = ( U y E y ) { o y } .
Now the cases considered in Lemma 2 must be changed. Substitute the original cases of o = e y for o U y E y . Also, substitute the case o E y { e y } for o E y U y . The other cases remain unaltered. Except for the first case, the previous deductions still apply. We will exemplify how the deduction changes for o U y E y . We consider only the situation when | C x | = | C y | . For the remaining situations, C x < C y and C x > C y , we use a general argument. Hence our precise assumptions are: o U y E y and | C x | = | C y | .
Pr ( o y = o ) Pr ( e y = o ) = Pr ( o x E x { e x } and s y U y ) + Pr ( o x = e x ) = Pr ( o x E x { e x } ) Pr ( s y U y ) + Pr ( o x = e x ) = E x 1 C x 1 × | U y E y | 1 E y 1 + 1 C x 1 = | U y E y | C x 1 = | U y E y | C y 1
This is correct according to our assumption.
The general argument follows the above derivation. Whenever the Markovian coupling produces o y = e y , we obtain a 1 / ( C y 1 ) probability of. Moreover, for every edge produced by the Markovian coupling such that o y E y { e y } , we obtain another 1 / ( C y 1 ) probability. This totals | U y E y | / ( C y 1 ) , as desired. This also occurs in the cases when C x < C y and C x > C y , only the derivations become more cumbersome.
Finally will argue why Pr ( e y = e ) = 1 / U y when e U y . The set U y is initialized to contain only the edge e y , i.e., U y = { e y } . As the coupling proceeds, U y is chosen to represent the edges, from which e y was chosen, or is simply restricted if e y does not change. More precisely, in case 4.a.iii we choose e y = o x ; in case 4.b.iv we choose e z = o x ; and in case 4.b.ii we choose e y = o x . ☐
We obtained no general bounds on the coupling we presented; it may even be that such bounds are exponential even if the Markov chain has a polynomial mixing time. In fact, Kumar and Ramesh [10] proved that this is the case for Markovian couplings of the Jerrum–Sinclair chain [11]. Note that according to the classification of Kumar and Ramesh [10] the coupling we present is considered as time-variant Markovian. Hence their result applies to the type of coupling we are using, although we are considering different chains so it is not immediately seen that indeed there exist no polynomial Markovian couplings for the chain we presented. Cycle graphs are the only class of graphs for which we establish polynomial bounds (see Figure 16).
Theorem 2.
For any cycle graph G the mixing time τ of edge-swap chain is O ( V ) for the normal version of the chain and 1 / log 4 ( V 1 ) for the fast version.
Proof. 
For any two trees A x and A y we have a maximum distance of one edge, i.e., d ( A x , A y ) 1 . Hence our coupling applies directly.
For the fast version, case 1 does not occur, because i x is chosen from E { A x } . Hence, the only cases that might apply are cases 2 and 3. In first case, the chains preserve their distance and in the last case the distance is reduced to 0. Hence, E [ d ( X 1 , Y 1 ) ] = 1 / ( V 1 ) , which corresponds to the probability of case 2. Each step of the coupling is independent, which means we can use the previous result and Markov’s inequality to obtain Pr ( d ( X τ , Y τ ) 1 ) 1 / ( V 1 ) τ . Then, we use this probability in the coupling Lemma 4 to obtain a variation distance of 1 / 4 , by solving the following equation: 1 / ( V 1 ) τ = 1 / 4 .
For the slow version of the chain, case 1 applies most of the time, i.e., for V 1 out of V choices of i x . It takes V 1 steps for the standard chain to behave as the fast chain and, therefore, the time should be ( V 1 ) / log 4 ( V 1 ) . ☐
This result is in stark contrast with the alternative methods, the random walk and Wilson’s (see Section 5) algorithms, which require O ( V 2 ) time [7]. More recent algorithms are also at least O ( V 4 / 3 ) for this case.
Moreover when a graph is a connected set of cycles linked by bridges or articulation points we can also establish a similar result. Figure 17 shows one such graph.
Theorem 3.
For any graph G which consists of n simple cycles connected by bridges or articulation points, such that m is the size of the smallest cycle, then the mixing time τ of the fast edge swap chain is as follows:
τ = log ( 4 n ) log n ( m 1 ) n ( m 1 ) ( m 2 )
The mixing time for the slow version is obtained by using | E | instead of n in the previous expression.
Proof. 
To obtain this result we use a path-coupling argument. Then, for two chains at distance 1 we have E [ d ( X 1 , Y 1 ) ] 1 m 2 n ( m 1 ) .
We assume that the different edge occurs in the largest cycle. In general the edges inserted and deleted do not alter this situation, hence the term 1. However with probability 1 / n the chain X t inserts an edge that creates the cycle where the difference occurs. In that case with probability ( m 2 ) / ( m 1 ) the chains coalesce. Hence applying path-coupling the mixing time must verify the following equation:
n 1 m 2 n ( m 1 ) τ 1 4
For the slow version the chain choose the correct edge with probability 1 / E instead of 1 / n . ☐

4.3. Experimental Results

4.3.1. Convergence Testing

Before looking at the performance of the algorithm we started by testing the convergence of the edge swap chain. We estimate the variation distance after a varying number of iterations. The results are shown in Figure 18, Figure 19, Figure 20, Figure 21, Figure 22, Figure 23 and Figure 24. We now describe the structure of these figures. Consider for example Figure 20. The structure is as follows:
  • The bottom left plot shows the graph properties, the number of vertices V in the x axis and the number edges E on the y axis. For the dense case graph 0 has 10 vertices and 45 edges. Moreover, graph 6 has 40 vertices and 780 edges. These graph indexes are used in the remaining plots.
  • The top left plot shows the number of iterations t of the chain in the x axis and the estimated variation distance on the y axis, for all the different graphs.
  • The top right plot is similar to the top left, but the x axis contains the number of iterations divided by ( V 1.3 + E ) . Besides the data this plot also shows a plot of ln ( 1 / ε ^ ) for reference.
  • The bottom right plot is the same as the top right plot, using a logarithmic scale on the y axis.
To avoid the plots from becoming excessively dense, we do not plot points for all experimental values, instead we plot one point out of three. However, the lines pass through all experimental points, even those that are not explicit.
The different values at the end of dmP, namely in Figure 22, Figure 23 and Figure 24, correspond to the choices of p.
The variation distance between two distributions D 1 and D 2 on a countable state space S is given by D 1 D 2 = x S | D 1 ( x ) D 2 ( x ) | / 2 . This is the real value of ε . However, the size of S quickly becomes larger than we can compute. Instead, we compute a simpler variation distance D 1 D 2 d , where S is reduced from the set of all spanning trees of G to the set of integers from 0 to V 1 , which correspond to the edge distance, defined in Section 4.2, of the generated tree A to a fixed random spanning tree R. More precisely, we generate 20 random trees, using a random walk algorithm described in Section 5. For each of these trees, we compute π M t d , i.e., the simpler distance between the stationary distribution π and the distribution M t obtained by computing t steps of the edge-swapping chain. To obtain M t , we start from a fixed initial tree A 0 and execute our chain t times. This process is repeated several times to obtain estimates for the corresponding probabilities. We keep two sets of estimates M t and M t and stop when M t M t d < 0.05 . Moreover, we only estimate values where π M t d 0.1 . We use the same criteria to estimate π , but in this case the trees are again generated by the random walk algorithm. The final value ε ^ is obtained as the maximum value obtained for the 20 trees.
We generated dense graphs, cycle graphs, sparse graphs, and some in-between graphs. The  cycle graphs consist of a single cycle, as shown in Figure 16.The sparse graphs are ladder graphs; an illustration of these graphs is shown in Figure 25.
The dense graphs are actually the complete graphs K V . We also generated other dense graphs labeled biK which consisted of two complete graphs connected by two edges. Graphs were also generated based on the duplication model dmP. Let G 0 = ( V 0 , E 0 ) be an undirected and unweighted graph. Given 0 p 1 , the partial duplication model builds a graph G = ( V , E ) by partial duplication as follows [12]: start with G = G 0 at time t = 1 and, at time t > 1 , perform a duplication step:
  • Uniformly select a random vertex u of G.
  • Add a new vertex v and an edge ( u , v ) .
  • For each neighbor w of u, add an edge ( v , w ) with probability p.
These graphs show the convergence of the Markov chain and moreover V 1.3 + E seems to be a reasonable bound for τ . Still, these results are not entirely binding. On the one hand the estimation of the variation distance groups several spanning trees into the same distance, which means that within a group the distribution might not be uniform, even if the global statistics are good. Hence, the actual variation distance may be larger and the convergence might be slower. On the other hand, we chose the exponent 1.3 experimentally by trying to force the data of the graphs to converge at the same point. The actual value may be smaller or larger.

4.3.2. Coupling Simulation

As mentioned before, we obtained no general bounds on the coupling we presented. In fact, experimental simulation for the coupling does not converge for all classes of graphs. We obtained experimental convergence for cycle graph, as expected from Theorem 2, and for ladder graphs. For the remaining graphs we used an optimistic version of the coupling which always assumes that s y U y and that B * fails. With these assumptions, all the cases which increase the distance between states are eliminated and the coupling always converges. Note that this approach does not yield sound coupling, but in practice we verified that this procedure obtained good experimental variation distance. Moreover, the variation distance estimation for these tests is not the simpler distance but the actual experimental variation distance, obtained by generating several experimental trees, such that in average each possible tree is obtained 100 times.
The simulation of the path coupling proceeds by generating a path with e ln V steps, essentially selecting two trees at distance e ln V from each other. This path is obtained by computing e ln V steps of the fast chain. Recall that our implementation and all simulations use the fast version of the chain. The simulation ends once this path contracts to size ln V . Let t be the number of steps in this process. Once this point is obtained, our estimate for mixing time is τ ^ = t ln V . In general, we wish to obtain τ ^ such that the probability that the two general chains X t and X t coalesce is at least 75 % . Hence, we repeat this process four times and choose the second largest value of τ ^ as our estimate.
Table 1 summarizes results for the experimental variation distance. The number of possible spanning trees for each graph was computed with Kirchhoff’s theorem. Then, we generated 100 times the number of possible trees, and we computed the variation distance. As stated above, we obtained good results for the variation distance, getting a median well below 25% for all tested graph topologies.
We now present experimental results for larger graphs where we use the optimistic coupling. All experiments were conducted on a computer with an Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40 GHz with 4 cores and 32 GB of RAM. We present running times for different graph topologies and sizes in Figure 26, Figure 27, Figure 28, Figure 29, Figure 30, Figure 31 and Figure 32. Note beforehand that the coupling estimate needs only to be computed once for each graph. Once the estimate is known, we can generate as many spanning trees as we want. Although the edge-swapping method is not always the faster compared with the random walk and Wilson’s algorithms, it is competitive in practice for dmP and torus graphs, and it is faster for biK, cycle and sparse (ladder) graphs. As expected, it is less competitive for dense graphs. Hence, experimental results seem to point out that the edge-swapping method is more competitive in practice for those instances that are harder for random walk-based methods, namely biK and cycle graphs. The results for biK and dmP are of particular interest as most real networks seem to include these kind of topologies, i.e., they include communities and they are scale-free [13].

5. Related Work

For detailed information on probabilities for trees and networks, see  Lyons and Peres [14] (Chapter 4). As far as we know, the initial work on generating uniform spanning trees was performed by Aldous [15] and Broader [16], who obtained spanning trees by performing a random walk on the underlying graph. The former author also further studied the properties of such random trees [17], namely giving general closed formulas for the counting argument we presented in Section 2. In the random walk process a vertex v of G is chosen and at each step this vertex is swapped by an adjacent vertex, where all neighboring vertexes are selected with equal probability. Each time a vertex is visited by the first time, the corresponding edge is added to the growing spanning tree. The process ends when all vertices of G get visited at least once. This amount of steps is known as the cover time of G.
To obtain an algorithm that is faster than the cover time, Wilson [18] proposed a different approach. A vertex r of G is initially chosen uniformly and the goal is to hit this specific vertex r from a second vertex, also chosen uniformly from G. This process is again a random walk, but with a loop erasure feature. Whenever the path from the second vertex intersects itself, all the edges in the corresponding loop must be removed from the path. When the path eventually reaches r it becomes part of the spanning tree. The process then continues by choosing a third vertex and also computing a loop erasure path from it, but this time it is not necessary to hit r precisely: it is enough to hit any vertex on the branch that is already linked to r. The process continues by choosing random vertices and computing loop erasure paths that hit the spanning tree that is already computed.
We implemented the above algorithms as they are accessible. Although several theoretical results have been obtained in recent years, we are not aware of an implementation of such algorithms. We  will now survey these results. Another approach to this problem relies on a Theorem by Kirchhoff [19] that counts the number of spanning trees by computing the determinant of a certain matrix, related to the graph G. This relation was studied by Guénoche [20] and Kulkarni [21], who yielded an O ( E V 3 ) time algorithm. This result was improved to O ( V 2.373 ) by Colbourn et al. [22,23], where the exponent corresponds to the fastest algorithm to compute matrix multiplication. Improvements on the random walk approach were obtained by Kelner and Mądry [24], and Mądry [25], culminating in an O ˜ ( E o ( 1 ) + 4 / 3 ) time algorithm by Madry et al. [26], which relies on insight provided by the effective resistance metric. Interestingly, the initial work by Broader [16] contains a reference to the edge-swapping chain we presented in this paper (Section 5, named the swap chain). The author mentions that the mixing time of this chain is E O ( 1 ) , although the details are omitted. This chain was extensively studied by several authors, namely in the context of balanced matroids [27,28,29]. The most recent upper bound on the mixing time is O ( E V log V )  [30]. Using Theorem 1 yields an O ( E V log 2 V )   algorithm.
Even though link-cut trees are well known [5,31] their application to this problem was not established prior to this work. Their initial application was to network flows [32]. We also found another reference to the edge swap in the work of Sinclair [8]. In the proposal of the canonical path technique the author mentions this particular chain as a motivating application for the canonical path technique, although the details are omitted and we were not able to obtain such an analysis.
We considered an LCT version where the auxiliary trees are implemented with splay trees as per Sleator and Tarjan [5], i.e., whereby the auxiliary data structures we mentioned in Section 3 are splay trees. This means that in step 5 of Algorithm 1 all the vertices involved in the path C { ( u , v ) } get stored in a splay tree. This path-oriented approach of link-cut trees makes them suitable for our goals, as opposed to other dynamic connectivity data structures such as Euler tour trees [33].
Splay trees are self-adjusting binary search trees, and therefore the vertices are ordered in such a way that the in-order traversal of the tree coincides with the sequence of the vertices that are obtained by traversing C { ( u , v ) } from u to v. This also justifies why the size of this set can also be obtained in O ( log V ) amortized time. Each node simply stores the size of its sub-tree and these values are efficiently updated during the splay process, which consists of a sequence of rotations. Moreover, these  values can also be used to Select an edge from the path. By starting at the root and comparing the tree sizes to i we can determine if the first vertex of the desired edge is on the left sub-tree, on the root, or on the right sub-tree. Likewise we can do the same for the second vertex of the edge in question. These operations splay the vertices that they obtain and therefore the total time depends on the Splay operation. The precise total time of the Splay operation is O ( ( V + 1 ) log n ) , however the V log V term does not accumulate over successive operations, thus yielding the bound of O ( ( V + τ ) log V ) in Theorem 1. In general the V log V term should not be a bottleneck because for most graphs we should have τ > V . This is not always the case; if G consists of a single cycle then τ = 1 , but V may be large. Figure 16 shows an example of such a graph.
We finish this section by reviewing the formal definitions of variational distance and mixing time τ [6].
Definition 1.
The variation distance between two distributions D 1 and D 2 on a countable space S is given by
| | D 1 D 2 | | = x S | D 1 ( x ) D 2 ( x ) | 2
Definition 2.
Let π be the stationary distribution of a Markov chain with state space S. Let p x t represent the distribution of the state of the chain starting at state x after t steps. We define
Δ x ( t ) = | p x t π |
Δ ( t ) = max x S Δ s ( t )
That is, Δ x ( t ) is the variation distance between the stationary distribution, and p x t and Δ ( t ) is the maximum of these values over all states x. We also define
τ x ( ε ) = m i n { t : Δ x ( t ) ε }
τ ( ε ) = max x S τ x ( ε )
When we refer only to the mixing time we mean τ ( 1 / 4 ) . Finally the coupling Lemma justifies the coupling approach:
Lemma 4.
Let Z t = ( X t , Y t ) be a coupling for a Markov chain M on a state space S. Suppose that there exists a T such that, for every x , y S ,
Pr ( X T Y T | X 0 = x , Y 0 = y ) ε
Then τ ( ε ) T . That is, for any initial state, the variation distance between the distribution of the state of the chain after T steps and the stationary distribution is at most ε.
If there is a distance d defined in S then the property X T Y T can be obtained using the condition d ( X T , Y T ) 1 . For this condition we can use the Markovian inequality Pr ( d ( X T , Y T ) 1 ) E [ d ( X T , Y T ) ] . The path-coupling technique [9] constructs a coupling by chaining several chains, such that the distance between then is 1. Therefore we obtain d ( X T , Y T ) = d ( X T 0 , X T 1 ) + d ( X T 1 , X T 2 ) + + d ( X T D 1 , X T D ) = 1 + 1 + + 1 , where X T = X T 0 and Y T = X T D .

6. Conclusions and Future Work

In this paper we studied a new algorithm to obtain the spanning trees of a graph in a uniform way. The underlying Markov chain was initially sketched by Broader [16] in the early study of this problem. We further extended this work by proving the necessary Markov chain properties and using the link-cut tree data structure. This allows for a much faster implementation than repeating the DFS procedure. This may actually be the reason why this approach has gone largely unnoticed during this time.
Using link-cut trees it is possible to generate a spanning tree in O ( E V log 2 V ) time for any graph, according to the latest bound on the mixing time of the Markov chain we used. However this result is not competitive against existing alternatives. Instead we studied a coupling approach that yielded much better bounds for graphs consisting of cycles and can be simulated in practice for any graph. We implemented our approach and compared it against existing alternatives. The experimental results show that it is very competitive.
On the one hand, computing the mixing time of the underlying chain is complex, time-consuming and hard to analyze in theory. On the other hand the user of this process can fix a certain number of steps to execute. This is a very useful parameter, as it can be used to swap randomness for time. Depending on the type of application the user may sacrifice the randomness of the underlying trees to obtain faster results or on the contrary spend some extra time to guarantee randomness. Existing algorithms do not provide such a possibility.
As a final note, we point out that our approach can be generalized by assigning weights to the edges of the graph. The edge to be inserted can then be selected with a probability that corresponds to its weight, divided by the global sum of weights. Moreover, the edge to remove from the cycle should be removed according to its weight. The probability should be its weight divided by the sum of the cycle weights. The ergodic analysis of Section 4.1 generalizes easily to this case, so this chain also generates spanning trees uniformly, although the analysis of the coupling of Section 4.2 might need some adjustments. A proper weight selection might obtain a faster mixing timer, possibly something similar to the resistance of the edge.

Acknowledgments

This work was partly supported by the BacGenTrack (TUBITAK/0004/2014) project funded by FCT (Fundação para a Ciência e a Tecnologia) and TUBITAK (Scientific and Technological Research Council of Turkey), by PRECISE (LISBOA-01-0145-FEDER-016394) project co-funded by FEEI (Fundos Europeus Estruturais e de Investimento) from “Programa Operacional Regional Lisboa 2020” and by national funds from FCT (UID/CEC/500021/2013 and Pest-OE/EEI/LA0021/2014) and European Union’s Horizon 2020 research and innovation programme under the Marie Skłodowska-Curie grant agreement No 690941.

Author Contributions

Luís M. S. Russo and Alexandre P. Francisco conceived the study, performed the theoretical analysis and designed the experiments; Luís M. S. Russo implemented the prototype; Andreia Sofia Teixeira and Alexandre P. Francisco constructed the test cases, performed the experiments and the experimental analysis; Luís M. S. Russo and Alexandre P. Francisco wrote the paper.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Aigner, M.; Ziegler, G.M.; Quarteroni, A. Proofs from the Book; Springer: Berlin/Heidelberg, Germany, 2010; Volume 274. [Google Scholar]
  2. Borchardt, C.W. Über Eine Interpolationsformel für Eine Art Symmetrischer Functionen und über Deren Anwendung; Math. Abh. der Akademie der Wissenschaften zu Berlin: Berlin, Germany, 1860; pp. 1–20. [Google Scholar]
  3. Cayley, A. A theorem on trees. Q. J. Math. 1889, 23, 376–378. [Google Scholar]
  4. Galler, B.A.; Fisher, M.J. An improved equivalence algorithm. Commun. ACM 1964, 7, 301–303. [Google Scholar] [CrossRef]
  5. Sleator, D.D.; Tarjan, R.E. Self-adjusting binary search trees. J. ACM 1985, 32, 652–686. [Google Scholar] [CrossRef]
  6. Mitzenmacher, M.; Upfal, E. Probability and Computing: Randomized Algorithms and Probabilistic Analysis; Cambridge University Press: New York, NY, USA, 2005. [Google Scholar]
  7. Levin, D.A.; Peres, Y. Markov Chains and Mixing Times; American Mathematical Society: Providence, RI, USA, 2017; Volume 107. [Google Scholar]
  8. Sinclair, A. Improved bounds for mixing rates of Markov chains and multicommodity flow. Comb. Probab. Comput. 1992, 1, 351–370. [Google Scholar] [CrossRef]
  9. Bubley, R.; Dyer, M. Path coupling: A technique for proving rapid mixing in Markov chains. In Proceedings of the 38th Annual Symposium on Foundations of Computer Science, Miami Beach, FL, USA, 20–22 October 1997; pp. 223–231. [Google Scholar]
  10. Kumar, V.S.A.; Ramesh, H. Markovian coupling vs. conductance for the Jerrum-Sinclair chain. In Proceedings of the 40th Annual Symposium on Foundations of Computer Science, New York, NY, USA, 17–19 October 1999; pp. 241–251. [Google Scholar]
  11. Jerrum, M.; Sinclair, A. Approximating the permanent. SIAM J. Comput. 1989, 18, 1149–1178. [Google Scholar] [CrossRef]
  12. Chung, F.R.K.; Lu, L.; Dewey, T.G.; Galas, D.J. Duplication models for biological networks. J. Comput. Biol. 2003, 10, 677–687. [Google Scholar] [CrossRef]
  13. Chung, F.R.; Lu, L. Complex Graphs and Networks; American Mathematical Society: Providence, RI, USA, 2006; No. 107. [Google Scholar]
  14. Lyons, R.; Peres, Y. Probability on Trees and Networks; Cambridge University Press: Cambridge, UK, 2016; Volume 42. [Google Scholar]
  15. Aldous, D.J. The random walk construction of uniform spanning trees and uniform labelled trees. SIAM J. Discret. Math. 1990, 3, 450–465. [Google Scholar] [CrossRef]
  16. Broader, A. Generating random spanning trees. In Proceedings of the IEEE Symposium on Fondations of Computer Science, Research Triangle Park, NC, USA, 30 October–1 November 1989; pp. 442–447. [Google Scholar]
  17. Aldous, D. A random tree model associated with random graphs. Random Struct. Algorithms 1990, 1, 383–402. [Google Scholar] [CrossRef]
  18. Wilson, D.B. Generating random spanning trees more quickly than the cover time. In Proceedings of the Twenty-Eighth Annual ACM Symposium on Theory of Computing (STOC ’96), Philadelphia, PA, USA, 22–24 May 1996; ACM: New York, NY, USA, 1996; pp. 296–303. [Google Scholar]
  19. Kirchhoff, G. Ueber die auflösung der gleichungen, auf welche man bei der untersuchung der linearen vertheilung galvanischer ströme geführt wird. Ann. Phys. 1847, 148, 497–508. [Google Scholar] [CrossRef]
  20. Guénoche, A. Random spanning tree. J. Algorithms 1983, 4, 214–220. [Google Scholar] [CrossRef]
  21. Kulkarni, V. Generating random combinatorial objects. J. Algorithms 1990, 11, 185–207. [Google Scholar] [CrossRef]
  22. Colbourn, C.J.; Day, R.P.J.; Nel, L.D. Unranking and ranking spanning trees of a graph. J. Algorithms 1989, 10, 271–286. [Google Scholar] [CrossRef]
  23. Colbourn, C.J.; Myrvold, W.J.; Neufeld, E. Two algorithms for unranking arborescences. J. Algorithms 1996, 20, 268–281. [Google Scholar] [CrossRef]
  24. Kelner, J.A.; Mądry, A. Faster generation of random spanning trees. In Proceedings of the 2009 50th Annual IEEE Symposium on Foundations of Computer Science, Atlanta, GA, USA, 24–27 October 2009; pp. 13–21. [Google Scholar]
  25. Mądry, A. From Graphs to Matrices, and Back: New Techniques For Graph Algorithms. Ph.D. Thesis, Massachusetts Institute of Technology, Cambridge, MA, USA, 2011. [Google Scholar]
  26. Mądry, A.; Straszak, D.; Tarnawski, J. Fast generation of random spanning trees and the effective resistance metric. In Proceedings of the Twenty-Sixth Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2015), San Diego, CA, USA, 4–6 January 2015; Indyk, P., Ed.; pp. 2019–2036. [Google Scholar]
  27. Feder, T.; Mihail, M. Balanced matroids. In Proceedings of the Twenty-Fourth Annual ACM Symposium on Theory of Computing, Victoria, BC, Canada, 4–6 May 1992; ACM: New York, NY, USA, 1992; pp. 26–38. [Google Scholar]
  28. Jerrum, M.; Son, J.-B.; Tetali, P.; Vigoda, E. Elementary bounds on poincaré and log-sobolev constants for decomposable markov chains. Ann. Appl. Probab. 2004, 14, 1741–1765. [Google Scholar] [CrossRef]
  29. Mihail, M. Conductance and convergence of markov chains-a combinatorial treatment of expanders. In Proceedings of the 30th Annual Symposium on Foundations of Computer Science, Research Triangle Park, NC, USA, 30 October–1 November 1989; pp. 526–531. [Google Scholar]
  30. Jerrum, M.; Son, J.-B. Spectral gap and log-sobolev constant for balanced matroids. In Proceedings of the 43rd Annual IEEE Symposium on Foundations of Computer Science, Vancouver, BC, Canada, 19 November 2002; pp. 721–729. [Google Scholar]
  31. Sleator, D.D.; Tarjan, R.E. A data structure for dynamic trees. In Proceedings of the Thirteenth Annual ACM Symposium on Theory of Computing (STOC ’81), Milwaukee, WI, USA, 11–13 May 1981; ACM: New York, NY, USA, 1981; pp. 114–122. [Google Scholar]
  32. Goldberg, A.V.; Tarjan, R.E. Finding minimum-cost circulations by canceling negative cycles. J. ACM 1989, 36, 873–886. [Google Scholar] [CrossRef]
  33. Henzinger, M.R.; King, V. Randomized dynamic graph algorithms with polylogarithmic time per operation. In Proceedings of the Twenty-Seventh Annual ACM Symposium on Theory of Computing, Las Vegas, NV, USA, 29 May–1 June 1995; ACM: New York, NY, USA, 1995; pp. 519–527. [Google Scholar]
Figure 1. A Spanning tree A over a graph G.
Figure 1. A Spanning tree A over a graph G.
Algorithms 11 00053 g001
Figure 2. A star graph on K 4 , centered at 1.
Figure 2. A star graph on K 4 , centered at 1.
Algorithms 11 00053 g002
Figure 3. Edge-swap procedure. Inserting the edge ( u , v ) into the initial tree A generates a cycle C. The edge ( u , v ) is removed from C.
Figure 3. Edge-swap procedure. Inserting the edge ( u , v ) into the initial tree A generates a cycle C. The edge ( u , v ) is removed from C.
Algorithms 11 00053 g003
Figure 4. Schematic representation of the relations between E x , E y , and I.
Figure 4. Schematic representation of the relations between E x , E y , and I.
Algorithms 11 00053 g004
Figure 5. Case 2.
Figure 5. Case 2.
Algorithms 11 00053 g005
Figure 6. Case 3.
Figure 6. Case 3.
Algorithms 11 00053 g006
Figure 7. Case 4.a.i, case 4.b.i, and case 4.c.i.
Figure 7. Case 4.a.i, case 4.b.i, and case 4.c.i.
Algorithms 11 00053 g007
Figure 8. Case 4.a.ii, case 4.b.ii, and case 4.c.ii, when o x C e .
Figure 8. Case 4.a.ii, case 4.b.ii, and case 4.c.ii, when o x C e .
Algorithms 11 00053 g008
Figure 9. Case 4.a.ii, case 4.b.ii, and case 4.c.ii, when o x C e .
Figure 9. Case 4.a.ii, case 4.b.ii, and case 4.c.ii, when o x C e .
Algorithms 11 00053 g009
Figure 10. Case 4.a.iii, case 4.b.iv, and case 4.c.iv, when B is true.
Figure 10. Case 4.a.iii, case 4.b.iv, and case 4.c.iv, when B is true.
Algorithms 11 00053 g010
Figure 11. Case 4.a.iv, case 4.b.iv, and case 4.c.iv.
Figure 11. Case 4.a.iv, case 4.b.iv, and case 4.c.iv.
Algorithms 11 00053 g011
Figure 12. Case 4.b.i when B fails and s y U y .
Figure 12. Case 4.b.i when B fails and s y U y .
Algorithms 11 00053 g012
Figure 13. Case 4.b.ii.
Figure 13. Case 4.b.ii.
Algorithms 11 00053 g013
Figure 14. Case 4.b.iii.
Figure 14. Case 4.b.iii.
Algorithms 11 00053 g014
Figure 15. Case 4.c.iii, when B * is true.
Figure 15. Case 4.c.iii, when B * is true.
Algorithms 11 00053 g015
Figure 16. A cycle graph.
Figure 16. A cycle graph.
Algorithms 11 00053 g016
Figure 17. Cycles connected by bridges or articulation points.
Figure 17. Cycles connected by bridges or articulation points.
Algorithms 11 00053 g017
Figure 18. Estimation of variation distance as a function of the number of iterations for sparse graphs (see Section 4.3.1 for details).
Figure 18. Estimation of variation distance as a function of the number of iterations for sparse graphs (see Section 4.3.1 for details).
Algorithms 11 00053 g018
Figure 19. Estimation of variation distance as a function of the number of iterations for cycle graphs (see Section 4.3.1 for details).
Figure 19. Estimation of variation distance as a function of the number of iterations for cycle graphs (see Section 4.3.1 for details).
Algorithms 11 00053 g019
Figure 20. Estimation of variation distance as a function of the number of iterations for dense graphs (see Section 4.3.1 for details).
Figure 20. Estimation of variation distance as a function of the number of iterations for dense graphs (see Section 4.3.1 for details).
Algorithms 11 00053 g020
Figure 21. Estimation of variation distance as a function of the number of iterations for biK graphs (see Section 4.3.1 for details).
Figure 21. Estimation of variation distance as a function of the number of iterations for biK graphs (see Section 4.3.1 for details).
Algorithms 11 00053 g021
Figure 22. Estimation of variation distance as a function of the number of iterations for dmP graphs (see Section 4.3.1 for details).
Figure 22. Estimation of variation distance as a function of the number of iterations for dmP graphs (see Section 4.3.1 for details).
Algorithms 11 00053 g022
Figure 23. Estimation of variation distance as a function of the number of iterations for dmP graphs (see Section 4.3.1 for details).
Figure 23. Estimation of variation distance as a function of the number of iterations for dmP graphs (see Section 4.3.1 for details).
Algorithms 11 00053 g023
Figure 24. Estimation of variation distance as a function of the number of iterations for dmP graphs (see Section 4.3.1 for details).
Figure 24. Estimation of variation distance as a function of the number of iterations for dmP graphs (see Section 4.3.1 for details).
Algorithms 11 00053 g024
Figure 25. A ladder graph.
Figure 25. A ladder graph.
Algorithms 11 00053 g025
Figure 26. Running times for dense (fully connected) graphs averaged over five runs, including the running time for computing the optimistic coupling estimate and the running time for generating a spanning tree based on that estimate, as well as the edge-swapping algorithm, the running time for generating a spanning tree through a random walk, and the running time for Wilson’s algorithm.
Figure 26. Running times for dense (fully connected) graphs averaged over five runs, including the running time for computing the optimistic coupling estimate and the running time for generating a spanning tree based on that estimate, as well as the edge-swapping algorithm, the running time for generating a spanning tree through a random walk, and the running time for Wilson’s algorithm.
Algorithms 11 00053 g026
Figure 27. Running times for biK graphs averaged over five runs, including the running time for computing the optimistic coupling estimate, the running time for generating a spanning tree based on that estimate, the edge-swapping algorithm, the running time for generating a spanning tree through a random walk, and the running time for Wilson’s algorithm.
Figure 27. Running times for biK graphs averaged over five runs, including the running time for computing the optimistic coupling estimate, the running time for generating a spanning tree based on that estimate, the edge-swapping algorithm, the running time for generating a spanning tree through a random walk, and the running time for Wilson’s algorithm.
Algorithms 11 00053 g027
Figure 28. Running times for cycle graphs averaged over five runs, including the running time for computing the optimistic coupling estimate, the running time for generating a spanning tree based on that estimate, the edge-swapping algorithm, the running time for generating a spanning tree through a random walk, and the running time for Wilson’s algorithm.
Figure 28. Running times for cycle graphs averaged over five runs, including the running time for computing the optimistic coupling estimate, the running time for generating a spanning tree based on that estimate, the edge-swapping algorithm, the running time for generating a spanning tree through a random walk, and the running time for Wilson’s algorithm.
Algorithms 11 00053 g028
Figure 29. Running times for sparse (ladder) graphs averaged over five runs, including the running time for computing the optimistic coupling estimate, the running time for generating a spanning tree based on that estimate, the edge-swapping algorithm, the running time for generating a spanning tree through a random walk, and the running time for Wilson’s algorithm.
Figure 29. Running times for sparse (ladder) graphs averaged over five runs, including the running time for computing the optimistic coupling estimate, the running time for generating a spanning tree based on that estimate, the edge-swapping algorithm, the running time for generating a spanning tree through a random walk, and the running time for Wilson’s algorithm.
Algorithms 11 00053 g029
Figure 30. Running times for square torus graphs averaged over five runs, including the running time for computing the optimistic coupling estimate, the running time for generating a spanning tree based on that estimate, the edge-swapping algorithm, the running time for generating a spanning tree through a random walk, and the running time for Wilson’s algorithm.
Figure 30. Running times for square torus graphs averaged over five runs, including the running time for computing the optimistic coupling estimate, the running time for generating a spanning tree based on that estimate, the edge-swapping algorithm, the running time for generating a spanning tree through a random walk, and the running time for Wilson’s algorithm.
Algorithms 11 00053 g030
Figure 31. Running times for rectangular torus graphs averaged over five runs, including the running time for computing the optimistic coupling estimate, the running time for generating a spanning tree based on that estimate, the edge-swapping algorithm, the running time for generating a spanning tree through a random walk, and the running time for Wilson’s algorithm.
Figure 31. Running times for rectangular torus graphs averaged over five runs, including the running time for computing the optimistic coupling estimate, the running time for generating a spanning tree based on that estimate, the edge-swapping algorithm, the running time for generating a spanning tree through a random walk, and the running time for Wilson’s algorithm.
Algorithms 11 00053 g031
Figure 32. Running times for dmP graphs averaged over five runs, including the running time for computing the optimistic coupling estimate, the running time for generating a spanning tree based on that estimate, the edge-swapping algorithm, the running time for generating a spanning tree through a random walk, and the running time for Wilson’s algorithm.
Figure 32. Running times for dmP graphs averaged over five runs, including the running time for computing the optimistic coupling estimate, the running time for generating a spanning tree based on that estimate, the edge-swapping algorithm, the running time for generating a spanning tree through a random walk, and the running time for Wilson’s algorithm.
Algorithms 11 00053 g032
Table 1. Variation distance (VD) for different graph topologies. Median and maximum VD computed over five runs for each network. Since dmP graphs are random, results for dmP were further computed over five different graphs for each size | V | .
Table 1. Variation distance (VD) for different graph topologies. Median and maximum VD computed over five runs for each network. Since dmP graphs are random, results for dmP were further computed over five different graphs for each size | V | .
Graph | V | Median VDMax VD
dense { 5 , 7 } 0.0600.194
biK { 8 , 10 } 0.0650.190
cycle { 16 , 20 , 24 } 0.0010.004
sparse { 10 , 14 , 20 } 0.0530.110
torus { 9 , 12 } 0.0940.383
dmP { 8 , 10 , 12 } 0.0690.270

© 2018 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).
Algorithms EISSN 1999-4893 Published by MDPI AG, Basel, Switzerland RSS E-Mail Table of Contents Alert
Back to Top