Documentation

CslibFrontier.Foundations.Combinatorics.SimpleGraph.Berge

Berge's lemma #

A matching M of a graph is maximum when no matching has more edges. An M-augmenting path is a path between two distinct vertices not covered by M whose edges alternate between edges outside and inside M. Exchanging the edges of M along such a path gives a matching covering two more vertices. Berge's lemma states the converse for finite graphs: a matching with no augmenting path is maximum. The proof is the standard one ([Sch17], Theorem 3.2). If a matching M' covers more vertices than M, then in M ∆ M' every vertex has degree at most two. The component of a vertex covered by M' only has a second odd-degree vertex. That vertex is covered by M only, since otherwise the path between them would be M-augmenting. So M' covers at most as many vertices as M.

Matchings are Mathlib's SimpleGraph.Subgraph.IsMatching and alternation is Mathlib's SimpleGraph.IsAlternating.

The results about maximum matchings assume a finite vertex type, as in the source.

Main definitions #

Main results #

References #

theorem SimpleGraph.Walk.IsPath.exists_ne_adj_toSubgraph {V : Type u_1} {G : SimpleGraph V} {u v x a : V} {p : G.Walk u v} (hp : p.IsPath) (hxu : x ≠ u) (hxv : x ≠ v) (ha : p.toSubgraph.Adj x a) :
∃ (b : V), b ≠ a ∧ p.toSubgraph.Adj x b

A vertex of a path other than its two ends has two distinct neighbours on the path.

structure SimpleGraph.Subgraph.IsAugmentingPath {V : Type u_1} {G : SimpleGraph V} (M : G.Subgraph) {u v : V} (p : G.Walk u v) :

p is an M-augmenting path: a path between two distinct vertices not covered by M whose edges alternate between edges outside and inside M ([Ber57]; [Sch17], Section 3.2). Alternation is Mathlib's SimpleGraph.IsAlternating: of two distinct edges of p at a vertex, exactly one lies in M. Since both ends are uncovered, the first and last edges lie outside M and the path has odd length.

Instances For
    def SimpleGraph.Subgraph.augment {V : Type u_1} {G : SimpleGraph V} (M : G.Subgraph) {u v : V} (p : G.Walk u v) :

    The matching M ∆ E(p) obtained by augmenting M along the walk p: an edge belongs to it when it belongs to exactly one of M and p. Its vertices are those of M and of p.

    Instances For
      theorem SimpleGraph.Subgraph.augment_adj {V : Type u_1} {G : SimpleGraph V} {M : G.Subgraph} {u v x y : V} {p : G.Walk u v} :
      (M.augment p).Adj x y ↔ M.Adj x y ∧ ¬p.toSubgraph.Adj x y ∨ p.toSubgraph.Adj x y ∧ ¬M.Adj x y
      theorem SimpleGraph.Subgraph.verts_augment {V : Type u_1} {G : SimpleGraph V} {M : G.Subgraph} {u v : V} {p : G.Walk u v} :
      (M.augment p).verts = M.verts ∪ {x : V | x ∈ p.support}
      theorem SimpleGraph.Subgraph.IsAugmentingPath.not_nil {V : Type u_1} {G : SimpleGraph V} {M : G.Subgraph} {u v : V} {p : G.Walk u v} (hp : M.IsAugmentingPath p) :
      theorem SimpleGraph.Subgraph.IsAugmentingPath.mem_verts_of_mem_support {V : Type u_1} {G : SimpleGraph V} {M : G.Subgraph} {u v : V} {p : G.Walk u v} (hp : M.IsAugmentingPath p) {x : V} (hx : x ∈ p.support) (hxu : x ≠ u) (hxv : x ≠ v) :

      An inner vertex of an augmenting path is covered by M.

      theorem SimpleGraph.Subgraph.IsAugmentingPath.isMatching_augment {V : Type u_1} {G : SimpleGraph V} {M : G.Subgraph} {u v : V} {p : G.Walk u v} (hM : M.IsMatching) (hp : M.IsAugmentingPath p) :

      Augmenting a matching along an augmenting path gives a matching.

      theorem SimpleGraph.Subgraph.IsAugmentingPath.verts_augment_eq {V : Type u_1} {G : SimpleGraph V} {M : G.Subgraph} {u v : V} {p : G.Walk u v} (hp : M.IsAugmentingPath p) :
      theorem SimpleGraph.Subgraph.IsAugmentingPath.ncard_verts_augment {V : Type u_1} {G : SimpleGraph V} {M : G.Subgraph} {u v : V} {p : G.Walk u v} [Finite V] (hp : M.IsAugmentingPath p) :

      The symmetric difference of two matchings #

      The symmetric difference of two matchings alternates with respect to the first one. For two matchings of the same graph, this generalizes Mathlib's Subgraph.IsPerfectMatching.isAlternating_symmDiff_left from perfect matchings to arbitrary matchings (Mathlib's lemma allows the second matching to live in a different graph).

      theorem SimpleGraph.Subgraph.IsMatching.exists_neighborSet_symmDiff_eq_singleton {V : Type u_1} {G : SimpleGraph V} {M M' : G.Subgraph} (hM' : M'.IsMatching) {x : V} (hx : x ∉ M.verts) (hx' : x ∈ M'.verts) :

      A vertex covered by M' but not by M has exactly one neighbour in M ∆ M', its partner in M'.

      A vertex has an odd number of neighbours in M ∆ M' only if exactly one of M and M' covers it.

      theorem SimpleGraph.Subgraph.IsMatching.exists_isAugmentingPath_of_ncard_lt {V : Type u_1} {G : SimpleGraph V} {M M' : G.Subgraph} [Finite V] (hM : M.IsMatching) (hM' : M'.IsMatching) (hlt : M.verts.ncard < M'.verts.ncard) :
      ∃ (u : V) (v : V) (p : G.Walk u v), M.IsAugmentingPath p

      Berge's lemma, hard direction ([Ber57], Theorem 1; [Sch17], Theorem 3.2): if a matching M' covers more vertices than a matching M, then there is an M-augmenting path.

      Maximum matchings and Berge's lemma #

      M is a maximum matching of G: a matching with at least as many edges as every matching of G. Edges are counted with Set.encard. The definition needs no finiteness hypothesis, but it is coarse on infinite graphs, where every matching with infinitely many edges is maximum. The results below assume [Finite V].

      Instances For

        A matching of a finite graph covers twice as many vertices as it has edges.

        In a finite graph, maximality of a matching may be tested by comparing edge counts with Set.ncard.

        In a finite graph a matching is maximum iff it covers at least as many vertices as every matching.

        A perfect matching of a finite graph is maximum.

        A finite graph has a maximum matching.

        Berge's lemma ([Ber57], Theorem 1; [Sch17], Theorem 3.2): a matching of a finite graph is maximum iff there is no augmenting path.