/- Copyright 2026 The Formal Conjectures Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -/ module public import Mathlib.Algebra.Polynomial.Roots public import Mathlib.Combinatorics.SimpleGraph.AdjMatrix public import Mathlib.Data.Real.Basic public import Mathlib.LinearAlgebra.Matrix.Charpoly.Basic@[expose] public sectionnamespace SimpleGraphvariable {α : Type*} [Fintype α] [DecidableEq α]

Given a simple graph G with adjacency matrix A, this is the number n₀ + min n₊ n₋ where:

    n₀ is the multiplicity of zero as an eigenvalue of A

    n₊ is the number of positive eigenvalues of A (counting multiplicities)

    n₋ is the number of negative eigenvalues of A (counting multiplicities)

noncomputable def cvetkovic (G : SimpleGraph α) [DecidableRel G.Adj] : := letI A : Matrix α α := G.adjMatrix letI spectrum : Multiset := (Matrix.charpoly A).roots letI positive_count : := spectrum.countP (fun x => 0 < x) letI negative_count : := spectrum.countP (fun x => 0 > x) letI zero_count : := spectrum.countP (fun x => 0 = x) zero_count + min positive_count negative_countend SimpleGraph