Documentation

CslibFrontier.Foundations.Combinatorics.Digraph.MatrixTree

The directed matrix-tree theorem #

Let A : Matrix V V R be a matrix over a commutative ring, read as the arc weights of a complete weighted digraph on a finite vertex type V, and let r : V. The reduced Laplacian is the submatrix of the out-degree Laplacian Matrix.laplacian A = diagonal (fun u => ∑ v, A u v) - A on the rows and columns of the vertices other than r. Its determinant is the sum, over the spanning in-arborescences T rooted at r, of the product of the weights A v w of the arcs v → w of T (Digraph.det_laplacian_submatrix_eq_finsum_isInArborescence). This is Tutte's directed matrix-tree theorem [Tut48]. A spanning in-arborescence rooted at r is a digraph on all of V in which r has no outgoing arc, every other vertex has exactly one outgoing arc, and every vertex reaches r along arcs (Digraph.IsInArborescence, defined with its parent-function description in CslibFrontier.Foundations.Combinatorics.Digraph.Arborescence). Its arcs point towards the root.

For a digraph G with adjacency matrix Digraph.adjMatrix R G, the reduced Laplacian is the out-degree matrix minus the adjacency matrix with the row and column of r deleted, and its determinant is the number of spanning in-arborescences T ≤ G rooted at r (Digraph.det_laplacian_adjMatrix_submatrix_eq_natCard_isInArborescence). Out-arborescences, whose arcs point away from the root, are counted by applying these results to the transposed weight matrix Aᵀ, which reverses every arc. The diagonal of A (loops) never contributes.

The proof expands the determinant multilinearly along its rows. Row v of the reduced Laplacian is ∑ u, A v u • (e_v - e_u), where e_r is read as 0. The determinant is therefore the sum, over the parent functions f assigning to each vertex v ≠ r a vertex f v, of ∏ v, A v (f v) times the determinant of the matrix with rows e_v - e_{f v}. That determinant is 1 when iterating f from every vertex reaches r: ordered by the number of steps to r, the matrix is triangular with unit diagonal. Otherwise f has a cycle avoiding r, and the indicator vector of the vertices that never reach r lies in its kernel, so it is 0. The parent functions that reach r correspond to the in-arborescences rooted at r, by T.Adj v w ↔ w = f v.

Main definitions #

Main results #

References #

def Digraph.adjMatrix {V : Type u_1} (R : Type u_2) [Zero R] [One R] (G : Digraph V) [DecidableRel G.Adj] :
Matrix V V R

The adjacency matrix of a digraph: the entry (v, w) is 1 if v → w is an arc and 0 otherwise.

@[simp]
theorem Digraph.adjMatrix_apply {V : Type u_1} {R : Type u_2} [Zero R] [One R] (G : Digraph V) [DecidableRel G.Adj] (v w : V) :
adjMatrix R G v w = if G.Adj v w then 1 else 0

The entries of the adjacency matrix.

Parent functions #

The determinant expansion #

theorem Digraph.det_laplacian_submatrix_eq_finsum_isInArborescence {V : Type u_1} [Fintype V] [DecidableEq V] {R : Type u_2} [CommRing R] (A : Matrix V V R) (r : V) :
(A.laplacian.submatrix Subtype.val Subtype.val).det = ∑ᶠ (T : Digraph V) (_ : T.IsInArborescence r), ∏ᶠ (p : V × V) (_ : T.Adj p.1 p.2), A p.1 p.2

The directed matrix-tree theorem [Tut48]. For a matrix A of arc weights over a commutative ring and a vertex r, the determinant of the reduced Laplacian, the submatrix of Matrix.laplacian A on the vertices other than r, is the sum, over the spanning in-arborescences T rooted at r (arcs directed towards r), of the product of the weights A v w of the arcs v → w of T. The Laplacian is the out-degree one, diagonal (fun v => ∑ w, A v w) - A. Applied to Aᵀ, the same statement sums over the out-arborescences of A rooted at r.

theorem Digraph.det_laplacian_submatrix_eq_finsum_reachable {V : Type u_1} [Fintype V] [DecidableEq V] {R : Type u_2} [CommRing R] (A : Matrix V V R) (r : V) :
(A.laplacian.submatrix Subtype.val Subtype.val).det = ∑ᶠ (f : { v : V // v ≠ r } → V) (_ : ∀ (v : V), Relation.ReflTransGen (fun (v w : V) => ∃ (h : v ≠ r), f ⟨v, h⟩ = w) v r), ∏ i : { v : V // v ≠ r }, A (↑i) (f i)

The directed matrix-tree theorem, parent-function form. The determinant of the reduced Laplacian is the sum, over the parent functions f assigning to each vertex v ≠ r a vertex f v such that following f leads from every vertex to r, of ∏ v, A v (f v).

The directed matrix-tree theorem, counting form [Tut48]. For a finite digraph G and a vertex r, the determinant of the reduced Laplacian of G, the out-degree matrix minus the adjacency matrix with the row and column of r deleted, is the number of spanning in-arborescences T ≤ G rooted at r (arcs directed towards r). Loops of G do not contribute.

theorem Digraph.finsum_isInArborescence_eq_of_balanced {V : Type u_1} [Fintype V] {R : Type u_2} [CommRing R] (A : Matrix V V R) (hbal : ∀ (v : V), ∑ w : V, A v w = ∑ u : V, A u v) (u v : V) :
∑ᶠ (T : Digraph V) (_ : T.IsInArborescence u), ∏ᶠ (p : V × V) (_ : T.Adj p.1 p.2), A p.1 p.2 = ∑ᶠ (T : Digraph V) (_ : T.IsInArborescence v), ∏ᶠ (p : V × V) (_ : T.Adj p.1 p.2), A p.1 p.2

For a balanced weight matrix (∑ w, A v w = ∑ u, A u v), the weighted sum of spanning in-arborescences rooted at u equals that rooted at v.

theorem Digraph.natCard_isInArborescence_eq_of_balanced {V : Type u_1} [Fintype V] (G : Digraph V) [DecidableRel G.Adj] (hbal : ∀ (v : V), {w : V | G.Adj v w}.card = {u : V | G.Adj u v}.card) (u v : V) :

For a finite balanced digraph (∀ v, outdeg v = indeg v), the number of spanning in-arborescences rooted at u equals that rooted at v ([Sta13], Corollary 10.3 for simple digraphs, without assuming connectivity).