Abstract 1 Introduction 2 Proof of Theorems 7 and 8 3 Proof of Theorem 10 4 Open problems References

Listing Spanning Trees of Outerplanar Graphs
by Pivot-Exchanges

Nastaran Behrooznia Department of Computer Science, University of Warwick, Coventry, UK Torsten Mütze ORCID Institut für Mathematik, Universität Kassel, Germany
Department of Theoretical Computer Science and Mathematical Logic, Charles University, Prague, Czech Republic
Abstract

We prove that the spanning trees of any outerplanar triangulation G can be listed so that any two consecutive spanning trees differ in an exchange of two edges that share an end vertex. For outerplanar graphs G with faces of arbitrary lengths (not necessarily 3) we establish a similar result, with the condition that the two exchanged edges share an end vertex or lie on a common face. These listings of spanning trees are obtained from a simple greedy algorithm that can be implemented efficiently, i.e., in time 𝒪(nlogn) per generated spanning tree, where n is the number of vertices of G. Furthermore, the listings correspond to Hamilton paths on the 0/1-polytope that is obtained as the convex hull of the characteristic vectors of all spanning trees of G.

Keywords and phrases:
Spanning tree, generation, edge exchange, Hamilton path, Gray code
Copyright and License:
[Uncaptioned image] © Nastaran Behrooznia and Torsten Mütze; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Mathematics of computing Trees
Acknowledgements:
We thank both reviewers of this paper for a number of very helpful suggestions that improved the writing.
Funding:
This work was supported by Czech Science Foundation grant GA 22-15272S. Both authors participated in the workshop “Combinatorics, Algorithms and Geometry” in March 2024, which was funded by German Science Foundation grant 522790373.
Editors:
Olaf Beyersdorff, Michał Pilipczuk, Elaine Pimentel, and Nguyễn Kim Thắng

1 Introduction

For a given graph G, let 𝒯(G) denote the set of all spanning trees of G. Two spanning trees of G differ in an edge exchange if the symmetric difference of their edge sets is a 2-element set, i.e., each of the two spanning trees is obtained from the other one by removing one edge and adding another. The flip graph (G) has the set 𝒯(G) as vertex set, and an edge between any two spanning trees that differ in an edge exchange; see Figure 1. It is well-known that (G) is the skeleton of the 0/1-polytope that is obtained as the convex hull of all characteristic vectors χ(T) of spanning trees T𝒯(G) (see [25, Thm. 40.6]). Specifically, if the edge set of G is {1,,m}, then for all e{1,,m} the characteristic vector χ(T) has a 1-bit at position e if the edge e belongs to T, and a 0-bit at position e otherwise.

Figure 1: The spanning tree flip graph (G) for the “diamond” graph G on the left, with a Hamilton cycle highlighted. For each spanning tree, the set of edges is shown above, and the characteristic vector is shown below. Edges of (G) are labelled by the two edges of G being exchanged.

We are interested in computing Hamilton paths or cycles in the flip graph (G), i.e., we aim to list all spanning trees of G such that any two consecutive spanning trees differ in an edge exchange. Such a listing of combinatorial objects subject to some small-change condition is generally referred to as a Gray code [24, 19]. A Gray code is called cyclic if the first and last object also differ in the small-change condition, i.e., this corresponds to a Hamilton cycle in the flip graph.

Cummins [8] first proved that (G) admits a Hamilton cycle for any graph G. He showed more generally that for any prescribed edge of (G), there is a Hamilton cycle containing this edge. Similar results were obtained by Shank [26], Kamae [11], and Kishi and Kajitani [13].

Harary and Holzmann [10] proved more generally that the base exchange flip graph of any matroid has a Hamilton cycle. They showed this in the stronger sense that any edge of this flip graph can be prescribed to be contained in the cycle, and to be avoided by another cycle. Furthermore, Naddef and Pulleyblank [20, 21] proved that the skeleton of any 0/1-polytope either admits a Hamilton path between any two prescribed end vertices, or it is a hypercube, in which case it admits a Hamilton path between any two end vertices of opposite parity.

Algorithmically, a Hamilton path in (G) can be computed in time 𝒪(1) on average per generated tree using Smith’s algorithm [30] (this is Algorithm S in [14, Sec. 7.2.1.6]); see Figure 2 (a). Given these strong Hamiltonicity properties of the graph (G), there has recently been interest to strengthen them by restricting the allowed edge exchanges.

1.1 The pivot-exchange property

We introduce some more notation. For a graph G, we write V(G) and E(G) for set of vertices and edges of G, respectively. For a subgraph HG and edges eE(H) and fE(G)E(H), we write He and H+f for the graphs obtained from H by removing and adding the edges e and f, respectively. We will think of a subgraph H as a subset of edges from E(G), so the operations He and H+f remove and add an element from the set, respectively. Formally, an edge exchange for a spanning tree T𝒯(G) is a pair {e,f} of edges such that eE(T) and fE(G)E(T) with Te+f=T{e,f}𝒯(G).

