The areas / V30. Combinatorics
Mathlib.Combinatorics.SimpleGraph.LapMatrix
38 declarations. Mathlib docs · Source
Laplacian Matrix
This module defines the Laplacian matrix of a graph, and proves some of its elementary properties.
Main definitions & Results
SimpleGraph.degMatrix: The degree matrix of a simple graphSimpleGraph.lapMatrix: The Laplacian matrix of a simple graph, defined as the difference between the degree matrix and the adjacency matrix.posSemidef_lapMatrix: The Laplacian matrix is positive semidefinite.card_connectedComponent_eq_finrank_ker_toLin'_lapMatrix: The number of connected components in a graph is the dimension of the nullspace of its Laplacian matrix.
theorem SimpleGraph.degMatrix.congr_simp E1 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] (G G_1 : SimpleGraph V),
G = G_1 →
∀ {inst_1 : DecidableRel G.Adj} [inst_2 : DecidableRel G_1.Adj] {inst_3 : DecidableEq V} [inst_4 : DecidableEq V]
[inst_5 : AddMonoidWithOne R] (a a_1 : V),
a = a_1 → ∀ (a_2 a_3 : V), a_2 = a_3 → SimpleGraph.degMatrix R G a a_2 = SimpleGraph.degMatrix R G_1 a_1 a_3
theorem SimpleGraph.lapMatrix.congr_simp E1 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] (G G_1 : SimpleGraph V),
G = G_1 →
∀ {inst_1 : DecidableRel G.Adj} [inst_2 : DecidableRel G_1.Adj] {inst_3 : DecidableEq V} [inst_4 : DecidableEq V]
[inst_5 : AddGroupWithOne R] (a a_1 : V),
a = a_1 → ∀ (a_2 a_3 : V), a_2 = a_3 → SimpleGraph.lapMatrix R G a a_2 = SimpleGraph.lapMatrix R G_1 a_1 a_3
theorem Matrix.IsAdjMatrix.isHermitian E0 #
∀ {α : Type u_1} {V : Type u_2} [inst : NonAssocSemiring α] [inst_1 : StarRing α] {A : Matrix V V α},
A.IsAdjMatrix → A.IsHermitian
theorem SimpleGraph.isHermitian_adjMatrix E1 #
∀ {V : Type u_1} (R : Type u_2) (G : SimpleGraph V) [inst : DecidableRel G.Adj] [inst_1 : NonAssocSemiring R]
[inst_2 : StarRing R], (SimpleGraph.adjMatrix R G).IsHermitian
theorem SimpleGraph.IsRegularOfDegree.mem_spectrum_adjMatrix E0 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [Nonempty V] [Nontrivial R] [inst_5 : CommRing R] {d : ℕ},
G.IsRegularOfDegree d → ↑d ∈ spectrum R (SimpleGraph.adjMatrix R G)
theorem SimpleGraph.degree_eq_sum_if_adj E1 #
∀ {V : Type u_1} [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj] {R : Type u_3}
[inst_2 : AddCommMonoidWithOne R] (i : V), ↑(G.degree i) = ∑ j, if G.Adj i j then 1 else 0
def SimpleGraph.degMatrix E1 #
{V : Type u_1} →
(R : Type u_2) →
[Fintype V] → (G : SimpleGraph V) → [DecidableRel G.Adj] → [DecidableEq V] → [AddMonoidWithOne R] → Matrix V V R
The diagonal matrix consisting of the degrees of the vertices in the graph.
def SimpleGraph.lapMatrix E1 #
{V : Type u_1} →
(R : Type u_2) →
[Fintype V] → (G : SimpleGraph V) → [DecidableRel G.Adj] → [DecidableEq V] → [AddGroupWithOne R] → Matrix V V R
The Laplacian matrix lapMatrix G R of a graph G
is the matrix L = D - A where D is the degree and A the adjacency matrix of G.
theorem SimpleGraph.isSymm_degMatrix E1 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [inst_3 : AddMonoidWithOne R], (SimpleGraph.degMatrix R G).IsSymm
theorem SimpleGraph.isHermitian_degMatrix E1 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [inst_3 : NonAssocSemiring R] [inst_4 : StarRing R], (SimpleGraph.degMatrix R G).IsHermitian
theorem SimpleGraph.isSymm_lapMatrix E1 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [inst_3 : AddGroupWithOne R], (SimpleGraph.lapMatrix R G).IsSymm
theorem SimpleGraph.isHermitian_lapMatrix E1 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [inst_3 : NonAssocRing R] [inst_4 : StarRing R], (SimpleGraph.lapMatrix R G).IsHermitian
theorem SimpleGraph.degMatrix_mulVec_apply E0 #
∀ {V : Type u_1} {R : Type u_2} [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [inst_3 : NonAssocSemiring R] (v : V) (vec : V → R),
(SimpleGraph.degMatrix R G).mulVec vec v = ↑(G.degree v) * vec v
theorem SimpleGraph.IsRegularOfDegree.degMatrix_eq E0 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [inst_3 : AddMonoidWithOne R] {d : ℕ}, G.IsRegularOfDegree d → SimpleGraph.degMatrix R G = ↑d
theorem SimpleGraph.degMatrix_bot E0 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] [inst_1 : DecidableEq V] [inst_2 : AddMonoidWithOne R],
SimpleGraph.degMatrix R ⊥ = 0
theorem SimpleGraph.degMatrix_top E0 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] [inst_1 : DecidableEq V] [inst_2 : AddMonoidWithOne R],
SimpleGraph.degMatrix R ⊤ = ↑(Fintype.card V - 1)
theorem SimpleGraph.IsIsolated.not_isUnit_degMatrix E1 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [Nontrivial R] [inst_4 : CommRing R] {v : V},
G.IsIsolated v → ¬IsUnit (SimpleGraph.degMatrix R G)
theorem SimpleGraph.lapMatrix_mulVec_apply E0 #
∀ {V : Type u_1} {R : Type u_2} [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [inst_3 : NonAssocRing R] (v : V) (vec : V → R),
(SimpleGraph.lapMatrix R G).mulVec vec v = ↑(G.degree v) * vec v - ∑ u ∈ G.neighborFinset v, vec u
theorem SimpleGraph.lapMatrix_mulVec_apply' E1 #
∀ {V : Type u_1} {R : Type u_2} [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [inst_3 : NonAssocRing R] (v : V) (vec : V → R),
(SimpleGraph.lapMatrix R G).mulVec vec v = ∑ u ∈ G.neighborFinset v, (vec v - vec u)
theorem SimpleGraph.lapMatrix_mulVec_one_eq_zero E1 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [inst_3 : NonAssocRing R], (SimpleGraph.lapMatrix R G).mulVec 1 = 0
theorem SimpleGraph.det_lapMatrix_eq_zero E0 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [Nonempty V] [inst_4 : CommRing R], (SimpleGraph.lapMatrix R G).det = 0
theorem SimpleGraph.not_isUnit_lapMatrix E1 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [Nonempty V] [Nontrivial R] [inst_5 : CommRing R], ¬IsUnit (SimpleGraph.lapMatrix R G)
theorem SimpleGraph.zero_mem_spectrum_lapMatrix E1 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [Nonempty V] [Nontrivial R] [inst_5 : CommRing R], 0 ∈ spectrum R (SimpleGraph.lapMatrix R G)
0 is an eigenvalue of the Laplacian matrix of any graph.
theorem SimpleGraph.lapMatrix_bot E0 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] [inst_1 : DecidableEq V] [inst_2 : AddGroupWithOne R],
SimpleGraph.lapMatrix R ⊥ = 0
theorem SimpleGraph.lapMatrix_top E0 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] [inst_1 : DecidableEq V] [inst_2 : AddGroupWithOne R],
SimpleGraph.lapMatrix R ⊤ = ↑(Fintype.card V) - Matrix.of 1
theorem SimpleGraph.dotProduct_mulVec_degMatrix E1 #
∀ {V : Type u_1} {R : Type u_2} [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [inst_3 : CommSemiring R] (x : V → R),
x ⬝ᵥ (SimpleGraph.degMatrix R G).mulVec x = ∑ i, ↑(G.degree i) * x i * x i
theorem SimpleGraph.lapMatrix_toLinearMap₂' E1 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [inst_3 : Field R] [CharZero R] (x : V → R),
(((Matrix.toLinearMap₂' R) (SimpleGraph.lapMatrix R G)) x) x =
(∑ i, ∑ j, if G.Adj i j then (x i - x j) ^ 2 else 0) / 2
Let $L$ be the graph Laplacian and let $x \in \mathbb{R}$, then $$x^{\top} L x = \sum_{i \sim j} (x_{i}-x_{j})^{2}$$, where $\sim$ denotes the adjacency relation
theorem SimpleGraph.posSemidef_lapMatrix E1 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [inst_3 : Field R] [inst_4 : LinearOrder R] [IsStrictOrderedRing R] [inst_6 : StarRing R]
[TrivialStar R], (SimpleGraph.lapMatrix R G).PosSemidef
The Laplacian matrix is positive semidefinite
theorem SimpleGraph.lapMatrix_toLinearMap₂'_apply'_eq_zero_iff_forall_adj E1 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [inst_3 : Field R] [inst_4 : LinearOrder R] [IsStrictOrderedRing R] (x : V → R),
(((Matrix.toLinearMap₂' R) (SimpleGraph.lapMatrix R G)) x) x = 0 ↔ ∀ (i j : V), G.Adj i j → x i = x j
theorem SimpleGraph.lapMatrix_mulVec_eq_zero_iff_forall_adj E1 #
∀ {V : Type u_1} [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj] [inst_2 : DecidableEq V]
{x : V → ℝ}, (SimpleGraph.lapMatrix ℝ G).mulVec x = 0 ↔ ∀ (i j : V), G.Adj i j → x i = x j
theorem SimpleGraph.lapMatrix_toLinearMap₂'_apply'_eq_zero_iff_forall_reachable E1 #
∀ {V : Type u_1} (R : Type u_2) [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj]
[inst_2 : DecidableEq V] [inst_3 : Field R] [inst_4 : LinearOrder R] [IsStrictOrderedRing R] (x : V → R),
(((Matrix.toLinearMap₂' R) (SimpleGraph.lapMatrix R G)) x) x = 0 ↔ ∀ (i j : V), G.Reachable i j → x i = x j
theorem SimpleGraph.lapMatrix_mulVec_eq_zero_iff_forall_reachable E1 #
∀ {V : Type u_1} [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj] [inst_2 : DecidableEq V]
{x : V → ℝ}, (SimpleGraph.lapMatrix ℝ G).mulVec x = 0 ↔ ∀ (i j : V), G.Reachable i j → x i = x j
theorem SimpleGraph.mem_ker_toLin'_lapMatrix_of_connectedComponent E0 #
∀ {V : Type u_1} [inst : Fintype V] [inst_1 : DecidableEq V] {G : SimpleGraph V} [inst_2 : DecidableRel G.Adj]
[inst_3 : DecidableEq G.ConnectedComponent] (c : G.ConnectedComponent),
(fun i ↦ if G.connectedComponentMk i = c then 1 else 0) ∈ (Matrix.toLin' (SimpleGraph.lapMatrix ℝ G)).ker
def SimpleGraph.lapMatrix_ker_basis_aux E0 #
{V : Type u_1} →
[inst : Fintype V] →
(G : SimpleGraph V) →
[inst_1 : DecidableRel G.Adj] →
[inst_2 : DecidableEq V] →
[DecidableEq G.ConnectedComponent] → G.ConnectedComponent → ↥(Matrix.toLin' (SimpleGraph.lapMatrix ℝ G)).ker
Given a connected component c of a graph G, lapMatrix_ker_basis_aux c is the map
V → ℝ which is 1 on the vertices in c and 0 elsewhere.
The family of these maps indexed by the connected components of G proves to be a basis
of the kernel of lapMatrix G R
theorem SimpleGraph.linearIndependent_lapMatrix_ker_basis_aux E0 #
∀ {V : Type u_1} [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj] [inst_2 : DecidableEq V]
[inst_3 : DecidableEq G.ConnectedComponent], LinearIndependent ℝ G.lapMatrix_ker_basis_aux
theorem SimpleGraph.top_le_span_range_lapMatrix_ker_basis_aux E0 #
∀ {V : Type u_1} [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj] [inst_2 : DecidableEq V]
[inst_3 : DecidableEq G.ConnectedComponent], ⊤ ≤ Submodule.span ℝ (Set.range G.lapMatrix_ker_basis_aux)
def SimpleGraph.lapMatrix_ker_basis E1 #
{V : Type u_1} →
[inst : Fintype V] →
(G : SimpleGraph V) →
[inst_1 : DecidableRel G.Adj] →
[inst_2 : DecidableEq V] →
[DecidableEq G.ConnectedComponent] →
Module.Basis G.ConnectedComponent ℝ ↥(Matrix.toLin' (SimpleGraph.lapMatrix ℝ G)).ker
lapMatrix_ker_basis G is a basis of the nullspace indexed by its connected components,
the basis is made up of the functions V → ℝ which are 1 on the vertices of the given
connected component and 0 elsewhere.
theorem SimpleGraph.card_connectedComponent_eq_finrank_ker_toLin'_lapMatrix E1 #
∀ {V : Type u_1} [inst : Fintype V] (G : SimpleGraph V) [inst_1 : DecidableRel G.Adj] [inst_2 : DecidableEq V],
Fintype.card G.ConnectedComponent = Module.finrank ℝ ↥(Matrix.toLin' (SimpleGraph.lapMatrix ℝ G)).ker
The number of connected components in G is the dimension of the nullspace of its Laplacian.