Algorithm Search⌘K

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 G=(V,E)G = (V, E) be an undirected multigraph with weights w≥0w \ge 0 and m≥1m \ge 1 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 TT 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 XX assigns to each e∈Ee \in E a number xe≥0x_e \ge 0 of copies. Its degree dX(v)d_X(v) counts each copy of an edge at vv, and a loop twice. XX is a TT-join if dX(v)d_X(v) is odd exactly for v∈Tv \in T. Its weight is w(X)=∑exew(e)w(X) = \sum_e x_e w(e). G+XG + X is the multigraph with 1+xe1 + x_e copies of ee.

Lemma 1 (walks and joins). (i) If WW is a closed walk that uses every edge of GG at least once, and XX counts the uses beyond the first (xex_e = number of uses of ee minus 1), then XX is a TT-join and w(W)=w(E)+w(X)w(W) = w(E) + w(X). (ii) If XX is a TT-join, then G+XG + X has an Eulerian circuit, and it is a closed walk in GG that uses every edge at least once, of weight w(E)+w(X)w(E) + w(X).

Proof. (i) WW is an Eulerian circuit of G+XG + X, so every degree of G+XG + X is even. Since dG+X(v)=dG(v)+dX(v)d_{G+X}(v) = d_G(v) + d_X(v), dX(v)d_X(v) is odd exactly when dG(v)d_G(v) is odd, that is for v∈Tv \in T. The weight count is immediate. (ii) Each degree of G+XG + X is dG(v)+dX(v)d_G(v) + d_X(v), which is even. Every edge of G+XG + X is a copy of an edge of GG, so all edges of G+XG + X lie in the one component that holds the edges of GG. By Euler's theorem, G+XG + X has an Eulerian circuit. Mapping each copy to its original edge gives a closed walk in GG with the stated properties. □\square

So the optimum is w(E)+τw(E) + \tau, where τ\tau is the least weight of a TT-join, and it remains to show that XX of line L5 is a TT-join of weight τ\tau.

Lemma 2 (reduction to a set). There is a TT-join of weight τ\tau in which every xe∈{0,1}x_e \in \{0, 1\} and no loop is used.

Proof. Replace each xex_e by xe mod 2x_e \bmod 2, and set xe=0x_e = 0 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 TT-join, and since w≥0w \ge 0 its weight does not increase. □\square

Lemma 3 (pairing trails). Let J⊆EJ \subseteq E be a set of non-loop edges whose odd vertices are exactly TT. Then JJ contains ∣T∣/2|T|/2 edge-disjoint trails whose ends pair up the vertices of TT.

Proof. By induction on ∣T∣|T|; if T=∅T = \emptyset there is nothing to show. Otherwise take t∈Tt \in T and walk from tt along edges of JJ, never using an edge twice, as long as the current vertex has an unused edge. When the walk is at a vertex x≠tx \ne t, it has used an odd number of the edges at xx (one more entry than exits); when it is at tt after leaving it, it has used an even number of the edges at tt. So if the current vertex is tt, or is not in TT, its degree in JJ differs in parity from the used count, and an unused edge remains. The walk is finite, so it stops at a vertex t′∈Tt' \in T with t′≠tt' \ne t. It is a trail from tt to t′t'. Removing its edges from JJ changes the parity only at tt and t′t', so the rest has odd vertices T∖{t,t′}T \setminus \{t, t'\}, and the induction hypothesis gives the other trails, edge-disjoint from the first. □\square

Lemma 4 (the matching bound). Let μ\mu be the weight of a minimum weight perfect matching of the complete graph on TT with weights d(s,t)d(s, t). Then τ=μ\tau = \mu.

Proof. (τ≥μ\tau \ge \mu.) Take a TT-join JJ of weight τ\tau as in Lemma 2 and the trails of Lemma 3. The trails pair up TT, so they define a perfect matching NN of TT. A trail from ss to tt weighs at least d(s,t)d(s, t), and the trails are edge-disjoint parts of JJ, so τ=w(J)≥∑{s,t}∈Nd(s,t)≥μ\tau = w(J) \ge \sum_{\{s, t\} \in N} d(s, t) \ge \mu.

(τ≤μ\tau \le \mu.) Let XX be as in line L5, built from the optimal matching MM. A path from ss to tt with s≠ts \ne t has odd degree at ss and tt and even degree at its inner vertices. Adding up the paths for all pairs of MM, each vertex of TT is the end of exactly one path, and each other vertex is an end of none. So dX(v)d_X(v) is odd exactly for v∈Tv \in T, and XX is a TT-join of weight ∑{s,t}∈Md(s,t)=μ\sum_{\{s, t\} \in M} d(s, t) = \mu. So τ≤μ\tau \le \mu. □\square

The shortest paths exist because all odd vertices are in the one component of the edges, and Dijkstra's algorithm computes them because w≥0w \ge 0.

Theorem. If the edges of GG 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 w(E)+μw(E) + \mu.

Proof. The first part is line L1. Otherwise, the set XX of line L5 is a TT-join of weight μ=τ\mu = \tau by Lemma 4, so by Lemma 1 (ii) line L6 finds an Eulerian circuit of G+XG + X, which is a covering closed walk of weight w(E)+τw(E) + \tau. By Lemma 1 (i), every covering closed walk has weight at least w(E)+τw(E) + \tau. ■\blacksquare

Back to Edmonds-Johnson algorithm