In the mathematical field of graph theory, Kirchhoff's theorem or Kirchhoff's matrix tree theorem is a theorem about the number of spanning trees in a graph. It states that this number can be computed as any cofactor of the graph's Laplacian matrix. This shows in particular that the number of spanning trees can be computed from the graph data in polynomial time. Kirchhoff's theorem is a generalization of Cayley's formula which provides the number of spanning trees in a complete graph. The theorem is named after the German mathematician Gustav Kirchhoff, who published it in 1847. An English translation of Kirchhoff's paper was published in 1958.
Definitions and statement Let G be a simple, undirected graph. A spanning tree of G is a subgraph of G that is a tree with the same vertex set as G. The Laplacian matrix L of G is the difference between the graph's degree matrix (the diagonal matrix of vertex degrees) and its adjacency matrix (a (0,1)-matrix with 1's at places corresponding to entries where the vertices are adjacent and 0's otherwise). A cofactor of L is obtained by deleting a row (say the i-the row) and a column (say the j-th column) of L, taking the determinant of that smaller matrix, and multiplying it with (-1)i+j. Kirchhoff's theorem states that the number of spanning trees of the graph is equal to any cofactor of the graph's Laplacian matrix. (In particular, all these cofactors are equal.)
Example
First, construct the Laplacian matrix L for the example diamond graph G (see image on the right):
L = [ 2 − 1 − 1 0 − 1 3 − 1 − 1 − 1 − 1 3 − 1 0 − 1 − 1 2 ] . {\displaystyle L=\left[{\begin{array}{rrrr}2&-1&-1&0\\-1&3&-1&-1\\-1&-1&3&-1\\0&-1&-1&2\end{array}}\right].}
Next, construct a matrix Q* by deleting any row and any column from Q. For example, deleting row 1 and column 1 yields
L ∗ = [ 3 − 1 − 1 − 1 3 − 1 − 1 − 1 2 ] . {\displaystyle L^{\ast }=\left[{\begin{array}{rrr}3&-1&-1\\-1&3&-1\\-1&-1&2\end{array}}\right].}
Finally, take the determinant of L*, which results in 8. The number of spanning trees of G, shown on the right, is also 8.
Proof outline (The proof below is based on the Cauchy–Binet formula. An elementary induction argument for Kirchhoff's theorem can be found on page 654 of Moore (2011).) First notice that the Laplacian matrix has the property that the sum of its entries across any row and any column is 0. Thus we can transform any minor into any other minor by adding rows and columns, switching them, and multiplying a row or a column by −1. Thus the cofactors are the same up to sign, and it can be verified that, in fact, they have the same sign. We proceed to show that the determinant of the minor M11 is the number of spanning trees. Let n be the number of vertices of the graph, and m the number of its edges. The incidence matrix E is an n-by-m matrix, which may be defined as follows: suppose that (i, j) is the kth edge of the graph, and that i < j. Then Eik = 1, Ejk = −1, and all other entries in column k are 0 (see oriented incidence matrix for understanding this modified incidence matrix E). For the preceding example (with n = 4 and m = 5):
… excerpt ends here. Continue reading the full article.

