Definition · Maximal matching, and the cover built from itA matching is a set of edges no two of which share a vertex; it is maximal when no further edge can be added. The algorithm scans the edges in order, keeps an edge whenever neither end has been used, and returns the set of all endpoints of the kept edges as its cover.
Theorem · The endpoints of a maximal matching are a cover of at most twice the minimumLet M be a maximal matching and C the set of endpoints of its edges. Then C is a vertex cover, and |C| = 2|M| ≤ 2 · τ, where τ is the size of the smallest cover.
C is a cover: if some edge had neither end in C, neither of its ends is used by a matched edge, so it could be added to M, contradicting maximality.
|M| ≤ τ: the edges of M are pairwise disjoint, and any cover must contain at least one end of each, so it contains at least |M| distinct vertices.
|C| = 2|M| by construction, since the endpoints of disjoint edges are all different. Combining, |C| = 2|M| ≤ 2τ. Note which quantities appear in each line: the algorithm computes M and C, and τ enters only in the middle inequality, which is the one nobody has to evaluate.
□
The chain, as four numbers on the panel
matching 3 a lower bound the algorithm can see
optimum 3 by exhaustive search over the subsets
cover built 6 the endpoints of the matching
twice the matching 6 the promise
The loaded graph is the three disjoint edges 1-2, 3-4, 5-6. The matching takes all three, the cover takes all six vertices, and the optimum is 3 — one end of each edge. The realised ratio is exactly 2 and the panel prints it against the promised 2. This is the worst the algorithm can do, and it is not an artefact of a strange graph: every matched edge needs one vertex in a cover and the algorithm takes two.
The middle link is the only one needing an optimum, and it is the only one the panel had to do extra work for: 3 comes from an exhaustive search over the subsets of the vertices. Without it the ratio printed above would be a fraction with an invented denominator, which is why every mode of this lab computes both halves.
Every graph of a size, not just this one
The panel then does something a page about approximation usually only describes. It enumerates every graph on the number of vertices its slider names — 63 non-empty graphs on four vertices — solves each one exactly, runs the approximation on each, and reports the worst ratio any of them produced. The answer is 2, attained by 49 of the 63, and it names both the first witness in edge order, which is a single edge, and the densest, which has five edges. Both, because a reader shown only a single edge concludes the bound is an artefact of a degenerate case.
Example · A ratio strictly inside the promiseSwitch to the five-cycle: the greedy matching takes two edges, the cover has four vertices, the optimum is three, and the ratio is 4/3. Switch to the two triangles and the ratio is 1 — the algorithm returns the optimum. Neither number is the algorithm's number, and both are inside a promise of 2 that the first graph attains exactly.
One honest caveat the panel states itself. The matching is greedy in edge order, so the worst ratio found by the sweep is the worst case of this implementation on graphs of that size; a different edge order is a different matching. The bound of 2 covers all of them, because the proof never mentioned the order — which is the sense in which a proof is stronger than a sweep over every instance of a size.