Linear algebraic techniques for spanning tree enumeration
Steven Klee, Matthew T. Stamps

TL;DR
This paper introduces linear algebraic methods, specifically the Matrix Determinant Lemma and Schur complement, to efficiently count spanning trees in various graph families, simplifying computations beyond traditional determinant approaches.
Contribution
It demonstrates novel applications of linear algebra techniques to improve spanning tree enumeration in specific graph classes.
Findings
Efficient counting of spanning trees using linear algebra methods.
Application of Matrix Determinant Lemma and Schur complement to graph theory.
Simplification of complex determinant calculations for certain graph families.
Abstract
Kirchhoff's Matrix-Tree Theorem asserts that the number of spanning trees in a finite graph can be computed from the determinant of any of its reduced Laplacian matrices. In many cases, even for well-studied families of graphs, this can be computationally or algebraically taxing. We show how two well-known results from linear algebra, the Matrix Determinant Lemma and the Schur complement, can be used to elegantly count the spanning trees in several significant families of graphs.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Linear Algebraic Techniques for Spanning Tree Enumeration
Steven Klee and Matthew T. Stamps
Abstract.
Kirchhoff’s matrix-tree theorem asserts that the number of spanning trees in a finite graph can be computed from the determinant of any of its reduced Laplacian matrices. In many cases, even for well-studied families of graphs, this can be computationally or algebraically taxing. We show how two well-known results from linear algebra, the matrix determinant lemma and the Schur complement, can be used to count the spanning trees in several significant families of graphs in an elegant manner.
1. Introduction
A graph consists of a finite set of vertices and a set of edges that connect some pairs of vertices. For the purposes of this article, we will assume that all graphs are simple, meaning they do not contain loops (an edge connecting a vertex to itself) or multiple edges between a given pair of vertices. We will use and to denote the vertex set and edge set of , respectively. For example, the graph with
and
is shown in Figure 1.
A spanning tree in a graph is a subgraph , meaning is a graph with and , that satisfies three conditions:
- (1)
Every vertex in is a vertex in ; 2. (2)
is connected, meaning it is possible to walk between any two vertices in using only edges in ; and 3. (3)
does not contain any cycles.
Figure 1 shows an example and several nonexamples of spanning trees in our example graph to illustrate the relevance of each of these conditions.
For our example graph , it is possible to write down all the spanning trees. This is shown in Figure 2.
In general, the number of spanning trees in a graph can be quite large, and exhaustively listing all of its spanning trees is not feasible. For this reason, we need to be more resourceful when counting the spanning trees in a graph. Throughout this article, we will use to denote the number of spanning trees in a graph . A common approach for calculating involves linear algebraic techniques and the Laplacian matrix of .
If is a graph with vertex set , the Laplacian matrix of , denoted by is a matrix whose rows and columns are indexed by vertices of . The entries of the Laplacian matrix are given by
[TABLE]
Here, denotes the degree of vertex in , which is the number of edges in that contain . It follows from the definition that the rows and columns of sum to [math], which means is always singular. Remarkably, if we delete any row and any column of , then up to a sign, the determinant of the resulting matrix counts the number of spanning trees in . This is the content of Kirchhoff’s matrix-tree theorem [10], which we state more precisely below. Let denote the matrix obtained from by deleting the th row and th column. This submatrix is sometimes called a reduced Laplacian of .
Kirchhoff’s Matrix-Tree Theorem**.**
Let be a connected graph with vertex set . For any vertices , not necessarily distinct,
[TABLE]
The Laplacian matrix of the graph from Figure 1, along with the reduced Laplacian are
[TABLE]
It can be checked that and , which is consistent with the eight spanning trees we listed in Figure 2.
For the remainder of this article, we will combine two well-known results in linear algebra with the matrix-tree theorem to obtain elegant explicit formulas for in terms of the number and degrees of its vertices.
2. Tools from linear algebra
Even for simple graphs such as the one in Figure 1, computing the determinant of a reduced Laplacian can be computationally intensive. Depending on the choice of which row and column are to be crossed out, the determinant of some reduced Laplacians might be easier to compute than others, but the necessity to make a such a choice may seem unsatisfactory. In this section, we present our main result, which will play a central role throughout the subsequent sections of the article. We proceed with the first of two well-known results from linear algebra. Recall that the adjugate of an matrix is the transpose of its matrix of cofactors.
The Matrix Determinant Lemma**.**
Let be an matrix and let and be column vectors in . Then
[TABLE]
In particular, if is invertible, then .
A proof of the matrix determinant lemma can be found in [9, §0.8.5], where it is referred to as Cauchy’s formula for the determinant of a rank-one perturbation. The main ingredients in the proof are the fact that is a multilinear operator on the rows of a matrix and the observation that is a rank-one matrix. With this, we are ready to present our main result.
Lemma 1**.**
Let be a graph on vertex set with Laplacian matrix and let and be column vectors in . Then
[TABLE]
Proof.
Let denote the matrix of ones and let denote the column vector of ones. By Kirchoff’s matrix-tree theorem, every cofactor of is equal to , so can be written as Therefore, by the matrix determinant lemma,
[TABLE]
∎
In the case that , this result is credited to Temperley [18].
2.1. The Schur complement of a matrix.
Later in this article, there will be instances in which we partition the vertices of a graph into disjoint subsets as . In such instances, the Laplacian matrix of can be decomposed into a block matrix of the form
[TABLE]
where the first rows and columns correspond to the vertices in and the last rows and columns correspond to the vertices in . In this case, and are square matrices of sizes and , respectively.
Suppose is any square matrix that can be decomposed into blocks as above with and square. If is invertible, then the Schur complement of in is defined as . The fundamental reason for using Schur complements is the following result in [9, §0.8.5].
Lemma 2**.**
Let be a square matrix decomposed as above into blocks , , , and with and square and invertible. Then
[TABLE]
When is a matrix and , Lemma 2 simply says
[TABLE]
which is just an alternative way of writing the familiar formula for the determinant of a matrix.
3. Applications to Complete Graphs
In this section, we demonstrate the applicability of Lemma 1 for enumerating spanning trees in complete graphs, complete bipartite graphs, and complete multipartite graphs. Formal definitions for each of these families of graphs will be given as we progress through this section, but examples of the complete graph , the complete bipartite graph , and the complete multipartite graph are shown in Figure 3.
The results presented here are all known in the literature, but the proofs seem new and more elementary than the existing proofs that use Kirchoff’s matrix-tree theorem.
For any positive integer , the complete graph is the graph with vertices, all of which are connected by edges. The following result, known as Cayley’s formula [4], was first proved by Borchardt [3] and is widely studied in enumerative combinatorics—for instance, see [17, §5.3] or [1, §33].
Proposition 1**.**
The number of spanning trees in the complete graph is .
Proof.
The Laplacian matrix has entries of on the diagonal and in all off-diagonal entries. Therefore, , where is the identity matrix. By Lemma 1, . ∎
For every pair of positive integers and , the complete bipartite graph has a vertex set partitioned into two sets, and of sizes and , respectively, where every vertex in is connected to every vertex in , but there are no edges among the vertices in or . The next result is a special case of Proposition 3, but its statement is clearer and its proof is more straightforward, so it warrants presenting this result first. Several proofs of this result can be found in the literature, for instance by Hartsfield and Werth [8] and Scoins [16].
Proposition 2**.**
The number of spanning trees in the complete bipartite graph is .
Proof.
Partition the vertex set of as with and so the Laplacian matrix of has the block form
[TABLE]
Let be the indicator vector for vertices in , meaning each entry indexed by a vertex in is and all other entries are [math]. Similarly, let be the indicator vector for vertices in . Then has the upper-triangular block form
[TABLE]
Therefore, by Lemma 1, we have
[TABLE]
∎
For every -tuple of positive integers , the complete multipartite graph has a vertex set that can be partitioned into disjoint sets with for such that and form an edge in if and only if . The following generalization of Cayley’s formula has several different proofs by Austin [2], Lewis [12], and Onodera [15].
Proposition 3**.**
Let be positive integers and let . The number of spanning trees in the complete multipartite graph is given by
[TABLE]
Proof.
For simplicity, let and let be ordered so that make up , make up , and so on. Then the Laplacian matrix of has blocks of the form on its diagonal and all other entries equal to . This means is a block diagonal matrix whose diagonal blocks have the form . By the matrix determinant lemma,
[TABLE]
Therefore, by Lemma 1,
[TABLE]
∎
4. Application to Ferrers graphs
In this section, we demonstrate the applicability of Lemmas 1 and 2 for enumerating spanning trees in a family of bipartite graphs corresponding to integer partitions called Ferrers graphs.
A partition of a positive integer is a weakly decreasing list of positive integers that sum to . For example, is a partition of . We write to denote the parts of a partition . To any partition, there is an associated Ferrers diagram, which is a stack of left-justified boxes with boxes in the first row, boxes in the second row, and so on. Finally, to any Ferrers diagram there is an associated Ferrers graph, whose vertices are indexed by the rows and columns of the Ferrers diagram with an edge if there is a box in the corresponding position. The Ferrers diagram and corresponding Ferrers graph associated to the partition are shown in Figure 4.
Equivalently, a Ferrers graph is a bipartite graph whose vertices can be partitioned as with (corresponding to the rows of the Ferrers diagram) and (corresponding to the columns) such that
- (1)
if is an edge in , then so is for any and , and 2. (2)
and are edges in .
Ehrenborg and van Willigenburg [6, Theorem 2.1] found the following beautiful formula counting the number of spanning trees in a Ferrers graph.
Theorem 1**.**
Let be a Ferrers graph whose vertices are partitioned as with and . Then
[TABLE]
We will give a new proof of this result using Lemmas 1 and 2. To begin, let us explore some general properties of Laplacians of bipartite graphs through the lens of Lemma 1.
Let be a connected bipartite graph whose vertices are partitioned as . The Laplacian matrix of can be partitioned as a block matrix with the form
[TABLE]
where (respectively, ) is an (respectively, ) diagonal matrix whose diagonal entries encode the degrees of the vertices in (respectively, ). The matrix is an matrix with rows indexed by vertices , columns indexed by vertices , and if is an edge and a [math] otherwise.
Now we consider a rank-one update to the Laplacian matrix that will be useful in interpreting Theorem 1. Consider the matrix
[TABLE]
where and are the indicator vectors for and in . We can decompose as
[TABLE]
where , , and are defined as in and . As a consequence of Lemma 1, .
On the other hand, if and only if , if and only if , and the entries of and equal zero otherwise. Applying Lemma 2 to and , we see that
[TABLE]
We can compute the entries of explicitly. Let and be elements of that are not necessarily distinct. The row indexed by in has a nonzero entry of for each that is a neighbor of and the column indexed by in has a nonzero entry of for each that is not a neighbor of . Therefore, the entry in row and column of is equal to , where the sum is over all that are incident with , but not . Consequently, the entries on the diagonal of are all zero. This proves the following proposition.
Proposition 4**.**
Let be a bipartite graph whose vertex set is partitioned as . Then
[TABLE]
where is the matrix with entries given by
[TABLE]
where denotes the set of neighbors of a vertex . ∎
We can now give a simple proof of Theorem 1.
Proof of Theorem 1.
Let be a Ferrers graph as described in the theorem statement and observe that the vertices in are naturally ordered such that . This means for every , and hence the corresponding entries of the matrix in Proposition 4 satisfy . Thus, the matrix is upper triangular with diagonal entries for , which means . The result follows by Proposition 4. ∎
5. Application to Threshold graphs
In this section, we demonstrate the applicability of Lemmas 1 and 2 for enumerating spanning trees in an important and well-studied family of graphs called threshold graphs; see [13].
A graph on vertices is a threshold graph if its vertices can be ordered in such a way that if for some , then whenever and for all . For a threshold graph , we consider a special vertex , where is taken to be the largest index such that for all . Because is threshold, this means for all .111For readers who are familiar with the definition of threshold graphs starting from an initial vertex and inductively adding dominating or isolated vertices, the vertex in our definition is the initial vertex, the vertices are the dominating vertices in (where is the first dominating vertex, the second, and so on), and the vertices are the isolated vertices (where is the first isolated vertex, the second, and so on). An example threshold graph is illustrated in Figure 5.
In this article, we are only interested in connected threshold graphs since disconnected graphs do not have any spanning trees. An important property of threshold graphs is that a threshold graph is connected if and only if its highest index vertex, , is not an isolated vertex. In other words, as long as has neighbors, the graph is connected.
As with Ferrers graphs, spanning trees in threshold graphs can also be counted by a beautiful formula, which appears several places in the literature, including proofs by Chestnut and Fishkind [5], Hammer and Kelmans [7], and Merris [14].
Theorem 2**.**
Let be a connected threshold graph on vertices, and let be the largest index such that for all . Then
[TABLE]
Before we give a new proof of this theorem, let us point out a familiar example. In the special case that , the threshold graph in question is the complete graph . In this case, each vertex has degree , so the expression in equation (1) simplifies to as we saw in Cayley’s formula.
Proof.
We begin with a few observations: First, since is connected, as noted above, which implies that for all . Next, recall that for all and, because was chosen to be the largest index such that whenever , it follows that whenever . Therefore, we know that the Laplacian matrix can be partitioned into blocks as
[TABLE]
where is the matrix whose diagonal entries are for and whose off-diagonal entries are all , is the diagonal matrix whose diagonal entries are for , and records the adjacencies with and .
Now let and , and consider the matrix , where is the vector of ones and is the indicator vector for in . By Lemma 1,
[TABLE]
On the other hand,
[TABLE]
where is a diagonal matrix with diagonal entries for and . Note that, for all and , has a nonzero entry if and only if and has a nonzero entry if and only if . Since the diagonal matrix is invertible by our assumption that for all , we can apply Lemma 2 to get that
[TABLE]
As in the proof of Theorem 1, we can explicitly compute the entries of . For , the entry in the row indexed by vertex and column indexed by is equal to , where the sum is over all with such that and . Because is a threshold graph, the set of such is empty when , which means is an upper-triangular matrix with diagonal entries for . Since is a diagonal matrix with diagonal entries for , we know that
[TABLE]
To complete the proof, we observe that because is threshold and , it must be the case that , hence for all . Therefore, . Similarly, by our choice of , we see that . The result now follows by cancelling appropriate terms from both sides. ∎
6. Conclusion
We have shown that the matrix determinant lemma and method of Schur complements can be used to simplify spanning tree enumeration for several families of graphs. While they may not shed as much light on spanning tree enumeration as a bijective proof would, they do give simpler, more direct proofs than other purely linear-algebraic approaches using the matrix-tree theorem. Our methods also extend naturally to weighted spanning tree enumeration [11]. Which other families of graphs are amenable to having their spanning trees counted by Lemma 1? We hope you can tell us!
Acknowledgments
Steven Klee’s research was supported by NSF grant DMS-1600048. Matthew Stamps is grateful to Isabella Novik and the Department of Mathematics at the University of Washington for hosting him during the time this research was conducted.
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1] Aigner, M., Ziegler, G. M. (2018). Proofs from The Book , 6th ed. Berlin: Springer. doi.org/10.1007/978-3-662-57265-8
- 2[2] Austin, T. L. (1960). The enumeration of point labelled chromatic graphs and trees. Canad. J. Math. 12: 535–545. doi.org/10.4153/CJM-1960-047-1
- 3[3] Borchardt, C. W. (1860). Über eine Interpolationsformel für eine Art Symmetrischer Functionen und über Deren Anwendung. Abh. d. PreußAkad. d. Wiss. 1–20.
- 4[4] Cayley, A. (1889). A theorem on trees. Quart. J. Pure Appl. Math. 23: 376–378.
- 5[5] Chestnut, S., Fishkind, D. (2012). Counting spanning trees in threshold graphs. ar Xiv:1208.4125 .
- 6[6] Ehrenborg, R., van Willigenburg, S. (2004). Enumerative properties of Ferrers graphs. Discrete Comput. Geom. 32(4): 481–492. doi.org/10.1007/s 00454-004-1135-1
- 7[7] Hammer, P. L., Kelmans, A. K. (1996). Laplacian spectra and spanning trees of threshold graphs. Discrete Appl. Math. 65(1-3): 255–273. doi.org/10.1016/0166-218X(94)00049-J
- 8[8] Hartsfield, N., Werth, J. S. (1990). Spanning trees of the complete bipartite graph. In: Bodendiek, R., Henn R.,eds. Topics in Combinatorics and Graph Theory . Heidelberg: Physica-Verlag HD, pp. 339–346. doi.org/10.1007/978-3-642-46908-4_38
