Documentation

Mathlib.Combinatorics.SimpleGraph.AdjMatrix

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.IsAdjMatrix {V : Type u_1} {α : Type u_2} [Zero α] [One α] (A : Matrix V V α) :

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.

  • zero_or_one : ∀ (i j : V), A i j = 0 A i j = 1
  • symm : Matrix.IsSymm A
  • apply_diag : ∀ (i : V), A i i = 0
Instances For
    @[simp]
    theorem Matrix.IsAdjMatrix.apply_diag_ne {V : Type u_1} {α : Type u_2} {A : Matrix V V α} [MulZeroOneClass α] [Nontrivial α] (h : Matrix.IsAdjMatrix A) (i : V) :
    ¬A i i = 1
    @[simp]
    theorem Matrix.IsAdjMatrix.apply_ne_one_iff {V : Type u_1} {α : Type u_2} {A : Matrix V V α} [MulZeroOneClass α] [Nontrivial α] (h : Matrix.IsAdjMatrix A) (i : V) (j : V) :
    ¬A i j = 1 A i j = 0
    @[simp]
    theorem Matrix.IsAdjMatrix.apply_ne_zero_iff {V : Type u_1} {α : Type u_2} {A : Matrix V V α} [MulZeroOneClass α] [Nontrivial α] (h : Matrix.IsAdjMatrix A) (i : V) (j : V) :
    ¬A i j = 0 A i j = 1
    @[simp]
    theorem Matrix.IsAdjMatrix.toGraph_adj {V : Type u_1} {α : Type u_2} {A : Matrix V V α} [MulZeroOneClass α] [Nontrivial α] (h : Matrix.IsAdjMatrix A) (i : V) (j : V) :
    (Matrix.IsAdjMatrix.toGraph h).Adj i j = (A i j = 1)
    def Matrix.IsAdjMatrix.toGraph {V : Type u_1} {α : Type u_2} {A : Matrix V V α} [MulZeroOneClass α] [Nontrivial α] (h : Matrix.IsAdjMatrix A) :

    For A : Matrix V V α and h : IsAdjMatrix A, h.toGraph is the simple graph whose adjacency matrix is A.

    Equations
    Instances For
      def Matrix.compl {V : Type u_1} {α : Type u_2} [Zero α] [One α] [DecidableEq α] [DecidableEq 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.adjMatrix.

      Equations
      Instances For
        @[simp]
        theorem Matrix.compl_apply_diag {V : Type u_1} {α : Type u_2} [DecidableEq α] [DecidableEq V] (A : Matrix V V α) [Zero α] [One α] (i : V) :
        Matrix.compl A i i = 0
        @[simp]
        theorem Matrix.compl_apply {V : Type u_1} {α : Type u_2} [DecidableEq α] [DecidableEq V] (A : Matrix V V α) [Zero α] [One α] (i : V) (j : V) :
        Matrix.compl A i j = 0 Matrix.compl A i j = 1
        @[simp]
        theorem Matrix.isSymm_compl {V : Type u_1} {α : Type u_2} [DecidableEq α] [DecidableEq V] (A : Matrix V V α) [Zero α] [One α] (h : Matrix.IsSymm A) :
        @[simp]
        theorem Matrix.isAdjMatrix_compl {V : Type u_1} {α : Type u_2} [DecidableEq α] [DecidableEq V] (A : Matrix V V α) [Zero α] [One α] (h : Matrix.IsSymm A) :
        @[simp]
        theorem Matrix.IsAdjMatrix.compl {V : Type u_1} {α : Type u_2} [DecidableEq α] [DecidableEq V] {A : Matrix V V α} [Zero α] [One α] (h : Matrix.IsAdjMatrix A) :
        def SimpleGraph.adjMatrix {V : Type u_1} (α : Type u_2) (G : SimpleGraph V) [DecidableRel G.Adj] [Zero α] [One α] :
        Matrix V V α

        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
        Instances For
          @[simp]
          theorem SimpleGraph.adjMatrix_apply {V : Type u_1} {α : Type u_2} (G : SimpleGraph V) [DecidableRel G.Adj] (v : V) (w : V) [Zero α] [One α] :
          SimpleGraph.adjMatrix α G v w = if G.Adj v w then 1 else 0
          @[simp]
          theorem SimpleGraph.isSymm_adjMatrix {V : Type u_1} {α : Type u_2} (G : SimpleGraph V) [DecidableRel G.Adj] [Zero α] [One α] :
          @[simp]

          The adjacency matrix of G is an adjacency matrix.

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

          @[simp]
          theorem SimpleGraph.adjMatrix_dotProduct {V : Type u_1} {α : Type u_2} (G : SimpleGraph V) [DecidableRel G.Adj] [Fintype V] [NonAssocSemiring α] (v : V) (vec : Vα) :
          @[simp]
          theorem SimpleGraph.dotProduct_adjMatrix {V : Type u_1} {α : Type u_2} (G : SimpleGraph V) [DecidableRel G.Adj] [Fintype V] [NonAssocSemiring α] (v : V) (vec : Vα) :
          @[simp]
          theorem SimpleGraph.adjMatrix_mulVec_apply {V : Type u_1} {α : Type u_2} (G : SimpleGraph V) [DecidableRel G.Adj] [Fintype V] [NonAssocSemiring α] (v : V) (vec : Vα) :
          @[simp]
          theorem SimpleGraph.adjMatrix_vecMul_apply {V : Type u_1} {α : Type u_2} (G : SimpleGraph V) [DecidableRel G.Adj] [Fintype V] [NonAssocSemiring α] (v : V) (vec : Vα) :
          @[simp]
          theorem SimpleGraph.adjMatrix_mul_apply {V : Type u_1} {α : Type u_2} (G : SimpleGraph V) [DecidableRel G.Adj] [Fintype V] [NonAssocSemiring α] (M : Matrix V V α) (v : V) (w : V) :
          (SimpleGraph.adjMatrix α G * M) v w = Finset.sum (SimpleGraph.neighborFinset G v) fun (u : V) => M u w
          @[simp]
          theorem SimpleGraph.mul_adjMatrix_apply {V : Type u_1} {α : Type u_2} (G : SimpleGraph V) [DecidableRel G.Adj] [Fintype V] [NonAssocSemiring α] (M : Matrix V V α) (v : V) (w : V) :
          @[simp]
          theorem SimpleGraph.trace_adjMatrix {V : Type u_1} (α : Type u_2) (G : SimpleGraph V) [DecidableRel G.Adj] [Fintype V] [AddCommMonoid α] [One α] :
          theorem SimpleGraph.adjMatrix_mulVec_const_apply {V : Type u_1} {α : Type u_2} {G : SimpleGraph V} [DecidableRel G.Adj] [Fintype V] [Semiring α] {a : α} {v : V} :
          theorem SimpleGraph.adjMatrix_mulVec_const_apply_of_regular {V : Type u_1} {α : Type u_2} {G : SimpleGraph V} [DecidableRel G.Adj] [Fintype V] [Semiring α] {d : } {a : α} (hd : SimpleGraph.IsRegularOfDegree G d) {v : V} :
          theorem SimpleGraph.adjMatrix_pow_apply_eq_card_walk {V : Type u_1} {α : Type u_2} {G : SimpleGraph V} [DecidableRel G.Adj] [Fintype V] [DecidableEq V] [Semiring α] (n : ) (u : V) (v : V) :

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