Cameron, Grubb, and Sawada [3] introduced the stronger notion of a pivot-exchange, which is an exchange {e,f} with the additional property that e and f have a common end vertex. For example, in the graph G shown in Figure 1, all exchanges except {1,5} and {2,4} are pivot-exchanges. They raised the following problem.

Figure 2: Three different edge exchange Gray codes for listing the 21 spanning trees of the fan graph F5. In each spanning tree, the edge removed to reach the next tree is highlighted (prefixed by  in (c)), and the non-edge being added is dashed (prefixed by + in (c)). In (b) and (c), the common end vertex of each pivot-exchange operation is highlighted, and in (c), the common face of each face-exchange operation is highlighted. The right-hand side of (c) shows the characteristic vectors of each spanning tree.
Problem 1.

Does every graph G admit a pivot-exchange Gray code of its spanning trees?

Additionally, they asked if such a listing can be computed using a greedy strategy, and possibly by an efficient algorithm. Problem 1 is a special case of a more general question raised by Knuth in Vol. 4A of his seminal series “The Art of Computer Programming” [14], stated as problem 102 in Section 7.2.1.6 with a difficulty rating of 46/50: 111A flawed attempt at settling this problem was published in [5] (see [22]).

Problem 2.

Does every directed graph admit an edge exchange Gray code of its oriented spanning trees, also known as arborescences, i.e., spanning trees in which all arcs are oriented away from a fixed root vertex r?

Note that for any exchange {e,f} in this directed setting, in order to preserve the arborescence property, the arcs e and f must point to the same vertex, i.e., it must be a pivot-exchange. Furthermore, a positive answer to Problem 2 would imply an affirmative answer to Problem 1: Indeed, given an undirected graph G, construct the directed graph G by replacing each undirected edge of G by two oppositely oriented arcs, and pick an arbitrary vertex as root r. Listing the oriented spanning trees of G by arc exchanges produces every spanning tree of G exactly once, namely in the orientation forced by the choice of r.

1.2 Fan graphs

Figure 3: The fan graphs Fn.

As a first step towards Problem 1, Cameron, Grubb, and Sawada [3] provided a pivot-exchange Gray code for listing the spanning trees of fan graphs Fn, which are obtained by joining an extra vertex to all vertices of a path on n1 vertices; see Figure 3.

Theorem 3 ([3, Thm. 4]).

For any n3, there is a pivot-exchange Gray code for the spanning trees of Fn.

The output of their algorithm for the case n=5 is shown in Figure 2 (b). The algorithm uses a greedy strategy that prioritizes exchanges based on vertex labels.

1.3 A simple greedy algorithm

Merino, Mütze and Williams [17] discovered a simple greedy algorithm for listing the spanning trees of a graph G by (arbitrary) edge exchanges. The algorithm operates based on a total ordering of the edges of G, which is captured by labeling the edges by integers. Specifically, if m denotes the number of edges of G, then an edge labeling is a bijection :E(G){1,,m}. For an edge eE(G), we refer to (e) as the label of the edge e. In the following examples, we will often identify edges by their labels. In particular, edge exchanges {e,f} will be denoted by the pairs of labels {(e),(f)}. We will also use the abbreviation [m]:={1,,m}.

Algorithm G Greedy edge exchanges.

This algorithm greedily generates the spanning trees of a graph G with m edges via edge exchanges, using an edge labeling :E(G)[m] and an initial spanning tree 𝒯(G).

  1. G1.

    [Initialize] Visit the initial spanning tree  .

  2. G2.

    [Exchange] Perform an edge exchange in the current spanning tree that minimizes the larger of the two edge labels in the exchange and that yields an unvisited spanning tree from 𝒯(G). If no such exchange exists, then terminate. Otherwise visit this new spanning tree and repeat G2.

The output of Algorithm G when applied to the fan graph F5 is shown in Figure 2 (c), using the edge labeling displayed on the left. To illustrate the greedy rule in step G2, when reaching the sixth spanning tree T6={1,2,5,6}, there are seven possible edge exchanges to obtain another spanning tree in 𝒯(F5), namely {1,3}, {2,3}, {1,4}, {2,4}, {4,5}, {5,7} and {6,7}; see Figure 4. Only {1,4}, {2,4}, {5,7} and {6,7} give an unvisited spanning tree, and among those, {1,4} and {2,4}, minimize the larger label, which is 4. In this case, the exchange {2,4} is applied, but {1,4} would be a valid alternative for the algorithm.

Figure 4: Illustration of the sixth iteration of Algorithm G in the run shown in Figure 2 (c).

In general, in step G2 there may be several edge exchanges

{e1,f},{e2,f},,{et,f} with (e1)<(e2)<<(et)<(f), (1)

applicable to the current spanning tree to give an unvisited spanning tree, which all have (f) as the larger label, differing only in the smaller label (ei), i[t]. We refer to such a situation as a tie. A tie-breaking rule is a procedure that determines which exchange to apply in case of a tie.

By definition of the step G2, Algorithm G only selects edge exchanges that result in a previously unvisited spanning tree of G, i.e., the produced listing of spanning trees will not contain repetitions. However, it could be that the algorithm terminates before having visited the entire set 𝒯(G), a situation that is ruled out by the next theorem.

Theorem 4 ([17, Thm. 10]).

