Fact-checked by Grok 2 weeks ago

Reverse-delete algorithm

The reverse-delete algorithm is a for finding a (MST) in a connected, undirected with non-negative edge weights. First described by in , it operates by starting with the full set of edges and iteratively removing the highest-weight edges that do not disconnect the graph, yielding a of minimum total weight. Unlike , which constructs the MST by adding the lowest-weight edges without forming , the reverse-delete algorithm begins with all edges and prunes them in decreasing order of weight, skipping edges whose removal would disconnect the graph (i.e., bridges in the current ). This approach relies on the cycle property of MSTs: the maximum-weight edge in any cannot belong to an MST. The algorithm's correctness stems from the greedy choice properties shared with other MST algorithms, ensuring the result is minimal while maintaining . Though asymptotically comparable to Kruskal's in efficient implementations, it is less commonly used due to the challenges in performing repeated tests, particularly on dense graphs. The method illustrates the duality in MST construction and provides insight into optimization in graphs.

Introduction

Overview

The reverse-delete algorithm is a method for constructing a (MST) in a connected, undirected with weighted edges, beginning with the full set of edges and iteratively removing the heaviest edges that do not disconnect the graph. This approach contrasts with additive methods like by focusing on deletion rather than insertion to build the . Key prerequisites include an undirected graph G = (V, E), where vertices V represent nodes and edges E connect pairs of vertices with assigned non-negative weights indicating costs. A is defined as a that connects all vertices without cycles, and the is the one among all possible spanning trees with the smallest total edge weight. The algorithm assumes the graph is connected to ensure a exists. The purpose of the reverse-delete algorithm is to efficiently compute an MST by pruning high-cost while preserving , leveraging properties such as the property—which states that the heaviest in any cannot belong to an MST—to optimality. At a high level, the process involves sorting all in decreasing order of weight and then sequentially attempting to remove each , skipping removal only if it would disconnect the (e.g., via a connectivity check such as DFS or BFS traversal). This results in a that spans all vertices with minimal total weight.

Relation to Minimum Spanning Trees

The reverse-delete algorithm exhibits a strong duality to in the context of minimum spanning trees (MSTs). While constructs an MST by edges in increasing of weight and adding the lightest edges that do not form cycles, the reverse-delete algorithm inverts this by edges in decreasing of weight and removing the heaviest edges that do not disconnect the . This mirroring approach ensures that both algorithms greedily select edges based on the cycle property of MSTs, where the heaviest edge in any cycle cannot belong to an MST, leading to equivalent outcomes when applied to the same . The output of the reverse-delete algorithm is guaranteed to be an MST, possessing the essential properties of being acyclic, connected, and of minimal total edge weight, identical to those produced by Kruskal's or Prim's algorithms. By starting from the and iteratively deleting only "unsafe" heavy edges—those whose removal maintains connectivity—the algorithm preserves a while minimizing weight through adherence to the cut property, which ensures that no lighter edge is overlooked in the final structure. This results in a that spans all vertices with the lowest possible , verifiable through the exchange arguments underlying MST optimality. In comparison to , which builds an MST greedily from a starting by repeatedly adding the minimum-weight connecting the growing tree to an unvisited , the reverse-delete algorithm operates globally across all edges without a designated starting point, beginning instead from the full edge set. This global perspective aligns it more closely with Kruskal's in terms of , both achieving near-linear time with appropriate structures, though reverse-delete's initial complete graph assumption suits dense graphs particularly well. The reverse-delete algorithm finds application in network design scenarios where a full is initially available, such as or transportation systems, allowing for the systematic removal of redundant high-cost links to achieve minimal . For instance, in optimizing layouts or networks, it facilitates expensive while ensuring the remaining infrastructure remains spanning and cost-effective.

Algorithm

Steps

The reverse-delete algorithm operates on a connected, undirected G = (V, E) with non-negative weights, beginning with the full set of edges E that spans all vertices V. All edges are first sorted in non-increasing order of their weights, so the heaviest edges are considered first for potential deletion. The algorithm then proceeds iteratively through this sorted list: for each edge e = (u, v), it determines whether deleting e from the current would increase the number of connected components (i.e., disconnect the ). This connectivity check can be performed using (DFS) or (BFS) on the induced by the current edge set excluding e, to verify if u and v remain connected. If deletion of e maintains connectivity, the edge is removed; otherwise, it is retained. This deletion process continues until exactly |V| - 1 edges remain, ensuring the final subgraph is a that connects all vertices and serves as the .

Pseudocode

