Skip to main content

The Matrix-Tree Theorem

  • 6227 Accesses

Part of the Undergraduate Texts in Mathematics book series (UTM)


The Matrix-Tree Theorem is a formula for the number of spanning trees of a graph in terms of the determinant of a certain matrix. We begin with the necessary graph-theoretical background. Let G be a finite graph, allowing multiple edges but not loops. (Loops could be allowed, but they turn out to be completely irrelevant.


  • Matrix Tree Theorem
  • Multiple Edges
  • Binet-Cauchy Theorem
  • Reduced Incidence Matrix
  • Bottom Left Block

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

This is a preview of subscription content, access via your institution.

Buying options

USD   29.95
Price excludes VAT (USA)
  • DOI: 10.1007/978-1-4614-6998-8_9
  • Chapter length: 16 pages
  • Instant PDF download
  • Readable on all devices
  • Own it forever
  • Exclusive offer for individuals only
  • Tax calculation will be finalised during checkout
USD   39.99
Price excludes VAT (USA)
  • ISBN: 978-1-4614-6998-8
  • Instant PDF download
  • Readable on all devices
  • Own it forever
  • Exclusive offer for individuals only
  • Tax calculation will be finalised during checkout
Softcover Book
USD   54.99
Price excludes VAT (USA)
Fig. 9.1
Fig. 9.2


  1. C.W. Borchardt, Ueber eine der Interpolation entsprechende Darstellung der Eliminations–Resultante. J. Reine Angew. Math. (Crelle’s J.) 57, 111–121 (1860)

    MATH  CrossRef  Google Scholar 

  2. A. Cayley, Note sur une formule pour la réversion des séries. J. Reine Angew. Math. (Crelle’s J.) 52, 276–284 (1856)

    MATH  CrossRef  Google Scholar 

  3. A. Cayley, A theorem on trees. Q. J. Math. 23, 376–378 (1889); Collected Papers, vol. 13 (Cambridge University Press, Cambridge, 1897), pp. 26–28

    Google Scholar 

  4. A. Joyal, Une théorie combinatoire des séries formelles. Adv. Math. 42, 1–82 (1981)

    MathSciNet  MATH  CrossRef  Google Scholar 

  5. J.W. Moon, in Counting Labelled Trees. Canadian Mathematical Monographs, vol. 1 (Canadian Mathematical Congress, 1970)

    Google Scholar 

  6. J. Pitman, Coalescent random forests. J. Comb. Theor. Ser. A 85, 165–193 (1999)

    MathSciNet  MATH  CrossRef  Google Scholar 

  7. H. Prüfer, Neuer Beweis eines Satzes über Permutationen. Arch. Math. Phys. 27, 742–744 (1918)

    Google Scholar 

  8. J.J. Sylvester, On the change of systems of independent variables. Q. J. Math. 1, 42–56 (1857); Collected Mathematical Papers, vol. 2 (Cambridge, 1908), pp. 65–85

    Google Scholar 

Download references

Author information

Authors and Affiliations


9.1 Appendix: Three Elegant Combinatorial Proofs

In this appendix we give three elegant combinatorial proofs that the number of spanning trees of the complete graph K p is p p − 2 (Example 9.11). The proofs are given in chronological order of their discovery.

First proof (Prüfer). Given a spanning tree T of K p , i.e., a tree on the vertex set [p], remove the largest endpoint (leaf) v and write down the vertex a 1 adjacent to v. Continue this procedure until only two vertices remain, obtaining a sequence \((a_{1},\ldots,a_{p-2}) \in {[p]}^{p-2}\), called the Prüfer sequence of T. For the tree below, we first remove 11 and then record 8. Next remove 10 and record 1. Then remove 8 and record 4, etc., ending with the sequence (8, 1, 4, 4, 1, 4, 9, 1, 9) and leaving the two vertices 1 and 9.

Second proof (Joyal). A doubly rooted tree is a tree T with one vertex u labelled S (for “start”) and one vertex v (which may equal u) labelled E (“end”). Let t(p) be the number of trees T on the vertex set [p], and let d(p) be the number of doubly rooted trees on [p]. Thus

$$\displaystyle{ d(p) = {p}^{2}t(p), }$$
since once we have chosen T there are p choices for u and p choices for v.

Let T be a doubly rooted tree. There is a unique path from S to E, say with vertices \(S = b_{1},b_{2},\ldots,b_{k} = E\) (in that order). The following diagram shows such a doubly rooted tree:

Third proof (Pitman). A forest is a graph without cycles; thus every connected component is a tree. A planted forest is a forest F for which every component T has a distinguished vertex r T (called the root of T). Thus if a component T has k vertices, then there are k ways to choose the root of T.

Let P p be the set of all planted forests on [p]. Let uv be an edge of a forest F ∈ P p such that u is closer than v to the root r of its component. Define F to cover the rooted forest F′ if F′ is obtained by removing the edge uv from F and rooting the new tree containing v at v. This definition of cover defines the covering relation of a partial order on P p . Under this partial order P p is graded of rank p − 1. The rank of a forest F in P p is its number of edges. The following diagram shows the poset P 3, with the root of each tree being its top vertex.

Our third proof isn’t an explicit bijection like the first two proofs. On the other hand, it has the virtue of not depending on the names of the vertices. Note that in the first two proofs it is necessary to know when one vertex is larger than another.

Notes for Chap. 9

The concept of tree as a formal mathematical object goes back to Kirchhoff and von Staudt. Trees were first extensively investigated by Cayley, to whom the term “tree” is due. In particular, in [20] Cayley states the formula \(\kappa (K_{p}) = {p}^{p-2}\) for the number of spanning trees of K p and he gives a vague idea of a combinatorial proof. Because of this paper, Cayley is often credited with the enumeration of labelled trees. Cayley pointed out, however, that an equivalent result had been proved earlier by Borchardt [10]. Moreover, this result appeared even earlier in a paper of Sylvester [111]. Undoubtedly Cayley and Sylvester could have furnished a complete, rigorous proof had they had the inclination to do so. The elegant combinatorial proofs given in the appendix are due to Prüfer [89], Joyal [61, Example 12, pp. 15–16], and Pitman [83].

The Matrix-Tree Theorem (Theorem 9.8) was first proved by Borchardt [10] in 1860, though a similar result had earlier been published by Sylvester [111] in 1857. Cayley [19, p. 279] in fact in 1856 referred to the not-yet-published work of Sylvester. For further historical information on the Matrix-Tree theorem, see Moon [77, p. 42].

Exercises for Chap. 9

  1. 1.

    (*) Let G p be the complete graph K p with one edge removed. How many spanning trees does G p have?

  2. 2.

    Let \(\boldsymbol{L} = \boldsymbol{L}(K_{rs})\) be the laplacian matrix of the complete bipartite graph K rs .

    1. (a)

      Find a simple upper bound on rank\((\boldsymbol{L} - rI)\). Deduce a lower bound on the number of eigenvalues of \(\boldsymbol{L}\) equal to r.

    2. (b)

      Assume rs and do the same as (a) for s instead of r.

    3. (c)

      (*) Find the remaining eigenvalues of \(\boldsymbol{L}\).

    4. (d)

      Use (a)–(c) to compute \(\kappa (K_{rs})\), the number of spanning trees of K rs .

    5. (e)

      Give a combinatorial proof of the formula for \(\kappa (K_{rs})\), by modifying either the proof of Prüfer or Joyal that \(\kappa (K_{p}) = {p}^{p-2}\).

  3. 3.

    Let p ≥ 5 and let G p be the graph on the vertex set \(\mathbb{Z}_{p}\) with edges {i, i + 1} and {i, i + 2}, for \(i \in \mathbb{Z}_{p}\). Thus G p has 2p edges. Show that \(\kappa (G_{p}) = pF_{p}^{2}\), where F p is a Fibonacci number (\(F_{1} = F_{2} = 1\), \(F_{p} = F_{p-1} + F_{p-2}\) for p ≥ 3).

  4. 4.

    Let \(\overline{C}_{n}\) be the edge complement of the cube graph C n , i.e., \(\overline{C}_{n}\) has vertex set {0, 1}n, with an edge uv if u and v differ in at least two coordinates. Find a formula for \(\kappa (\overline{C}_{n})\), the number of spanning trees of \(\overline{C}_{n}\). Your answer should be expressed as a simple product.

  5. 5.
    1. (a)

      (based on a suggestion of Venkataramana) Let G be a bipartite graph with vertex bipartition (A, B). Suppose that deg v = a for all v ∈ A and deg v = b for all v ∈ B. Let \(\boldsymbol{A}\) and \(\boldsymbol{L}\) denote the adjacency matrix and laplacian matrix of G, respectively. Show that if the eigenvalues of \(\boldsymbol{L}\) are \(\lambda _{1},\ldots,\lambda _{p}\), then the eigenvalues of \({\boldsymbol{A}}^{2}\) are \((\lambda _{1} - a)(\lambda _{1} - b),\ldots,(\lambda _{p} - a)(\lambda _{p} - b)\).

    2. (b)

      (*) Find the number of spanning trees of the graph \(\mathcal{C}_{n,k}\) of Exercise 2 in Chap. 2.

  6. 6.
    1. (a)

      (*) Let G be a finite loopless graph with p vertices. Suppose that the eigenvalues of the Laplacian matrix \(\boldsymbol{L}(G)\) are \(\theta _{1},\ldots,\theta _{p-1}\) and θ p  = 0. Let J be the p ×p matrix of all 1’s and let \(\alpha \in \mathbb{R}\). Show that the eigenvalues of \(\boldsymbol{L} +\alpha J\) are \(\theta _{1},\ldots,\theta _{p-1},\alpha p\).

    2. (b)

      Let GK p be the graph obtained from G by adding one new edge between every pair of distinct vertices. Express the number of spanning trees of GK p in terms of \(\theta _{1},\ldots,\theta _{p-1}\).

    3. (c)

      Suppose that G is simple and let \(\overline{G}\) be the complementary graph, i.e., G and \(\overline{G}\) have the same vertex set, and two distinct vertices are adjacent in G if and only if they are not adjacent in \(\overline{G}\). Express the number of spanning trees of \(\overline{G}\) in terms of \(\theta _{1},\ldots,\theta _{p-1}\).

    4. (d)

      (*) Let G be simple with p vertices and define the polynomial

      $$\displaystyle{P(G,x) =\sum _{F}{x}^{c(F)-1},}$$

      where F ranges over all spanning planted forests of G and where c(F) is the number of components of F. Show that

      $$\displaystyle{P(\overline{G},x) = {(-1)}^{p-1}P(G,-x - p).}$$
  7. 7.

    (*) Let V be the subset of \(\mathbb{Z} \times \mathbb{Z}\) on or inside some simple closed polygonal curve whose vertices belong to \(\mathbb{Z} \times \mathbb{Z}\), such that every line segment that makes up the curve is parallel to either the x-axis or y-axis. Draw an edge e between any two points of V at distance one apart, provided e lies on or inside the boundary curve. We obtain a planar graph G, an example being

    Let G′ be the dual graph G  ∗  with the “outside” vertex deleted. (The vertices of G′ are the interior regions of G. For each edge e of G, say with regions R and R′ on the two sides of e, there is an edge of G′ between R and R′. See Sect. 11.4 for more information on duals to planar graphs.) For the above example, G′ is given by

    Let \(\lambda _{1},\ldots,\lambda _{p}\) denote the eigenvalues of G′ (i.e., of the adjacency matrix \(\boldsymbol{A}(G^{\prime})\)). Show that

    $$\displaystyle{\kappa (G) =\prod _{ i=1}^{p}(4 -\lambda _{ i}).}$$
  8. 8.
    1. (a)

      Let \(\boldsymbol{L}\) be the laplacian matrix of a graph G on p vertices. We know (via Corollary 9.10) that the coefficient of x in the characteristic polynomial \(\det (\boldsymbol{L} - xI)\) is − (G). Show in fact that the coefficient of x j is equal to ( − 1)j times the number f j (G) of planted spanning forests (as defined in the third proof of the Appendix to this chapter) of G with j components.

    2. (b)

      Deduce from Theorem 5.12 that the sequence f 1(G), f 2(G), , f p (G) is strongly log-concave.

    3. (c)

      (extremely difficult) Let g k (G) denote the number of spanning forests (but not planted) of G with j components. Show that the sequence g 1(G), \(g_{2}(G),\ldots\), g p (G) is log-concave. (The graph K 3 shows that this sequence need not be strongly log-concave.)

  9. 9.

    Let G be a vertex-transitive graph with p vertices. (This means that for any two vertices u, v there is an automorphism \(\varphi\) of G satisfying \(\varphi (u) = v\).) Let \(\boldsymbol{A}\) denote the adjacency matrix of G. Show that for any integer n ≥ 1, \(\mathrm{tr}({\boldsymbol{A}}^{n})\) is divisible by p (where tr denotes trace).

  10. 10.
    1. (a)

      (moderately difficult) (*) Let G be a (finite) connected graph on a 2m-element vertex set V. For any graph with vertices u and v, let μ(u, v) denote the number of edges adjacent to both u and v. Suppose that there is an automorphism \(\varphi : V \rightarrow V\) of G all of whose cycles have length two. (In other words, \(\varphi\) is a fixed-point free involution.) Define the quotient graph \(G/\varphi\) as follows. The vertices of \(G/\varphi\) are the orbits of \(\varphi\). Thus \(G/\varphi\) has m vertices. Write [v] for the orbit containing vertex v, so \([v] =\{ v,\varphi (v)\}\). Set

      $$\displaystyle{\mu ([u],[v]) =\mu (u,v) +\mu (\varphi (u),v).}$$

      For instance, if G is a 4-cycle and \(\varphi\) takes each vertex to its antipode, then \(G/\varphi\) consists of a double edge. If G is a 6-cycle and \(\varphi\) takes each vertex to its antipode, then \(G/\varphi\) is a triangle. If G = K 4, then \(G/\varphi\) is a double edge (for any \(\varphi\)). If G = K 3, 3 then \(G/\varphi\) is a 3-cycle for any \(\varphi\). Show that 2κ(G) is divisible by \(\kappa (G/\varphi )\), where κ denotes the number of spanning trees.

    2. (b)

      (difficult) Show in fact that κ(G) is always divisible by \(\kappa (G/\varphi )\).

  11. 11.
    1. (a)

      (difficult) (*) Show that the number s(n, q) of invertible n ×n symmetric matrices over the field \(\mathbb{F}_{q}\) is given by

      $$\displaystyle{s(n,q) = \left \{\begin{array}{ll} {q}^{m(m-1)}(q - 1)({q}^{3} - 1)\cdots ({q}^{2m-1} - 1),&n = 2m - 1, \\ {q}^{m(m+1)}(q - 1)({q}^{3} - 1)\cdots ({q}^{2m-1} - 1),&n = 2m.\end{array} \right.}$$
    2. (b)

      Find a formula for the number f(p) of simple graphs on the vertex set [p] with an odd number of spanning trees.

  12. 12.

    (*) Let S be a k-element subset of [p]. Show that the number f S (p) of planted forests on the vertex set [p] with exactly k components, whose set of roots is S, is given by \(f_{S}(p) = k{n}^{n-k-1}\). Deduce that the total number f k (p) of planted forests on [p] with k components is given by

    $$\displaystyle{f_{k}(p) = k\left ({ p \atop k} \right ){p}^{p-k-1} = \left ({ p - 1 \atop k - 1} \right ){p}^{p-k}.}$$

Rights and permissions

Reprints and Permissions

Copyright information

© 2013 Springer Science+Business Media New York

About this chapter

Cite this chapter

Stanley, R.P. (2013). The Matrix-Tree Theorem. In: Algebraic Combinatorics. Undergraduate Texts in Mathematics. Springer, New York, NY.

Download citation