For any graph G, for any edge labeling of G, for any initial spanning tree 𝒯(G), and for any tie-breaking rule, Algorithm G yields a genlex listing of all spanning trees of G.

A listing of bitstrings is called genlex if all strings with the same suffix appear consecutively. In particular, all strings ending with 0 appear before all strings ending with 1, or vice versa. A genlex listing of bitstrings is also sometimes referred to as suffix-partitioned in the literature. Note that genlex order generalizes colexicographic order. In the context of spanning trees, the genlex property refers to the corresponding characteristic vectors χ(T) of spanning trees T𝒯(G); see the right-hand side of Figure 2 (c). In other words, all spanning trees not containing the highest-labeled edge appear before all spanning trees containing this edge, or vice versa, and this property is true recursively within the blocks.

As evidenced by this theorem, the greedy Algorithm G is very powerful and versatile. In fact, the algorithm can be generalized for listing the bases of any matroid by base exchanges, and even more generally, for traversing a Hamilton path on the skeleton of any 0/1-polytope [16].

1.4 The face-exchange property

The paper [17] also introduced another closeness condition for edge exchanges, which is well-defined only for plane graphs. Specifically, a face-exchange between two spanning trees of a plane graph is an exchange of two edges that lie on a common face. If an edge exchange is both a pivot-exchange and face-exchange, then we refer to it as a pivotface-exchange. A weaker requirement is that it is a pivot-exchange or a face-exchange, and then we refer to it as a pivotface-exchange. These notions give rise to the following question.

Problem 5.

Does every plane graph G admit a pivotface-exchange or a pivotface-exchange Gray code of its spanning trees?

Pivot- and face-exchanges are connected through the well-known concept of the dual graph; see Figure 5 (a). For a plane graph G, we write F(G) for the set of faces of G. The dual graph G is the plane graph obtained from G as follows: For every face αF(G), the dual graph G has a vertex αV(G), and for every edge e of G between faces α and β of G, the dual graph G has the edge e=(α,β). For every vertex vV(G), we write vF(G) for the corresponding face of G dual to it. For a spanning tree T𝒯(G), the dual spanning tree T𝒯(G) has the dual edge eE(T) for every non-edge eE(G)E(T) and a dual non-edge eE(T) for every edge eE(T); see Figure 5 (b). Observe that a pivot-exchange {e,f} in T is a face-exchange {e,f} in the dual spanning tree T; see Figure 5 (c). Symmetrically, a face-exchange {e,f} in T is a pivot-exchange {e,f} in T.

Figure 5: Connection between pivot- and face-exchanges via the dual spanning tree.

Merino, Mütze and Williams [17] strengthened Theorem 3, by showing that for a suitable edge labeling of the fan graph Fn and a suitable tie-breaking rule, Algorithm G yields a pivotface-exchange Gray code. Specifically, the edges of Fn are labeled from left-to-right, as shown in Figure 2 (c), and ties are broken according to the closest tie-breaking rule, which in case of a tie as in (1) selects the exchange {et,f}, i.e., the exchange that maximizes the smaller of the edge labels (et) (equivalently, the one for which the smaller label is closest to the larger label (f)).

Theorem 6.

For any n3, for the left-to-right labeling of the edges of Fn, for any initial spanning tree 𝒯(Fn), and for the closest tie-breaking rule, Algorithm G yields a genlex pivotface-exchange Gray code for the spanning trees of Fn.

In fact, the Gray code from Theorem 3 also has the stronger pivotface-exchange property.

(a) (b)
Figure 6: (a) Pivot-exchange Gray code for the spanning trees of the outerplane triangulation G. (b) Pivotface-exchange Gray code for the spanning trees of the outerplane graph G, which has the four marked face-exchanges {1,7}, and the rest pivot-exchanges. Both listings were computed by Algorithm G, and the spanning trees are represented by their characteristic vectors, with 1-bits and 0-bits drawn as black and white squares, respectively. The initial spanning tree is highlighted in both graphs.

1.5 Our results

In this work, we solve Problems 1 and 5 for certain families of plane graphs that generalize fan graphs, thus generalizing Theorems 3 and 6.

An outerplane graph is a plane graph in which all vertices are incident to the outer face. An outerplane graph is a triangulation if all of its faces, except possibly the outer face, are triangles. Note that fan graphs are a very special case of outerplane triangulations.

Theorem 7.

For any outerplane triangulation G, there is an edge labeling of G, so that for any initial spanning tree 𝒯(G), there is a tie-breaking rule for which Algorithm G yields a genlex pivot-exchange Gray code for the spanning trees of G.

Theorem 8.

For any outerplane graph G, there is an edge labeling of G, so that for any initial spanning tree 𝒯(G), there is a tie-breaking rule for which Algorithm G yields a genlex pivotface-exchange Gray code for the spanning trees of G.

These theorems directly yield efficient algorithms. Specifically, using the techniques described in [16, Sec. 7.2+Cor. 32], Algorithm G can be implemented to output each spanning tree in time 𝒪(nlogn), where n is the number of vertices of G. The required space for the algorithm is 𝒪(n). In particular, this implementation is history-free in the sense that no previously computed spanning trees apart from the current spanning tree need to be stored, plus some simple data structures for bookkeeping.