The reverse-delete algorithm is typically presented in pseudocode that starts with the complete set of and iteratively removes the heaviest provided that doing so does not disconnect the . This approach leverages the property of minimum spanning trees, ensuring that removed are the heaviest in some . The following outlines the process, assuming the input is a connected, undirected G = (V, E) with weights.
REVERSE-DELETE(G):
1  T ← E  // Start with all edges; T will become the MST edges
2  Sort the edges in T in decreasing order of weight
3  for each edge e ∈ T (in decreasing weight order):
4      if T − {e} is still [connected](/page/Connectivity):
5          T ← T − {e}  // Remove e safely
6  return T
In this , the edges are represented as a list of triples (u, v, w), where u and v are vertices and w is the edge weight, facilitating in descending order of w. The connectivity check in line 4 can be implemented using (DFS) or (BFS) on the graph induced by T − {e}, which verifies if the endpoints of e remain in the same . For improved efficiency in practice, optimizations such as preprocessing or specialized data structures may be used, though the basic version relies on traversal. The Union-Find data structure, equipped with path compression and union-by-rank, can support efficient connectivity queries in related greedy MST algorithms like Kruskal's, achieving nearly linear time overall, but for reverse-delete, the deletion aspect requires careful handling of component maintenance. The algorithm assumes the input graph is connected; if not, it can be adapted to produce a minimum spanning forest by applying the process to each component separately. For graphs with equal edge weights, the algorithm remains correct regardless of tie-breaking, as stable sorting is not required—the greedy choice property ensures an optimal result. Isolated vertices or empty graphs are handled trivially, with no edges in the output.

Worked Example

Graph Setup

To illustrate the reverse-delete algorithm, consider a simple undirected, connected, edge-weighted G = (V, E) with set V = \{A, B, C, D\} and edge set E consisting of six edges with positive weights, as shown in the table below. This setup provides more edges than the minimum required for a (|V| - 1 = 3), enabling the deletion process while maintaining connectivity.
EdgeWeight
A-B1
A-C3
A-D4
B-C2
B-D5
C-D1
The assumes positive weights for simplicity and is fully connected, forming a K_4. For visualization, the vertices can be arranged in a tetrahedral formation, with each labeled by its weight to clearly show the structure before any deletions.

Iteration Details

The reverse-delete algorithm proceeds by considering edges in decreasing order of weight, attempting to delete each one if doing so maintains the graph's . For the example with vertices A, B, C, and D, the edges sorted in decreasing weight order are: BD (weight 5), AD (4), AC (3), BC (2), AB (1), and CD (1). Initially, the graph is fully connected with all six edges, forming a single . The first edge considered is (weight 5). Deleting leaves alternative paths between B and D, such as B-A-D or B-C-D, preserving in one component. Thus, is deleted, and the remaining consists of edges AD, AC, BC, AB, and CD. Next, AD (weight 4) is considered; its deletion still connects A and D via A-C-D or A-B-C-D, so AD is removed, leaving AC, BC, AB, and with one connected component. Continuing, AC (weight 3) is evaluated; removing it connects A and C via A-B-C, maintaining a single component with edges BC, AB, and . The now forms a A-B-C-D. The next edge, BC (weight 2), is tested for deletion; removing BC would split the into two components—A-B and C-D—violating , so BC is retained. At this stage, the intermediate structure is a chain connecting all vertices through AB, BC, and . For AB (weight 1), deletion would isolate A from the rest (B-C-D via BC and CD), creating two components, so AB is kept. Similarly, removing CD (weight 1) would isolate D from A-B-C, disconnecting the graph, so CD is retained. No further deletions are possible, resulting in the minimum spanning tree consisting of edges AB (1), BC (2), and CD (1), with a total weight of 4. This tree spans all vertices without cycles, as depicted by the path A-B-C-D.
StepEdge Considered (Weight)Deletion DecisionComponents After AttemptRemaining Edges
1BD (5)Deleted1AD, AC, BC, AB, CD
2AD (4)Deleted1AC, BC, AB, CD
3AC (3)Deleted1BC, AB, CD
4BC (2)Retained1 (if deleted: 2)BC, AB, CD
5AB (1)Retained1 (if deleted: 2)BC, AB, CD
6CD (1)Retained1 (if deleted: 2)BC, AB, CD

Complexity

Time Complexity

