mathlibdocumentation

This module defines the adjacency matrix of a graph, and provides theorems connecting graph properties to computational properties of the matrix.

Main definitions #

structure matrix.is_adj_matrix {V : Type u_1} {α : Type u_2} [has_zero α] [has_one α] (A : V α) :
Prop
• zero_or_one : (∀ (i j : V), A i j = 0 A i j = 1) . "obviously"
• symm : A.is_symm . "obviously"
• apply_diag : (∀ (i : V), A i i = 0) . "obviously"

A : matrix V V α is qualified as an "adjacency matrix" if (1) every entry of A is 0 or 1, (2) A is symmetric, (3) every diagonal entry of A is 0.

@[simp]
theorem matrix.is_adj_matrix.apply_diag_ne {V : Type u_1} {α : Type u_2} {A : V α} [nontrivial α] (h : A.is_adj_matrix) (i : V) :
¬A i i = 1
@[simp]
theorem matrix.is_adj_matrix.apply_ne_one_iff {V : Type u_1} {α : Type u_2} {A : V α} [nontrivial α] (h : A.is_adj_matrix) (i j : V) :
¬A i j = 1 A i j = 0
@[simp]
theorem matrix.is_adj_matrix.apply_ne_zero_iff {V : Type u_1} {α : Type u_2} {A : V α} [nontrivial α] (h : A.is_adj_matrix) (i j : V) :
¬A i j = 0 A i j = 1
@[simp]
theorem matrix.is_adj_matrix.to_graph_adj {V : Type u_1} {α : Type u_2} {A : V α} [nontrivial α] (h : A.is_adj_matrix) (i j : V) :
h.to_graph.adj i j = (A i j = 1)
def matrix.is_adj_matrix.to_graph {V : Type u_1} {α : Type u_2} {A : V α} [nontrivial α] (h : A.is_adj_matrix) :

For A : matrix V V α and h : is_adj_matrix A, h.to_graph is the simple graph whose adjacency matrix is A.

Equations
@[protected, instance]
def matrix.is_adj_matrix.adj.decidable_rel {V : Type u_1} {α : Type u_2} {A : V α} [nontrivial α] [decidable_eq α] (h : A.is_adj_matrix) :
Equations
• = _.mpr (λ (a b : V), _inst_3 (A a b) 1)
def matrix.compl {V : Type u_1} {α : Type u_2} [has_zero α] [has_one α] [decidable_eq α] [decidable_eq V] (A : V α) :
V α

For A : matrix V V α, A.compl is supposed to be the adjacency matrix of the complement graph of the graph induced by A.adj_matrix.

Equations
@[simp]
theorem matrix.compl_apply_diag {V : Type u_1} {α : Type u_2} [decidable_eq α] [decidable_eq V] (A : V α) [has_zero α] [has_one α] (i : V) :
A.compl i i = 0
@[simp]
theorem matrix.compl_apply {V : Type u_1} {α : Type u_2} [decidable_eq α] [decidable_eq V] (A : V α) [has_zero α] [has_one α] (i j : V) :
A.compl i j = 0 A.compl i j = 1
@[simp]
theorem matrix.is_symm_compl {V : Type u_1} {α : Type u_2} [decidable_eq α] [decidable_eq V] (A : V α) [has_zero α] [has_one α] (h : A.is_symm) :
@[simp]
theorem matrix.is_adj_matrix_compl {V : Type u_1} {α : Type u_2} [decidable_eq α] [decidable_eq V] (A : V α) [has_zero α] [has_one α] (h : A.is_symm) :
@[simp]
theorem matrix.is_adj_matrix.compl {V : Type u_1} {α : Type u_2} [decidable_eq α] [decidable_eq V] {A : V α} [has_zero α] [has_one α] (h : A.is_adj_matrix) :
theorem matrix.is_adj_matrix.to_graph_compl_eq {V : Type u_1} {α : Type u_2} [decidable_eq α] [decidable_eq V] {A : V α} [nontrivial α] (h : A.is_adj_matrix) :
def simple_graph.adj_matrix {V : Type u_1} (α : Type u_2) (G : simple_graph V) [decidable_rel G.adj] [has_zero α] [has_one α] :
V α

