Documentation

CslibFrontier.Algorithms.Lean.Euler.Handshake

The handshake lemma for list multigraphs #

For a finite multigraph given by an edge list H : List (α × α) (parallel edges and self-loops allowed, Cslib.Algorithms.Lean.Euler.degree counting a self-loop twice), the degrees sum to twice the number of edges, so an even number of vertices have odd degree. Christofides' algorithm uses this to find a perfect matching on the odd-degree vertices of a spanning tree ([WS11], Section 2.4).

Mathlib's SimpleGraph.sum_degrees_eq_twice_card_edges and SimpleGraph.even_card_odd_degree_vertices prove the same for simple graphs; the statements here cover the list multigraphs of Cslib.Algorithms.Lean.Euler.

Main results #

References #

theorem Cslib.Algorithms.Lean.Euler.sum_map_degree {α : Type u_1} [DecidableEq α] {H : List (α × α)} {V : List α} (hV : V.Nodup) (hH : ∀ e ∈ H, e.1 ∈ V ∧ e.2 ∈ V) :
(List.map (degree H) V).sum = 2 * H.length

Degree sum for list multigraphs: summed over a duplicate-free list of vertices containing every endpoint, the degrees count each edge twice.

theorem Cslib.Algorithms.Lean.Euler.even_length_filter_odd_degree {α : Type u_1} [DecidableEq α] {H : List (α × α)} {V : List α} (hV : V.Nodup) (hH : ∀ e ∈ H, e.1 ∈ V ∧ e.2 ∈ V) :
Even (List.filter (fun (x : α) => decide (Odd (degree H x))) V).length

The handshake lemma for list multigraphs: among the vertices of a duplicate-free list containing every endpoint, an even number have odd degree.