Algorithm Search⌘K

Proofs: Reverse-delete algorithm

These are the human proofs of Reverse-delete algorithm, at full length.

Reverse-delete returns a minimum spanning forest full

This proof shows: correctness, termination.

Claim. Let G=(V,E)G = (V, E) be a finite undirected graph with a real weight w(e)w(e) on each edge. Weights may tie and may be negative, GG may have parallel edges and self-loops, and GG need not be connected. Then REVERSE-DELETE(G,w)(G, w) stops, and the set FF that it returns is a minimum spanning forest of GG: a forest with the same connected components as GG, of least total weight among all such forests.

Setup. Let e1,e2,…,eme_1, e_2, \ldots, e_m be the edges in the order of line L2, so w(e1)≥w(e2)≥⋯≥w(em)w(e_1) \ge w(e_2) \ge \cdots \ge w(e_m). Let FkF_k be the set FF after eke_k is processed, with F0=EF_0 = E. An edge e∈Fe \in F is a bridge of (V,F)(V, F) if its two ends are not connected in (V,F∖{e})(V, F \setminus \{e\}). A self-loop is never a bridge. An edge lies on a cycle of (V,F)(V, F) if and only if it is not a bridge: if its ends u≠vu \ne v are connected without it, a simple path from uu to vv and the edge form a cycle, and a self-loop is a cycle by itself; conversely, the rest of a cycle through ee connects its ends. Each spanning forest of GG has n−cn - c edges, where cc is the number of components of GG (spanning forest).

Lemma 1 (bridges stay bridges). If ee is a bridge of (V,F)(V, F) and F′⊆FF' \subseteq F with e∈F′e \in F', then ee is a bridge of (V,F′)(V, F').

Proof. A path in (V,F′∖{e})(V, F' \setminus \{e\}) is also a path in (V,F∖{e})(V, F \setminus \{e\}). So if the ends of ee are not connected in the second graph, they are not connected in the first. □\square

Invariant. For each kk from 00 to mm:

  • (C) (V,Fk)(V, F_k) has the same connected components as GG.
  • (K) Each edge eje_j with j≤kj \le k and ej∈Fke_j \in F_k is a bridge of (V,Fk)(V, F_k).
  • (M) There is a minimum spanning forest Fk∗F^*_k of GG with Fk∗⊆FkF^*_k \subseteq F_k.

Initialization. F0=EF_0 = E, so (C) holds, (K) is empty, and any minimum spanning forest is a subset of EE, so (M) holds.

Maintenance, eke_k kept. Then Fk=Fk−1F_k = F_{k-1}, and (C) and (M) carry over. The test of line L4 failed, so eke_k is a bridge of (V,Fk)(V, F_k). The edges eje_j with j<kj < k in FkF_k were bridges of (V,Fk−1)=(V,Fk)(V, F_{k-1}) = (V, F_k) by (K). So (K) holds.

Maintenance, ek=uve_k = uv deleted. Then uu and vv are connected in (V,Fk−1∖{ek})(V, F_{k-1} \setminus \{e_k\}).

  1. (C): any path of (V,Fk−1)(V, F_{k-1}) that uses eke_k can replace it by a path from uu to vv in (V,Fk)(V, F_k). So connectivity does not change.

  2. (K): each eje_j with j<kj < k in FkF_k was a bridge of (V,Fk−1)(V, F_{k-1}) by (K), and it is a bridge of (V,Fk)(V, F_k) by Lemma 1.

  3. (M): if ek∉Fk−1∗e_k \notin F^*_{k-1}, then Fk−1∗⊆FkF^*_{k-1} \subseteq F_k and we take Fk∗=Fk−1∗F^*_k = F^*_{k-1}. So assume ek∈Fk−1∗e_k \in F^*_{k-1}. A self-loop is in no forest, so u≠vu \ne v. Let PP be a simple path from uu to vv in (V,Fk)(V, F_k). Then C=P∪{ek}C = P \cup \{e_k\} is a cycle in (V,Fk−1)(V, F_{k-1}).

    Each edge f∈Pf \in P is eje_j for some jj. If j<kj < k, then by (K) ff is a bridge of (V,Fk−1)(V, F_{k-1}), but ff lies on the cycle CC of (V,Fk−1)(V, F_{k-1}), so it is not a bridge. Hence j>kj > k, and w(f)≤w(ek)w(f) \le w(e_k) by the order of the sort.

    Removing eke_k from Fk−1∗F^*_{k-1} splits its tree that holds uu and vv into a part X∋uX \ni u and a part Y∋vY \ni v. The path PP starts in XX and ends in YY, so it has an edge gg with one end in XX and the other in YY. Then g∉Fk−1∗g \notin F^*_{k-1}, since the only edge of Fk−1∗F^*_{k-1} between XX and YY is eke_k, and g≠ekg \ne e_k. Let Fk∗=Fk−1∗∖{ek}∪{g}F^*_k = F^*_{k-1} \setminus \{e_k\} \cup \{g\}. Adding gg joins XX and YY again, so Fk∗F^*_k is a forest with the components of Fk−1∗F^*_{k-1}, which are those of GG. Its weight is w(Fk−1∗)−w(ek)+w(g)≤w(Fk−1∗)w(F^*_{k-1}) - w(e_k) + w(g) \le w(F^*_{k-1}), since g∈Pg \in P. So Fk∗F^*_k is a minimum spanning forest, and Fk∗⊆FkF^*_k \subseteq F_k, because Fk−1∗∖{ek}⊆FkF^*_{k-1} \setminus \{e_k\} \subseteq F_k and g∈P⊆Fkg \in P \subseteq F_k.

Termination. The loop of line L3 runs once for each of the mm edges, and each test of line L4 is a graph search on a finite graph, which stops. So the algorithm stops after mm steps.

Conclusion. Let F=FmF = F_m. By (K) with k=mk = m, every edge of FF is a bridge of (V,F)(V, F), so no edge of FF lies on a cycle, and FF is a forest. By (C), its components are those of GG, so FF is a spanning forest with n−cn - c edges. By (M), FF contains a minimum spanning forest Fm∗F^*_m, which also has n−cn - c edges, so F=Fm∗F = F^*_m. Therefore FF is a minimum spanning forest, and a minimum spanning tree when GG is connected. ■\blacksquare

Back to Reverse-delete algorithm