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 #
-
Matrix.IsAdjMatrix:A : Matrix V V αis qualified as an "adjacency matrix" if (1) every entry ofAis0or1, (2)Ais symmetric, (3) every diagonal entry ofAis0. -
Matrix.IsAdjMatrix.to_graph: forA : Matrix V V αandh : A.IsAdjMatrix,h.to_graphis the simple graph induced byA. -
Matrix.compl: forA : Matrix V V α,A.complis supposed to be the adjacency matrix of the complement graph of the graph induced byA. -
SimpleGraph.adjMatrix: the adjacency matrix of aSimpleGraph. -
SimpleGraph.adjMatrix_pow_apply_eq_card_walk: each entry of thenth power of a graph's adjacency matrix counts the number of length-nwalks between the corresponding pair of vertices.
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.
- symm : Matrix.IsSymm A
- apply_diag : ∀ (i : V), A i i = 0
Instances For
For A : Matrix V V α and h : IsAdjMatrix A,
h.toGraph is the simple graph whose adjacency matrix is A.
Equations
- Matrix.IsAdjMatrix.toGraph h = { Adj := fun (i j : V) => A i j = 1, symm := ⋯, loopless := ⋯ }
Instances For
Equations
- Matrix.IsAdjMatrix.instDecidableRelAdjToGraph h = id inferInstance
For A : Matrix V V α, A.compl is supposed to be the adjacency matrix of
the complement graph of the graph induced by A.adjMatrix.
Equations
- Matrix.compl A i j = if i = j then 0 else if A i j = 0 then 1 else 0
Instances For
adjMatrix 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
- SimpleGraph.adjMatrix α G = Matrix.of fun (i j : V) => if G.Adj i j then 1 else 0
Instances For
The adjacency matrix of G is an adjacency matrix.
The graph induced by the adjacency matrix of G is G itself.
The sum of the identity, G.adjMatrix ℕ and (G.adjMatrix ℕ).compl is the all-ones matrix.
If A is qualified as an adjacency matrix,
then the adjacency matrix of the graph induced by A is itself.