The reverse-delete algorithm has a time complexity of O(E \log E + E(V + E)), where E is the number of edges and V is the number of vertices, dominated by the checks in dense graphs. The edges are first sorted by weight in decreasing order, which takes O(E \log E) time using a comparison-based such as or heap sort. Subsequently, the algorithm iterates over the sorted edges, and for each edge, it performs a check to determine if removal would disconnect the , typically using (DFS) or (BFS), each taking O(V + E) time, leading to a total of O(E(V + E)) for all checks. In the worst case, for dense graphs where E \approx V^2, the is O(V^3); the analysis assumes the input graph is connected, as the algorithm produces a minimum spanning otherwise. This is worse than , which runs in O(E \log V) using Union-Find, and the naive implementation of , which runs in O(V^2) time using an , especially in sparse graphs where E \ll V^2. The reverse-delete algorithm is thus less practical for large graphs due to the repeated full-graph traversals.

Space Complexity

The reverse-delete algorithm exhibits an overall of O(V + E), which is linear with respect to the input size of the , where V denotes the number of vertices and E the number of . This bound arises from the primary components of its data structures: the is typically represented using an , consuming O(V + E) space to store vertices and their incident ; an additional edge list is required for the in decreasing order of weight, occupying O(E) space. To determine whether deleting an edge would disconnect the graph, the algorithm employs connectivity checks, often via (DFS) or (BFS), which utilize auxiliary arrays such as a visited vector of size O(V) or a recursion stack bounded by O(V) in the worst case. While the permits in-place modifications during edge deletions to avoid extra graph copies, the sorting step inevitably demands temporary O(E) space for the edge list, as edges must be extracted and ordered independently of the original representation. In comparison to , which can achieve O(V) auxiliary space beyond the input in optimized implementations using priority queues without full edge storage, the reverse-delete approach may require more memory due to the explicit handling of all s upfront, though it performs well for sparse graphs where E ≈ V.

Correctness

Spanning Tree Guarantee

The reverse-delete algorithm operates on a connected, undirected G = (V, E) and guarantees the production of a by preserving while systematically reducing the number of edges until the tree condition is met. The process begins with the full edge set E, which spans all vertices |V| and maintains connectivity. Edges are considered for deletion in decreasing order of weight, but an edge is removed only if its deletion does not disconnect the graph, meaning the endpoints remain in the same connected component via alternative paths. This condition is efficiently verified using a Union-Find , which tracks components and confirms that removing the edge would not increase the number of components beyond one. By construction, the subgraph remains connected after each deletion, as no removal ever splits the graph into multiple components. The algorithm terminates when no further edges can be deleted without disconnecting the graph, at which point every remaining edge is a bridge essential for connectivity. This stopping condition ensures the final subgraph has exactly |V| - 1 edges, as the process eliminates redundant edges while preserving the spanning property. To formalize this, consider an induction on the number of edges: the initial graph is connected with |E| \geq |V| - 1 edges; each valid deletion reduces the edge count by one while keeping the graph connected; and the process halts precisely when the subgraph is minimally connected, which for a connected graph with |V| vertices requires exactly |V| - 1 edges. Since the final subgraph is connected and contains exactly |V| - 1 edges, it satisfies the fundamental theorem of trees: a connected with |V| vertices and |V| - 1 edges is acyclic and thus a . Deleting edges cannot introduce cycles, so the acyclicity follows directly from the edge count and connectivity in the connected component. If the input is disconnected, the algorithm fails to produce a single , but it assumes a connected input as standard.

Minimality Proof

