/- 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 FormalConjecturesForMathlib.Combinatorics.SimpleGraph.VertexDistance@[expose] public sectionnamespace SimpleGraphvariable {α : Type*} [Fintype α] [DecidableEq α]

The Wiener index of G, which is the sum of distances between all pairs of vertices.

noncomputable def wienerIndex (G : SimpleGraph α) : := uv : Sym2 α, uv.lift fun u v G.dist u v, α:Type u_1inst✝¹:Fintype αinst✝:DecidableEq αG:SimpleGraph αuv:Sym2 α (a₁ a₂ : α), (fun u v G.dist u v) a₁ a₂ = (fun u v G.dist u v) a₂ a₁ All goals completed! 🐙

Computable Wiener index: half the sum of all ordered pairwise distances.

def computable_wiener (G : SimpleGraph α) [DecidableRel G.Adj] : := ( u Finset.univ, v Finset.univ, computable_dist G u v) / 2α:Type u_1inst✝¹:Fintype αinst✝:DecidableEq αf:α α hf: (a b : α), f a b = f b ahd: (a : α), f a a = 0h_fiber: j, i, f (↑i).1 (↑i).2 = i, f i.1 i.2q:Sym2 αa✝:q Finset.univa:αb:αh_filter:{p | s(p.1, p.2) = s(a, b)} = {(a, b), (b, a)}hab:¬a = bf (a, b).1 (a, b).2 + f a b = 2 * f a b; All goals completed! 🐙All goals completed! 🐙end SimpleGraph