mathlib documentation

combinatorics.simple_graph.adj_matrix

Adjacency Matrices #

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 : matrix V 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 : matrix V V α} [mul_zero_one_class α] [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 : matrix V V α} [mul_zero_one_class α] [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 : matrix V V α} [mul_zero_one_class α] [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 : matrix V V α} [mul_zero_one_class α] [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 : matrix V V α} [mul_zero_one_class α] [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
@[instance]
def matrix.is_adj_matrix.adj.decidable_rel {V : Type u_1} {α : Type u_2} {A : matrix V V α} [mul_zero_one_class α] [nontrivial α] [decidable_eq α] (h : A.is_adj_matrix) :
Equations
def matrix.compl {V : Type u_1} {α : Type u_2} [has_zero α] [has_one α] [decidable_eq α] [decidable_eq V] (A : matrix V V α) :
matrix 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 : matrix V 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 : matrix V 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 : matrix V 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 : matrix V 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 : matrix V 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 : matrix V V α} [mul_zero_one_class α] [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 α] :
matrix V 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 α] :
simple_graph.adj_matrix α G v 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 α] :

The adjacency matrix of G is an adjacency matrix.

theorem simple_graph.to_graph_adj_matrix_eq {V : Type u_1} (α : Type u_2) (G : simple_graph V) [decidable_rel G.adj] [mul_zero_one_class α] [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] [non_assoc_semiring α] (v : V) (vec : V → α) :
matrix.dot_product (simple_graph.adj_matrix α G v) vec = ∑ (u : V) in G.neighbor_finset v, 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] [non_assoc_semiring α] (v : V) (vec : V → α) :
matrix.dot_product vec (simple_graph.adj_matrix α G v) = ∑ (u : V) in G.neighbor_finset v, 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] [non_assoc_semiring α] (v : V) (vec : V → α) :
(simple_graph.adj_matrix α G).mul_vec vec v = ∑ (u : V) in G.neighbor_finset v, 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] [non_assoc_semiring α] (v : V) (vec : V → α) :
matrix.vec_mul vec (simple_graph.adj_matrix α G) v = ∑ (u : V) in G.neighbor_finset v, 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] [non_assoc_semiring α] (M : matrix V V α) (v w : V) :
(simple_graph.adj_matrix α G M) v w = ∑ (u : V) in G.neighbor_finset v, 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] [non_assoc_semiring α] (M : matrix V V α) (v w : V) :
(M simple_graph.adj_matrix α G) v w = ∑ (u : V) in G.neighbor_finset w, 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] [non_assoc_semiring α] [semiring β] [module β α] :
@[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} :
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} :
theorem matrix.is_adj_matrix.adj_matrix_to_graph_eq {V : Type u_1} {α : Type u_2} [mul_zero_one_class α] [nontrivial α] {A : matrix V 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.