The minimality of the produced by the reverse-delete algorithm follows from the cycle property of minimum spanning trees (MSTs): in any of the , the maximum-weight cannot belong to any MST. To establish the cycle property, suppose for contradiction that some MST T includes the heaviest e = (u, v) on a C. Removing e from T disconnects the into components S (containing u) and V \setminus S (containing v). The remaining edges of C form a from u to v, which must cross the cut (S, V \setminus S) via at least one e' of weight less than that of e (since e is heaviest on C). Adding e' to T \setminus \{e\} yields a new spanning tree T' with strictly lower total weight than T, contradicting the minimality of T. Thus, no MST contains the heaviest of any , and for any deleted heavy e, the lighter crossing e' in its serves as a replacement across the relevant cut, ensuring optimality is preserved. In the reverse-delete algorithm, edges are processed in decreasing weight order, starting from the full . When considering an edge e, all heavier edges have already been either deleted (if they formed cycles with even heavier edges) or retained (if necessary for ). If deleting e disconnects the current , it is kept; otherwise, the endpoints of e remain connected via a of retained edges, all lighter than e. This plus e forms a where e is the heaviest edge. By the , e cannot belong to any MST, so deleting it is safe and does not preclude achieving minimum weight. Since the algorithm only deletes such non-MST edges and retains a (as proven separately), the final output T contains no superfluous heavy edges and has minimal total weight among all spanning trees. An equivalent proof proceeds by contradiction. Suppose T is the output spanning tree but w(T) > w(T') for some MST T'. The symmetric difference T \Delta T' forms a collection of disjoint cycles, as both T and T' are acyclic and spanning. Across these cycles, the total weight difference implies at least one cycle where an edge e \in T has weight exceeding some edge f \in T' on the same cycle. Consider the heaviest such e \in T over all cycles; the path in T' replacing e consists of lighter edges. When the algorithm processed e (before lighter edges), this lighter path already existed in the current subgraph (as heavier edges were handled first), forming a cycle with e as heaviest, so e would have been deleted—contradicting e \in T. Thus, no lighter T' exists, confirming T is minimal. The reverse-delete algorithm yields the same MST as when edge weights are distinct, as both implement the choice on the bases of —selecting edges that avoid cycles while minimizing (or equivalently, not maximizing unnecessary) weight. This equivalence stems from the matroid exchange properties, ensuring the optimal basis is uniquely determined by sorted selection in either direction for this structure.

References

  1. [1]
    [PDF] Chapter 12 Greedy Algorithms for Minimum Spanning Trees
    Mar 3, 2011 · The reverse delete algorithm, consider the edges of the graph in decreasing cost and remove an edge if it does not disconnect the graph. By ...Missing: explanation | Show results with:explanation
  2. [2]
    [PDF] Spanning Trees
    The reverse-delete algorithm produces a minimum spanning tree. Proof. The reverse-delete algorithm deletes edges in order of decreasing cost. Every time an edge ...Missing: explanation | Show results with:explanation
  3. [3]
    [PDF] Kruskal's Minimum Spanning Tree Algorithm & Union-Find Data ...
    Reverse-Delete Algorithm: Remove edges in decreasing order of weight, skipping those whose removal would disconnect the graph. Theorem. Reverse-Delete ...Missing: explanation | Show results with:explanation
  4. [4]
    [PDF] The Minimum Spanning Tree Problem
    Oct 4, 2007 · Hence the “Reverse Delete” algorithm produces a minimum spanning tree, because it removes only edges that cannot be in any minimum spanning tree ...<|control11|><|separator|>
  5. [5]
    [PDF] Chapter 4 4.5 Minimum Spanning Tree - cs.Princeton
    Reverse-Delete algorithm. Start with T = E. Consider edges in descending order of cost. Delete edge e from T unless doing so would disconnect T. Prim's ...
  6. [6]
    Key Concepts of Minimum Spanning Tree Algorithms to Know for ...
    Reverse-Delete Algorithm. Starts with the complete graph and removes edges in decreasing order of weight. Uses a disjoint-set data structure to check if ...
  7. [7]
    [PDF] Kruskal's Minimum Spanning Tree Algorithm & Union-Find Data ...
    Jan 21, 2013 · Reverse-Delete Algorithm: Remove edges in decreasing order of weight, skipping those whose removal would disconnect the graph. Theorem. Reverse- ...Missing: pseudocode | Show results with:pseudocode
  8. [8]
    Reverse Delete Algorithm for Minimum Spanning Tree
    Aug 4, 2023 · In Reverse Delete algorithm, we sort all edges in decreasing order of their weights. After sorting, we one by one pick edges in decreasing order.Missing: explanation | Show results with:explanation
  9. [9]
    [PDF] Hardware and Software Implementations of Prim's Algorithm for ...
    For common implementations using an adjacency matrix, Prim's complexity is O(V 2). ... Algorithm 2: Second implementation of Prim's algorithm. Input: A non ...
  10. [10]
    Reverse Delete Algorithm for MST - OpenGenus IQ
    In Reverse Delete Algorithm, we sort all edges in decreasing order of their weights. We then pick each edge from the sorted list and remove it from the graph, ...Missing: explanation | Show results with:explanation<|control11|><|separator|>
  11. [11]
    Difference between Prim's and Kruskal's algorithm for MST
    Jul 12, 2025 · Prim's is vertex-based, growing from a single vertex, while Kruskal's is edge-based, adding edges in increasing weight order. Prim's uses a ...
  12. [12]
  13. [13]
    [PDF] CSC373S Lecture 4
    The reverse delete alg does not seem easy to implement efficiently. 2. Kruskal's algorithm can be veiwed as a fixed order greedy algorithm where items are edges ...