Two examples of Gray code listings of spanning trees obtained from these theorems are shown in Figure 6.

Corollary 9.

Any outerplane triangulation admits a genlex pivot-exchange Gray code of its spanning trees. Any outerplane graph admits a genlex pivotface-exchange Gray code of its spanning trees.

The weak dual graph of a plane graph G, denoted G is the graph obtained from the dual graph G by removing the vertex corresponding to the outer face of G; see Figure 7 (a).

Figure 7: Illustration of (a) weak dual graph; (b) 2-connected outerplane triangulation and its weak dual tree; (e) 2-connected outerplane triangulation whose weak dual tree is a path.

Note that G is a 2-connected outerplane graph if and only if the weak dual G is a tree; see Figure 7 (b). Also note that G is a path if and only if G is 2-connected and all but at most two sides of every inner face are incident with the outer face; see Figure 7 (c). In particular, for a triangulation G, we have that G is a path if and only if G is 2-connected and at least one side of every triangle touches the outer face. This is true in particular for fan graphs Fn.

We show that fan graphs, and more generally outerplane triangulations for which the weak dual is a path, are exactly the outerplane graphs that have the maximum number of spanning trees for a fixed number of edges. Moreover, the counts are the Fibonacci numbers, defined as f0:=0, f1:=1 and

fm+1:=fm+fm1 (2)

for all m1. We write t(G):=|𝒯(G)| for the number of spanning trees of G.

Theorem 10.

For any outerplane graph G with m edges we have t(G)fm+1, with equality if and only if G is a triangulation such that G is a path.

The identity t(G)=fm+1 when G is a triangulation for which G is a path was already noticed by Slater [29, Prop. 1].

 Remark 11.

We remark that Problems 1, 2 and 5 are perfectly valid also for multigraphs, i.e., graphs that may have parallel edges and/or loops (though loops are irrelevant in the context of spanning trees). In fact, Theorems 4, 7 and 8, and hence Corollary 9, also hold in this more general setting. An “outerplane triangulation” in this case has all inner faces of lengths at most 3, instead of exactly 3. The time and space bounds stated after Theorem 8 change to 𝒪(mlogn) and 𝒪(m), respectively, where m is the number of edges of the multigraph. However, for simplicity we do our proofs in the setting of simple graphs, where no parallel edges nor loops are allowed. Nonetheless, our proof of Theorem 10 will actually use multigraphs.

 Remark 12.

The listings of spanning trees produced by Algorithm G are in general not Hamilton cycles in (G), but only Hamilton paths, i.e., the first and last spanning tree in general do not differ in an edge exchange. This remark applies to all the Gray codes mentioned in Theorems 4, 6, 7, and 8, and in Corollary 9. For some graphs, some edge labelings, and some initial spanning trees, however, the Gray codes are cyclic, such as the one mentioned in Theorem 6 for the L-shaped initial spanning tree shown in Figure 2 (c), which ends with the mirrored L.

1.6 Related work

There has been an extensive amount of work [23, 9, 15, 12, 27, 28] on efficiently generating the set 𝒯(G) of all spanning trees of G, without the requirement that any two consecutive trees differ in an edge exchange, i.e., the computed listings are not Hamilton paths or cycles in the flip graph (G). The algorithms in the last three of the aforementioned papers achieve this in time 𝒪(1) on average per generated tree. See the survey [4] for a comparison of the different algorithms.

If instead of listing all spanning trees of G, we want to count them, then this can be achieved by Kirchhoff’s Matrix-Tree Theorem, which reduces the problem to computing a determinant, which can be done efficiently. This problem is closely connected to finding the so-called most vital edge of G, which is the edge contained in the most spanning trees from 𝒯(G). Random sampling [1, 2] and ranking/unranking [6, 7] of spanning trees have also been considered.

1.7 Outline of this paper

In Section 2 we prove Theorems 7 and 8. In Section 3 we prove Theorem 10. We conclude with some open questions in Section 4, and there we also report on some experimental evidence.

2 Proof of Theorems 7 and 8

For the proofs of Theorems 7 and 8, we will assume w.l.o.g. that the outerplane graph G is 2-connected. If G is not 2-connected, then all the arguments presented in the following apply to each of its blocks, and the spanning trees of G are obtained by combining the spanning trees in each block in all possible ways, and pivot- or face-exchanges remain valid within the blocks.

We first describe the labeling of edges of a 2-connected outerplane graph G that we use in order to run Algorithm G on the graph G. We then establish two important properties of these labelings (Lemmas 13 and 14) that are crucial to show that whenever an arbitrary edge exchange becomes applicable in step G2 of Algorithm G, then ties can be broken to instead use a pivot- or face-exchange (Lemma 15).

2.1 The edge labeling

To define the edge labeling, we need another definition. Let v be the vertex of G corresponding to the outer face of G, and let d be the degree of v. The split dual graph, denoted G, is obtained from G by splitting v into d many degree-1 vertices, one adjacent to each neighbor of v; see Figure 8 (a).

