Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Kirchoff's Theorem
Kirchhoff's theorem (also known as the Matrix Tree Theorem) provides a way to find the number of spanning trees in a connected graph using matrices. Instead of manually listing all spanning trees, this theorem lets you compute the count using the determinant of a special matrix derived from the graph.
How Kirchhoff's Theorem Works
The process involves three steps −
- Create the Adjacency Matrix (A) − Fill entry A[i][j] as 1 if there is an edge between vertex i and vertex j, else 0.
- Create the Degree Matrix (D) − A diagonal matrix where D[i][i] equals the degree of vertex i, and all other entries are 0.
- Compute the Laplacian Matrix (L) − L = D − A. Then delete any one row and the corresponding column to form a cofactor matrix. The determinant of this cofactor matrix gives the number of spanning trees.
Example
Consider the following connected graph with 4 vertices ?
Step 1: Adjacency Matrix (A)
The matrix A is filled as 1 if there is an edge between two vertices, else 0 −
a b c d
a [ 0 1 1 1 ]
b [ 1 0 1 0 ]
c [ 1 1 0 1 ]
d [ 1 0 1 0 ]
Step 2: Degree Matrix (D)
The diagonal entries are the degree of each vertex −
a b c d
a [ 3 0 0 0 ]
b [ 0 2 0 0 ]
c [ 0 0 3 0 ]
d [ 0 0 0 2 ]
Step 3: Laplacian Matrix (L = D − A)
a b c d
a [ 3 -1 -1 -1 ]
b [ -1 2 -1 0 ]
c [ -1 -1 3 -1 ]
d [ -1 0 -1 2 ]
Step 4: Cofactor and Determinant
Delete the first row and first column (row a and column a) to get the cofactor matrix −
b c d
b [ 2 -1 0 ]
c [ -1 3 -1 ]
d [ 0 -1 2 ]
Determinant = 2(3×2 - (-1)×(-1)) - (-1)((-1)×2 - (-1)×0) + 0
= 2(6 - 1) - (-1)(-2 - 0) + 0
= 2(5) - (-1)(-2)
= 10 - 2
= 8
The number of spanning trees in this graph is 8.
Conclusion
Kirchhoff's theorem computes the number of spanning trees by finding the determinant of any cofactor of the Laplacian matrix (L = D − A). This method works for any connected graph and avoids the need to enumerate spanning trees manually.
