# Kirchhoff's theorem

In the mathematical field of graph theory **Kirchhoff's theorem** or **Kirchhoff's matrix tree theorem** named after Gustav Kirchhoff is a theorem about the number of spanning trees in a graph, showing that this number can be computed in polynomial time as the determinant of a matrix derived from the graph. It is a generalization of Cayley's formula which provides the number of spanning trees in a complete graph.

Kirchhoff's theorem relies on the notion of the Laplacian matrix of a graph that is equal to the difference between the graph's degree matrix (a diagonal matrix with vertex degrees on the diagonals) 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).

For a given connected graph *G* with *n* labeled vertices, let *λ*_{1}, *λ*_{2}, ..., *λ _{n}*

_{−1}be the non-zero eigenvalues of its Laplacian matrix. Then the number of spanning trees of

*G*is

Equivalently the number of spanning trees is equal to *any* cofactor of the Laplacian matrix of *G*.

## An example using the matrix-tree theorem

First, construct the Laplacian matrix *Q* for the example kite graph *G* (see image at right):

Next, construct a matrix *Q ^{*}* by deleting any row and any column from

*Q*. For example, deleting row 1 and column 1 yields

Finally, take the determinant of *Q ^{*}* to obtain

*t(G)*, which is 8 for the kite graph. (Notice

*t(G)*is the

*(1,1)*-cofactor of

*Q*in this example.)

## Proof outline

First notice that the Laplacian 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 *M _{11}* counts 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 is an

*n*-by-

*m*matrix, which may be defined as follows: suppose that (

*i*,

*j*) is the

*k*th edge of the graph, and that

*i*<

*j*. Then

*E*=

_{ik}*1*,

*E*, and all other entries in column

_{jk}= −1*k*are 0 (see oriented Incidence matrix for understanding this modified incidence matrix E). For the preceding example (with

*n*= 4 and

*m*= 5):

Recall that the Laplacian *L* can be factored into the product of the incidence matrix and its transpose, i.e., *L* = *EE*^{T}. Furthermore, let *F* be the matrix *E* with its first row deleted, so that *FF*^{T} = *M _{11}*.

Now the Cauchy-Binet formula allows us to write

where *S* ranges across subsets of [*m*] of size *n* − 1, and *F _{S}* denotes the (

*n*− 1)-by-(

*n*− 1) matrix whose columns are those of

*F*with index in

*S*. Then every

*S*specifies

*n*− 1 edges of the original graph, and it can be shown that those edges induce a spanning tree iff the determinant of

*F*is +1 or −1, and that they do not induce a spanning tree iff the determinant is 0. This completes the proof.

_{S}## Particular cases and generalizations

### Cayley's formula

{{#invoke:main|main}}
Cayley's formula follows from Kirchhoff's theorem as a special case, since every vector with 1 in one place, −1 in another place, and 0 elsewhere is an eigenvector of the Laplacian matrix of the complete graph, with the corresponding eigenvalue being *n*. These vectors together span a space of dimension *n* − 1, so there are no other non-zero eigenvalues.

Alternatively, note that as Cayley's formula counts the number of distinct labeled trees of a complete graph *K _{n}* we need to compute any cofactor of the Laplacian matrix of

*K*. The Laplacian matrix in this case is

_{n}Any cofactor of the above matrix is *n ^{n}*

^{−2}, which is Cayley's formula.

### Kirchhoff's theorem for multigraphs

Kirchhoff's theorem holds for multigraphs as well; the matrix *Q* is modified as follows:

- if vertex
*i*is adjacent to vertex*j*in*G*,*q*equals −_{i,j}*m*, where*m*is the number of edges between*i*and*j*; - when counting the degree of a vertex, all loops are excluded.

### Explicit enumeration of spanning trees

Kirchhoff's theorem can be strengthened by altering the definition of the Laplacian matrix. Rather than merely counting edges emanating from each vertex or connecting a pair of vertices, label each edge with an indeterminant and let the (*i*, *j*)-th entry of the modified Laplacian matrix be the sum over the indeterminants corresponding to edges between the *i*-th and *j*-th vertices when *i* does not equal *j*, and the negative sum over all indeterminants corresponding to edges emanating from the *i*-th vertex when *i* equals *j*.

The determinant above is then a homogeneous polynomial (the Kirchhoff polynomial) in the indeterminants corresponding to the edges of the graph. After collecting terms and performing all possible cancellations, each monomial in the resulting expression represents a spanning tree consisting of the edges corresponding to the indeterminants appearing in that monomial. In this way, one can obtain explicit enumeration of all the spanning trees of the graph simply by computing the determinant.

### Matroids

The spanning trees of a graph form the bases of a graphic matroid, so Kirchhoff's theorem provides a formula to count the number of bases in a graphic matroid. The same method may also be used to count the number of bases in regular matroids, a generalization of the graphic matroids Template:Harv.

## See also

## References

- {{#invoke:citation/CS1|citation

|CitationClass=citation }}.

- {{#invoke:citation/CS1|citation

|CitationClass=citation }}.

- {{#invoke:citation/CS1|citation

|CitationClass=citation }}.