Note that the weak dual graph G is a tree if and only if the split dual graph G is a tree; see Figures 7 (b) and 8 (b). Furthermore, G is a path if and only if G is a caterpillar, i.e., a tree in which all vertices are in distance 1 from a central path; see Figures 7 (c) and 8 (c).

Figure 8: Illustration of (a) split dual graph; (b) 2-connected outerplane triangulation and its split dual tree; (c) 2-connected outerplane triangulation whose split dual tree is a caterpillar (cf. Figure 7).

Let G be a 2-connected outerplane graph with m edges. We consider the split dual tree G, we pick a leaf r of this tree as root, and we orient all of its edges away from r, giving an oriented tree  , referred to as oriented split dual. We label the edges of  in a depth-first-search manner with integers 1,,m, starting at the root r and processing subtrees in counterclockwise (ccw) order; see Figure 9. The labeling of the edges of  induces a labeling of the corresponding dual edges of G with integers from [m]. We refer to this labeling of the edges of G as dual-tree labeling. Note that there is freedom in the choice of the root in the tree G, and different choices yield different oriented split dual trees  and hence different edge labelings of the same graph G. Note that the left-to-right labeling of the fan graph G=Fn shown in Figure 2 (c) is one particular dual-tree labeling.

Figure 9: Illustration of the dual-tree labeling procedure.

2.2 Proofs of theorems

Throughout this section, we let G be a 2-connected outerplane graph with m edges, an oriented split dual tree, and :E(G)[m] the corresponding dual-tree labeling of the edges of G. Before proving Theorems 7 and 8, we first derive two properties of the edge labelings defined in the previous section, stated in Lemmas 13 and 14 below.

The following definitions are illustrated in Figure 10. We denote a face α of G of length t by the sequence of edges (e1,,et) bounding this face in ccw order, starting with the edge e1 whose dual edge in  is oriented towards α (all other edges of  are oriented away from α). For a face α=(e1,,et) and an index i[t], the (α,ei)-lobe Lα,ei is the set of edges of G that are dual to the edges in the maximal subtree of G that contains the edge ei, but none of the other edges ej, j[t]{i}.

Figure 10: Illustration of lobes.
Lemma 13.

For any face α=(e1,,et) of G, we have (e1)<(e2)<<(et). Furthermore, for any i{2,,t} and fLα,ei{ei} we have (ei)<(f), and (f)<(ei+1) if i<t.

Proof.

This is an immediate consequence of the labeling procedure which processes subtrees in the oriented split dual in ccw order and in a depth-first-search manner. Specifically, for all i{2,,t}, all edges of Lα,ei{ei} are labeled directly after ei, and directly before ei+1 if i<t.

For a vertex v of G, the incidence list Ev is the sequence of edges incident to v in clockwise order around v, starting and ending with the two edges that bound the outer face; see Figure 11. We say that an edge e incident with v is a cw-edge or ccw-edge, respectively, according to the clockwise or counterclockwise orientation of the dual edge e in  around v.

Lemma 14.

For any vertex v, let Ev=:(e1,,et) be its incidence list. Then there is an index i{0,,t} such that e1,,ei are ccw-edges, ei+1,,et are cw-edges, and we have (ei)<(ei1)<<(e1)<(ei+1)<(ei+2)<<(et). In particular, for any cw-edge ej and any i[j1] we have (ei)<(ej).

Figure 11: Illustration of Lemma 14.

Proof.

For any sequence of edges P=(a1,,at) that form a path in the oriented tree  , there is an index i{0,,t} such that a1,,ai are oriented towards the start vertex of P and ai+1,,at are oriented towards the end vertex of P. The special cases i=0 and i=t mean that the path is oriented conformly, towards the end or start vertex, respectively.

The sequence of dual edges P:=(e1,,et) is a path in  to which the aforementioned observation applies. For j{1,,t1}, let fj be the face of G bounded by ej and ej+1. Furthermore, we denote the outer face of G by f0=ft. Note that ej is oriented towards fj1 in  for j=1,,i, i.e., these are all ccw-edges w.r.t. v. Furthermore, ej is oriented towards fj in  for j=i+1,,t, i.e., these are all cw-edges w.r.t. v.

Applying Lemma 13 to the faces fj, j=1,,i1 and j=i+1,,t1, yields (ei)<(ei1)<<(e1) and (ei+1)<(ei+2)<<(et), respectively. Furthermore, applying Lemma 13 to Lfi,ei and Lfi,ei+1 proves that (e1)<(ei+1). Combining these inequalities proves the lemma.

Lemma 15.

Let T𝒯(G) and let {e,f} with (e)<(f) be an edge exchange for T. Then there is a pivotface-exchange {d,f} with (d)<(f). Furthermore, if G is a triangulation, then {d,f} is a pivot-exchange.

Proof.

We let α=(e1,,et) be the face incident with f in G for which the dual edge f in  is oriented away from α. As (f)>(e)1 we have (f)>1, and consequently α is not the outer face, but an inner face. We have f=ei for some i{2,,t}. The graph T{e,f} contains exactly one cycle C, which contains both edges e and f. As (e)<(f), Lemma 13 implies that eLα,f, and as eC, we obtain that C contains edges from every lobe Lα,ei for all i[t], and furthermore eLα,ej for some j{1,,i1}.

