Proofs: Edmonds-Johnson algorithm
These are the human proofs of Edmonds-Johnson algorithm, at full length.
The Edmonds-Johnson algorithm returns a shortest covering closed walk full
This proof shows: correctness, termination.
Let be an undirected multigraph with weights and edges, all in one component (otherwise line L1 returns NIL, and no closed walk covers all edges, since a walk stays in one component). Let be the set of vertices of odd degree, where a self-loop adds 2. All steps are finite (Dijkstra's algorithm, a matching on finitely many points, Hierholzer's algorithm), so the algorithm stops.
Definitions. A multiset of edges assigns to each a number of copies. Its degree counts each copy of an edge at , and a loop twice. is a -join if is odd exactly for . Its weight is . is the multigraph with copies of .
Lemma 1 (walks and joins). (i) If is a closed walk that uses every edge of at least once, and counts the uses beyond the first ( = number of uses of minus 1), then is a -join and . (ii) If is a -join, then has an Eulerian circuit, and it is a closed walk in that uses every edge at least once, of weight .
Proof. (i) is an Eulerian circuit of , so every degree of is even. Since , is odd exactly when is odd, that is for . The weight count is immediate. (ii) Each degree of is , which is even. Every edge of is a copy of an edge of , so all edges of lie in the one component that holds the edges of . By Euler's theorem, has an Eulerian circuit. Mapping each copy to its original edge gives a closed walk in with the stated properties.
So the optimum is , where is the least weight of a -join, and it remains to show that of line L5 is a -join of weight .
Lemma 2 (reduction to a set). There is a -join of weight in which every and no loop is used.
Proof. Replace each by , and set for every loop. Removing two copies of an edge, or one copy of a loop, changes each degree by an even number, so the result is still a -join, and since its weight does not increase.
Lemma 3 (pairing trails). Let be a set of non-loop edges whose odd vertices are exactly . Then contains edge-disjoint trails whose ends pair up the vertices of .
Proof. By induction on ; if there is nothing to show. Otherwise take and walk from along edges of , never using an edge twice, as long as the current vertex has an unused edge. When the walk is at a vertex , it has used an odd number of the edges at (one more entry than exits); when it is at after leaving it, it has used an even number of the edges at . So if the current vertex is , or is not in , its degree in differs in parity from the used count, and an unused edge remains. The walk is finite, so it stops at a vertex with . It is a trail from to . Removing its edges from changes the parity only at and , so the rest has odd vertices , and the induction hypothesis gives the other trails, edge-disjoint from the first.
Lemma 4 (the matching bound). Let be the weight of a minimum weight perfect matching of the complete graph on with weights . Then .
Proof. (.) Take a -join of weight as in Lemma 2 and the trails of Lemma 3. The trails pair up , so they define a perfect matching of . A trail from to weighs at least , and the trails are edge-disjoint parts of , so .
(.) Let be as in line L5, built from the optimal matching . A path from to with has odd degree at and and even degree at its inner vertices. Adding up the paths for all pairs of , each vertex of is the end of exactly one path, and each other vertex is an end of none. So is odd exactly for , and is a -join of weight . So .
The shortest paths exist because all odd vertices are in the one component of the edges, and Dijkstra's algorithm computes them because .
Theorem. If the edges of are not in one component, EDMONDS-JOHNSON returns NIL, and no covering closed walk exists. Otherwise it returns a closed walk that uses every edge at least once, of the least possible weight .
Proof. The first part is line L1. Otherwise, the set of line L5 is a -join of weight by Lemma 4, so by Lemma 1 (ii) line L6 finds an Eulerian circuit of , which is a covering closed walk of weight . By Lemma 1 (i), every covering closed walk has weight at least .