Proofs: Vizing's algorithm
These are the human proofs of Vizing's algorithm, at full length.
Each step of Misra-Gries colors one more edge and keeps the coloring proper full
This proof shows: correctness, termination.
Let . A partial edge coloring is proper when two colored edges with a common end have different colors. A color is free at when no colored edge at has it. Every vertex has at most edges, so it always has a free color.
We show: if before a turn of line L1 the colored edges form a proper partial coloring and is uncolored, then after the turn the same holds with colored and no colored edge uncolored. The loop runs once per edge, so it terminates, and by induction the final coloring is proper with all edges colored and colors in .
Rotation. Let be a fan at . After the rotation, has the old color of for , and is uncolored. At , the edges now carry the old colors of , and carries none, so the set of colors at is unchanged and no color repeats. At for , the new color of was free at by the fan condition, and has no other changed edge. So the result is proper.
Swap. For colors , the edges colored or form vertex-disjoint paths and cycles. Swapping and on one whole component keeps the coloring proper: inside the component, consecutive edges still differ, and at an end of a path, the color that the end edge gets was free at , since is an end. If is free at , then meets at most one edge of color or , so is an end of its component, which is the cd-path at (empty if is also free at ). If , then is free at and the path is empty.
Line L4 frees at . If was free at , nothing changes. Otherwise the first edge of the path is the edge at of color , which becomes , and was free at . So after line L4, is free at .
Line L5 succeeds. Let be the maximal fan of line L2, free at and free at , all before line L4. It suffices to exhibit one such that, after line L4, is a fan and is free at ; the first such also qualifies.
- was free at . The path is empty, is unchanged and is free at . Take .
- was not free at . Let be the edge of color . Since is free at , the vertex would extend if , and because is uncolored. So with , and is free at by the fan condition. No edge with has color or , as is free at and is used at only by . The swap changes only colors and , so for , the edge keeps its color, and that color stays free or not free at each vertex as before. Let be the cd-path at ; it starts with the edge .
- does not end at . Since is free at , the vertex meets at most one edge of 's colors, so if it were on it would be an end; the ends are and some vertex other than . So , and stays free at . The conditions for involve only the edges , which keep their colors, so it is still a fan. Take .
- ends at . The last edge of at had color , because was free there, so after the swap is free at , and now has color . So the condition for holds again, and the conditions for the other indices are unchanged: is still a fan. The vertex is not on : it would have to be an end, since is free at , and the ends are and . So is still free at . Take .
Lines L6 and L7. Let be the vertex found at line L5. Rotating the fan keeps the coloring proper, colors , and uncolors . The rotation does not add any color at , and at it only removes the color of , so is still free at both and . Line L7 colors with , which keeps the coloring proper. All edges colored before the turn are colored after it, and is now colored too. ∎