We now distinguish the cases whether fT or fT, i.e., whether the exchange {e,f} adds the edge e and removes f, or removes e and adds f, respectively. These two cases are illustrated in Figure 12 (a) and (b), respectively.

Figure 12: Illustration of the two cases in the proof of Lemma 15.

Case (a).

fT. Note that {d,f} with d:=ej is a valid face-exchange for T, and we have (d)<(f) by Lemma 13. Furthermore, if G is a triangulation, then we have t=3 and consequently f=ei and d=ej share an end vertex, so the exchange {d,f} is a pivot-exchange.

Case (b).

fT. Let d be the edge of C incident with f in the lobe Lα,ei1. Note that {d,f} is a valid pivot-exchange for T. If i>2, then we have (d)<(f) by Lemma 13. If i=2, then let v be the common end vertex of e1=ej and e2=ei, and consider the incidence list Ev of v. The edge e1 is a cw-edge and d comes before it (or is equal to e1) on the list Ev, and so Lemma 14 yields (d)(e1). By Lemma 13 we have (e1)<(f) and therefore (d)<(f).

We are now in position to prove Theorems 7 and 8.

Proof of Theorems 7 and 8.

By Lemma 15, whenever Algorithm G considers an edge exchange {e,f} with (e)<(f), there is a pivotface-exchange {d,f} with (d)<(f). By Theorem 4, the listing of spanning trees produced by Algorithm G has the genlex property, which implies that if T{e,f} is unvisited, then T{d,f} is also unvisited. It follows that there is a tie-breaking rule for Algorithm G to only ever use pivotface-exchanges.

Furthermore, if G is a triangulation, then by Lemma 15 the alternative exchange {d,f} is a pivot-exchange, so there is a tie-breaking rule for Algorithm G to only ever use pivot-exchanges.

3 Proof of Theorem 10

We prove Theorem 10 in the more general setting of multigraphs (recall Remark 11), i.e., from now on we allow multiple edges between pairs of vertices. Two edges between the same pair of vertices are sometimes referred to as parallel edges. Loops may be present, but are never contained in a spanning tree and hence irrelevant for us. However, the distinction of parallel edges is important. For example, the plane graph formed by two vertices connected by m parallel edges has m different spanning trees, each containing exactly one of the m edges.

All notions introduced in Section 1 are valid in the more general context of multigraphs. The only exception is the definition of an outerplane triangulation, which we change from “face length 3” to “face length 3”. A length-2 face comes from two parallel edges, and is called a digon.

In addition to edge removal and edge addition, we now also introduce the operation of edge contraction. Given a graph G and an edge eE(G), we write G/e for the graph obtained from G by contracting the edge e. Note that even if G is a simple graph, G/e may still contain parallel edges, and if G has parallel edges, then G/e may contain loops (which can be ignored when counting spanning trees). The number of spanning trees t(G) of a graph G obeys the well-known recursive relation

t(G)=t(Ge)+t(G/e), (3)

valid for any (non-loop) edge eE(G) (see [18]).

We need the following auxiliary lemma about Fibonacci numbers.

Lemma 16.

For any two integers i,j1, we have fifjfi+j1, with equality if and only if i=1 or j=1.

Proof.

If i=1 or j=1, then one can check directly that the claimed equality holds.

Now assume that i,j2. We prove that fifj<fi+j1 by induction on i+j. In the base case i+j=4 we have i=j=2 and therefore fi=fj=f2=1 and fi+j1=f3=2, so the claim is true. For the induction step we distinguish the cases j{2,3} and j>3. If j=2 we have fifj=fi<fi+1=fi+j1 (recall that i2). If j=3 we have fifj=2fi<fi+fi+1=fi+2=fi+j1. It remains to consider the case j>3. We have

fifj=fi(fj2+fj1)=fifj2+fifj1<fi+j3+fi+j2=fi+j1,

where the strict inequality in the third step holds by induction, using that j2>1.

Theorem 10 is an immediate consequence of the following more general statement for multigraphs.

Theorem 17.

For any outerplane (multi)graph G with m edges we have t(G)fm+1, with equality if and only if G is a triangulation such that G is a path and all digons are incident with the outer face.

Note that digons incident with the outer face correspond to degree 1 vertices in the dual graph G, so if G is a path, then there are at most two such digons corresponding to end vertices of the path.

Theorem 17 is illustrated in Figure 13.

Figure 13: Sequence of outerplane graphs that maximize the number of spanning trees, with the corresponding counts, the Fibonacci numbers. They are all triangulations for which G is a path, and they either have no digons (red) or one digon incident with the outer face (blue). For each graph, deleting or contracting the bold edge yields the two preceding graphs.

Proof.

We argue by induction on m. The induction basis m=0 is trivial. For the induction step we assume that m1.

If G is not 2-connected, then it has at least two blocks A and B with a1 and b1 edges, respectively, where a+b=m. We have t(G)=t(A)t(B) and therefore t(G)fa+1fb+1<fa+b+1=fm+1, where the strict inequality follows from Lemma 16.

