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 ofA
is0
or1
, (2)A
is symmetric, (3) every diagonal entry ofA
is0
.Matrix.IsAdjMatrix.to_graph
: forA : Matrix V V α
andh : A.IsAdjMatrix
,h.to_graph
is the simple graph induced byA
.Matrix.compl
: forA : Matrix V V α
,A.compl
is 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 then
th power of a graph's adjacency matrix counts the number of length-n
walks 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 : A.IsSymm
- 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
.
Instances For
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
.
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, the adjacency matrix, and its complement 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.