adj_matrix G α is the matrix A such that A i j = (1 : α) if i and j are adjacent in the simple graph G, and otherwise A i j = 0.

Equations
@[simp]
theorem simple_graph.adj_matrix_apply {V : Type u_1} {α : Type u_2} (G : simple_graph V) [decidable_rel G.adj] (v w : V) [has_zero α] [has_one α] :
w = ite (G.adj v w) 1 0
@[simp]
theorem simple_graph.transpose_adj_matrix {V : Type u_1} {α : Type u_2} (G : simple_graph V) [decidable_rel G.adj] [has_zero α] [has_one α] :
@[simp]
theorem simple_graph.is_symm_adj_matrix {V : Type u_1} {α : Type u_2} (G : simple_graph V) [decidable_rel G.adj] [has_zero α] [has_one α] :
@[simp]
theorem simple_graph.is_adj_matrix_adj_matrix {V : Type u_1} (α : Type u_2) (G : simple_graph V) [decidable_rel G.adj] [has_zero α] [has_one α] :

theorem simple_graph.to_graph_adj_matrix_eq {V : Type u_1} (α : Type u_2) (G : simple_graph V) [decidable_rel G.adj] [nontrivial α] :

The graph induced by the adjacency matrix of G is G itself.

@[simp]
theorem simple_graph.adj_matrix_dot_product {V : Type u_1} {α : Type u_2} (G : simple_graph V) [decidable_rel G.adj] [fintype V] (v : V) (vec : V → α) :
⬝ᵥ vec = ∑ (u : V) in , vec u
@[simp]
theorem simple_graph.dot_product_adj_matrix {V : Type u_1} {α : Type u_2} (G : simple_graph V) [decidable_rel G.adj] [fintype V] (v : V) (vec : V → α) :
vec ⬝ᵥ = ∑ (u : V) in , vec u
@[simp]
theorem simple_graph.adj_matrix_mul_vec_apply {V : Type u_1} {α : Type u_2} (G : simple_graph V) [decidable_rel G.adj] [fintype V] (v : V) (vec : V → α) :
vec v = ∑ (u : V) in , vec u
@[simp]
theorem simple_graph.adj_matrix_vec_mul_apply {V : Type u_1} {α : Type u_2} (G : simple_graph V) [decidable_rel G.adj] [fintype V] (v : V) (vec : V → α) :
v = ∑ (u : V) in , vec u
@[simp]
theorem simple_graph.adj_matrix_mul_apply {V : Type u_1} {α : Type u_2} (G : simple_graph V) [decidable_rel G.adj] [fintype V] (M : V α) (v w : V) :
M) v w = ∑ (u : V) in , M u w
@[simp]
theorem simple_graph.mul_adj_matrix_apply {V : Type u_1} {α : Type u_2} (G : simple_graph V) [decidable_rel G.adj] [fintype V] (M : V α) (v w : V) :
(M v w = ∑ (u : V) in , M v u
theorem simple_graph.trace_adj_matrix {V : Type u_1} (α : Type u_2) {β : Type u_3} (G : simple_graph V) [decidable_rel G.adj] [fintype V] [semiring β] [ α] :
β α) = 0
theorem simple_graph.adj_matrix_mul_self_apply_self {V : Type u_1} {α : Type u_2} (G : simple_graph V) [decidable_rel G.adj] [fintype V] (i : V) :
i i = (G.degree i)
@[simp]
theorem simple_graph.adj_matrix_mul_vec_const_apply {V : Type u_1} {α : Type u_2} {G : simple_graph V} [decidable_rel G.adj] [fintype V] [semiring α] {a : α} {v : V} :
a) v = ((G.degree v)) * a
theorem simple_graph.adj_matrix_mul_vec_const_apply_of_regular {V : Type u_1} {α : Type u_2} {G : simple_graph V} [decidable_rel G.adj] [fintype V] [semiring α] {d : } {a : α} (hd : G.is_regular_of_degree d) {v : V} :
a) v = (d) * a
theorem matrix.is_adj_matrix.adj_matrix_to_graph_eq {V : Type u_1} {α : Type u_2} [nontrivial α] {A : V α} (h : A.is_adj_matrix) [decidable_eq α] :

If A is qualified as an adjacency matrix, then the adjacency matrix of the graph induced by A is itself.