It remains to consider the case that G is 2-connected. If G is a single edge, then t(G)=1=f2. If G has only one inner face, then it is a cycle and we have t(G)=mfm+1, and this inequality is tight for m{2,3} and strict for m4. The same estimates hold if all inner faces of G are digons, i.e., G has 2 vertices and all m edges are parallel to each other. For the rest of the proof we assume that G has at least two faces, not all of which are digons. This implies in particular that m4. We consider a face α of G for which the dual vertex α has degree at most 1 in G. We denote the sequence of edges bounding α by e1,,et in clockwise order, ending with the edge et that has a dual edge in G. We distinguish two cases, namely whether α is a digon (t=2) or not (t3), and we bound the number of spanning trees using (3) with respect to the edge e:=e1, i.e., the first edge of the face α. These two cases are illustrated in Figure 14 (a) and (b), respectively.

Figure 14: Illustration of the proof of Theorem 17.

Case (a).

t=2. Ge has m1 edges, and therefore

t(Ge)fm (4)

by induction. Let s2 be the number of edges that are parallel to e1 (including e1 and e2), and denote them by e1,e2,,es in ccw order around the corresponding common end vertex; see Figure 14 (a). Furthermore, we let β be the face incident with es but not es1. In the graph G/e, the edges e2,,es are loops, and we can therefore remove all of them, so we have

t(G/e)=t(G/e{e2,,es})fm1 (5)

by induction. Combining (2), (3), (4), and (5) proves that t(G)fm+1, as claimed. Furthermore, this inequality is tight if and only if (4) and (5) are tight, which happens if and only if the conditions stated in the theorem hold for Ge and G/e, which happens if and only if s=2 and β is a triangle that is incident with the outer face, if and only if the conditions stated in the theorem hold for G.

Case (b).

t3. Let β be the face incident with et but not e1. G/e has m1 edges, and therefore

t(G/e)fm (6)

by induction. In the graph Ge, the edges e2,,et1 are present in every spanning tree, so we have

t(Ge)=t(G{e1,,et1})fm1 (7)

by induction. Combining (2), (3), (6) and (7) proves that t(G)fm+1, as claimed. Furthermore, this inequality is tight if and only if (6) and (7) are tight, which happens if and only if the conditions stated in the theorem hold for G/e and Ge, which happens if and only if t=3 and β is a triangle that is incident with the outer face, if and only if the conditions stated in the theorem hold for G.

4 Open problems

Problems 1 and 5 remain open for general graphs, i.e., for graphs not covered by Theorems 7 and 8 (recall Remark 11). Also, Knuth’s more general Problem 2 for directed graphs remains very much open.

Concerning Problem 1, we checked experimentally that all 2-connected graphs on up to 6 vertices admit a pivot-exchange Gray code for their spanning trees, and these Gray codes are all cyclic. Regarding Problem 2, we checked that all directed graphs on up to 5 vertices (oppositely oriented arcs are allowed) whose underlying undirected graph is 2-connected admit an edge exchange Gray code for their arborescences, for any choice of fixed root. In some cases those flip graphs admit no Hamilton cycle, but only a Hamilton path (see [22]), so not all of these Gray codes are cyclic. Regarding Problem 5, we checked that all outerplane graphs on up to 6 vertices admit a cyclic pivotface-exchange Gray code for their spanning trees.

Furthermore, Knuth [14] asked in Exercise 101 in Section 7.2.1.6 whether the complete graph Kn admits a “nice” Gray code listing of its spanning trees. One interpretation of this question, in the spirit of Problem 1, could be: Is there a pivot-exchange Gray code for the spanning trees of Kn? Alternatively, is there a Gray code listing that provides a more fine-grained explanation of Cayley’s formula nn2 for the number of spanning trees? Similar questions can be asked for the complete bipartite graph Kn,n.

Does Theorem 10 hold without the outerplane requirement for m sufficiently large? The only complete graphs Kn that violate the bound t(Kn)f(n2)+1 arise for n=4,5,6.

References

  • [1] D. J. Aldous. The random walk construction of uniform spanning trees and uniform labelled trees. SIAM J. Discrete Math., 3(4):450–465, 1990. doi:10.1137/0403039.
  • [2] A. Z. Broder. Generating random spanning trees. In 30th Annual Symposium on Foundations of Computer Science, Research Triangle Park, North Carolina, USA, 30 October - 1 November 1989, pages 442–447. IEEE Computer Society, 1989. doi:10.1109/SFCS.1989.63516.
  • [3] B. Cameron, A. Grubb, and J. Sawada. Pivot Gray codes for the spanning trees of a graph ft. the fan. Graphs Combin., 40(4):Paper No. 78, 26 pp., 2024. doi:10.1007/s00373-024-02808-2.
  • [4] M. Chakraborty, S. Chowdhury, J. Chakraborty, R. Mehera, and R. K. Pal. Algorithms for generating all possible spanning trees of a simple undirected connected graph: an extensive review. Complex & Intelligent Systems, 5:265–281, 2019.
  • [5] W.-K. Chen. Hamilton circuits in directed-tree graphs. IEEE Trans. Circuit Theory, CT-14:231–233, 1967.
  • [6] C. J. Colbourn, R. P. J. Day, and L. D. Nel. Unranking and ranking spanning trees of a graph. J. Algorithms, 10(2):271–286, 1989. doi:10.1016/0196-6774(89)90016-3.
  • [7] C. J. Colbourn, W. J. Myrvold, and E. Neufeld. Two algorithms for unranking arborescences. J. Algorithms, 20(2):268–281, 1996. doi:10.1006/jagm.1996.0014.
  • [8] R. L. Cummins. Hamilton circuits in tree graphs. IEEE Trans. Circuit Theory, CT-13:82–90, 1966.
  • [9] H. N. Gabow and E. W. Myers. Finding all spanning trees of directed and undirected graphs. SIAM J. Comput., 7(3):280–287, 1978. doi:10.1137/0207024.
  • [10] C. A. Holzmann and F. Harary. On the tree graph of a matroid. SIAM J. Appl. Math., 22:187–193, 1972. doi:10.1137/0122021.
  • [11] T. Kamae. The existence of a Hamilton circuit in a tree graph. IEEE Trans. Circuit Theory, CT-14:279–283, 1967.
  • [12] S. Kapoor and H. Ramesh. Algorithms for generating all spanning trees of undirected, directed and weighted graphs. In Algorithms and data structures (Ottawa, ON, 1991), volume 519 of Lecture Notes in Comput. Sci., pages 461–472. Springer, Berlin, 1991. doi:10.1007/BFb0028284.
  • [13] G. Kishi and Y. Kajitani. On Hamilton circuits in tree graphs. IEEE Trans. Circuit Theory, CT-15(1):42–50, 1968.
  • [14] D. E. Knuth. The Art of Computer Programming. Vol. 4A. Combinatorial Algorithms. Part 1. Addison-Wesley, Upper Saddle River, NJ, 2011.
  • [15] T. Matsui. A flexible algorithm for generating all the spanning trees in undirected graphs. Algorithmica, 18(4):530–543, 1997. doi:10.1007/PL00009171.
  • [16] A. Merino and T. Mütze. Traversing combinatorial 0/1-polytopes via optimization. SIAM J. Comput., 53(5):1257–1292, 2024. doi:10.1137/23M1612019.
  • [17] A. Merino, T. Mütze, and A. Williams. All your bases¯ are belong to us: listing all bases of a matroid by greedy exchanges. In 11th International Conference on Fun with Algorithms, volume 226 of LIPIcs. Leibniz Int. Proc. Inform., pages Paper No. 22, 28. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2022. doi:10.4230/lipics.fun.2022.22.
  • [18] G. Minty. A simple algorithm for listing all the trees of a graph. IEEE Trans. Circuit Theory, 12(1):120, 1965.
  • [19] T. Mütze. Combinatorial Gray codes—an updated survey. Electron. J. Combin., DS26(Dynamic Surveys):99 pp., 2023. doi:10.37236/11023.
  • [20] D. J. Naddef and W. R. Pulleyblank. Hamiltonicity and combinatorial polyhedra. J. Combin. Theory Ser. B, 31(3):297–312, 1981. doi:10.1016/0095-8956(81)90032-0.
  • [21] D. J. Naddef and W. R. Pulleyblank. Hamiltonicity in (0-1)-polyhedra. J. Combin. Theory Ser. B, 37(1):41–52, 1984. doi:10.1016/0095-8956(84)90043-1.
  • [22] V. Rao and N. Raju. On tree graphs of directed graphs. IEEE Trans. Circuit Theory, 19(3):282–283, 1972.
  • [23] R. C. Read and R. E. Tarjan. Bounds on backtrack algorithms for listing cycles, paths, and spanning trees. Networks, 5(3):237–252, 1975. doi:10.1002/net.1975.5.3.237.
  • [24] C. D. Savage. A survey of combinatorial Gray codes. SIAM Rev., 39(4):605–629, 1997. doi:10.1137/S0036144595295272.
  • [25] A. Schrijver. Combinatorial optimization. Polyhedra and efficiency. Vol. B, volume 24 of Algorithms and Combinatorics. Springer-Verlag, Berlin, 2003. Matroids, trees, stable sets, Chapters 39–69.
  • [26] H. Shank. A note on Hamilton circuits in tree graphs. IEEE Trans. Circuit Theory, 15(1):86, 1968. doi:10.1109/TCT.1968.1082765.
  • [27] A. Shioura and A. Tamura. Efficiently scanning all spanning trees of an undirected graph. J. Oper. Res. Soc. Japan, 38(3):331–344, 1995. doi:10.15807/jorsj.38.331.
  • [28] A. Shioura, A. Tamura, and T. Uno. An optimal algorithm for scanning all spanning trees of undirected graphs. SIAM J. Comput., 26(3):678–692, 1997. doi:10.1137/S0097539794270881.
  • [29] P. J. Slater. Fibonacci numbers in the count of spanning trees. Fibonacci Quart., 15(1):11–14, 1977.
  • [30] M. J. Smith. Generating spanning trees. Master’s thesis, University of Victoria, 1997.