A spanning tree of a connected graph is a subgraph that is a tree and contains every vertex of . Its edges must come from . For finite on vertices, every spanning tree has edges, the minimum possible number preserving reachability between all locations. This makes a spanning tree a compact certificate that the original graph is connected. A minimum spanning tree additionally minimizes a specified total edge weight; merely selecting a spanning tree supplies no such optimization. [ref]
Let be our seven-vertex tree with edge added. It has seven edges and a graph cycle. Removing gives the original spanning tree ; removing instead gives another spanning tree . Both retain all seven vertices and six edges, but their graph distances differ: , whereas . In , but , along , compared with . Preserving reachability permits longer journeys; breadth-first search can preserve graph distances from one chosen starting vertex.
To construct a spanning tree, repeatedly delete any edge on a graph cycle. Its endpoints remain joined through the rest of that graph cycle, so the deletion preserves connectedness. Finiteness ensures that this stops at a connected acyclic graph. Conversely, adding an omitted edge to a spanning tree creates its unique fundamental cycle; deleting any other edge on that graph cycle produces another spanning tree. The displayed exchange replaces by . [ref]
https://www.maths.tcd.ie/~dwilkins/Courses/MA2C03/MA2C03Courseware_2014to15/MA2C03_S4_Yr1415.pdf. Trinity College Dublin, section 4.16: deleting cycle edges preserves connectivity
A spanning tree with greatest total edge weight. Apply Kruskal's algorithm in decreasing weight order, or negate every edge weight and compute a minimum spanning tree. Every graph path within a maximum spanning tree solves the widest path problem between its endpoints.
Suppose two spanning trees have the same first edges in nondecreasing weight order. If the first tree's next edge is no heavier than the second tree's next edge, it can be inserted into the second tree while preserving the common prefix and without increasing any sorted edge weight. If already occurs there, it ties for the next position. Otherwise its fundamental cycle contains an edge outside the prefix, since the prefix together with is acyclic. Every such is at least as heavy as . Exchanging for preserves the spanning tree. Replacing a multiset entry by a no-larger entry cannot increase any order statistic. Tied edges can be ordered to preserve the prescribed prefix.
Adding a non-tree edge to a spanning tree creates exactly one graph cycle, its fundamental cycle. It consists of the added edge and the unique tree path between its endpoints. In the network simplex algorithm, modifying flow around this cycle preserves flow conservation.
// Target: foundations-of-mathematics.bigb
A minimum spanning tree of a finite connected undirected weighted graph minimizes the sum of edge weights over all spanning trees. Kruskal's algorithm repeatedly accepts a least-weight edge joining different current connected components. The cut-exchange argument preserves an optimum containing every accepted edge, including when weights tie.
For nonnegative edge costs, an MST gives a lower bound on a travelling salesman tour: removing one tour edge leaves a spanning path whose cost is no greater than the tour cost, and the minimum spanning tree costs no more than that path.
Nonnegativity is needed for this comparison. A triangle with all three edge weights equal to minus one has tour cost and minimum spanning tree cost , so the latter is not a lower bound. The MST optimization problem itself permits negative edge weights.
Let an edge set be contained in some minimum spanning tree, and let a cut of a graph have no crossing edge in . Any least-weight edge crossing that cut of a graph can be added to while preserving its containment in some minimum spanning tree. Insert the chosen edge into an optimum containing , then remove another crossing edge from the resulting graph cycle; it is no lighter and cannot belong to . Ties imply existence of an optimum containing the chosen edge, rather than membership in every optimum.
Start with isolated vertices. In each round, determine the current connected components of a graph, choose a least-weight outgoing edge for each component, add their union, and recompute the components. With distinct weights, each chosen edge is the unique lightest edge across that component's graph cut. The minimum spanning tree cut property puts every such edge in every minimum spanning tree, so the selected edges remain acyclic. Every nonfinal component has an outgoing edge in a connected input, and merging makes progress until a spanning tree remains. Duplicate choices of the same edge are one set insertion.
Each new component contains at least two old components, so there are rounds. Scanning all edges per round gives time. Equal edge weights require a consistent secondary order to avoid choosing a cycle of tied edges.
Otakar Borůvka formulated the distinct-cost minimum-connection problem in 1926.[ref]
O jistém problému minimálním by Otakar Borůvka. pp. 37–38, opening formulation with positive distinct connection costs
Sort the edge weights of a minimum spanning tree and of any spanning tree in nondecreasing order. Then for every position. To prove it, fix a threshold and retain the graph's edges of weight at most . If this graph has connected components, contains a spanning forest of each component using those edges: otherwise a light edge joining two of its pieces could replace an edge heavier than on its tree path, decreasing total weight. Hence exactly edges of have weight at most . No other spanning tree can have more, since its retained edges form a forest inside those components. These threshold counts imply the coordinatewise inequality for sorted weights.
For a finite connected weighted graph with distinct edge weights, Kruskal's algorithm produces the unique minimum spanning tree. If another optimal tree existed, take an edge belonging only to the algorithm's tree and slightly increase its weight without changing the strict edge order. The algorithm then returns exactly the same tree, which must still be optimal, but the other tree's weight is unchanged and is now strictly smaller, a contradiction. Distinct weights are sufficient, not necessary: a triangle with weights has a unique optimum formed from the two weight-one edges.
Every path in a minimum spanning tree solves the bottleneck shortest path problem between its endpoints. If is a maximum-weight edge on the tree path, deleting it gives a graph cut separating the endpoints. A competing path with every edge lighter than would contain a crossing edge ; replacing with would decrease the tree's total weight, a contradiction. Equal weights cause no problem: the argument excludes a strictly smaller bottleneck and does not require a unique tree.
The reverse-delete algorithm processes edges of a finite connected undirected weighted graph in nonincreasing weight order, deleting an edge whenever the graph stays connected.
Maintain the invariant that the surviving graph contains some minimum spanning tree. A deletable edge lies on a cycle. Previously retained heavier edges are bridges and remain bridges after further deletions, so every other edge on that cycle has weight at most . If a current optimum contains , removing it creates a cut. Another cycle edge crosses that cut; replacing by gives a surviving tree of no greater weight. Thus an optimum remains after deleting .
At termination the graph is connected and acyclic, hence is itself a minimum spanning tree. With tied weights, need not be excluded from every optimum. On a triangle with all weights one, every edge belongs to some optimum, yet deleting any one edge is safe. The minimum spanning tree cycle property excludes an edge from every optimum only when it is uniquely heaviest on a cycle.
Kruskal's algorithm constructs a minimum spanning tree of a finite connected graph with undirected edges and real edge weights. Start with all vertices and no edges, a forest of isolated vertices. Sort the edges by nondecreasing weight, then accept an edge exactly when its endpoints belong to different current connected components of a graph. Otherwise reject it: the existing graph path between its endpoints would close a graph cycle. Each acceptance merges two connected components of a graph. Stop after acceptances, when the forest has become one spanning tree.
This is a greedy algorithm for economical network connection: only the next affordable connection and the current connected components of a graph matter. Unlike Prim's algorithm, which grows one reached tree, Kruskal's algorithm can grow several separate trees before joining them. The essential safeguard is avoiding a graph cycle, rather than simply buying the cheapest fixed number of edges.
Joseph Bernard Kruskal described this rule as Construction A on page 49 of his February 1956 paper, On the shortest spanning subtree of a graph and the traveling salesman problem; page 50 gives an exchange argument for distinct weights.[ref]
https://langevin.univ-tln.fr/cours/graphe/bonus/Krukskal.pdf. Joseph B. Kruskal, Jr., Proceedings of the American Mathematical Society 7(1), February 1956, pp. 48–50; inspected scan, Construction A and final exchange argument
Consider this original connected graph on vertices . Its undirected edges, already in increasing weight order, areHere means the unordered pair ; the weights are dimensionless costs. Accept and , with total . Reject : its endpoints already have the graph path , so it would close the graph cycle . Accept and , reaching all five vertices with four edges. The resulting minimum spanning tree isStop here: and need not be examined. If processing continued, both would be rejected because their endpoints are already in the same connected component of a graph.
Taking the three cheapest edges instead gives a graph cycle on , leaving isolated: it is neither a forest nor a spanning tree. Even taking the four cheapest edges adds only and leaves isolated. A cheap infeasible selection cannot compete with a minimum spanning tree. For this small graph, checking all four-edge subsets gives a direct certificate: among those that are spanning trees, exactly one has minimum cost , namely . The general algorithm avoids this exhaustive search.
An edge is safe for the current accepted forest if some minimum spanning tree contains both and that edge. The loop invariant is that some minimum spanning tree contains every accepted edge. It holds initially for the empty edge set. Suppose the next accepted edge joins a current connected component of a graph to its complement. No earlier rejected edge crosses this cut of a graph: once its endpoints are in one connected component of a graph, subsequent merges never separate them. Thus is a lightest edge across that cut of a graph.
For the short exchange argument, take a minimum spanning tree containing . If is absent, adding it creates a fundamental cycle. This graph cycle contains another edge crossing the same cut of a graph. No edge of crosses the cut of a graph, so is not in . Replace by : the result is a spanning tree containing and , with no greater total weight because . It is therefore also a minimum spanning tree. This is the minimum spanning tree cut property in the form needed for tied weights.
In the example, is safe after rejecting : the current connected component of a graph has crossing edges of weights . Its cheapest connection is . The rejected is also the unique heaviest edge of the graph cycle , so the minimum spanning tree cycle property excludes it from every optimum.
Negative and zero edge weights are allowed: the comparisons and exchange argument still apply. Ties can give several minimum spanning trees, though they need not; any order among equal-weight edges remains valid. Distinct edge weights guarantee a unique minimum spanning tree. To see why, take the lightest edge belonging to exactly one of two proposed optima, say . Deleting from gives a cut of a graph; the other optimum has a graph path across it, containing an edge absent from . Hence , and replacing by improves that other optimum, a contradiction. For disconnected input, process all edges to obtain a minimum spanning forest, one minimum spanning tree per original connected component of a graph; no spanning tree of the whole graph exists.[ref]
KruskalMST.java. Robert Sedgewick and Kevin Wayne, Algorithms, 4th edition, companion KruskalMST.java, class documentation and constructor: arbitrary signed weights, ties, disconnected input and sorted processing
A disjoint-set data structure stores the current partition of a set of vertices into connected components of a graph. The operation returns a representative of the block containing . Two vertices are in the same block exactly when their representatives agree. For each candidate edge , compare and . Equal representatives mean reject; different representatives mean accept and perform , merging the two blocks. The representatives are bookkeeping choices, not preferred vertices of the minimum spanning tree.
Connected components of a graph merge only when an edge is accepted
. The same example as a disjoint-set data structure ledger. Each coloured band is one block of the current partition of a set. The rejection of leaves both the partition of a set and the running cost unchanged. Bands show membership, not internal representative pointers. Details.Every acceptance reduces the connected component of a graph count by one and increases the accepted edge count by one, preserving . Thus the ledger reaches exactly when . Only ten representative queries and four merges are needed for the five examined edges, counting two queries per examination and using the already found representatives for each merge. Neither breadth-first search nor reconstruction of a graph path is needed for these connectivity queries.
For and , comparison sorting algorithm takes time for , using Big O notation. One simple disjoint-set data structure implementation stores each block as a rooted tree and attaches the smaller block's root below the larger block's root. Whenever a vertex's depth increases, its block size at least doubles, so its depth is at most . Consequently each representative query or merge takes time. Initialization plus the scan costs ; including sorting algorithm gives , hence for a connected input with . These are operation bounds, not measured timings.[ref]
WeightedQuickUnionUF.java. Robert Sedgewick and Kevin Wayne, Algorithms, 4th edition, companion WeightedQuickUnionUF.java: class documentation and union method; union by size without path compression, linear initialization and logarithmic operations
Start from one graph vertex. Repeatedly add the least-weight edge joining the reached graph vertices to an unreached graph vertex. Each step grows a tree and obeys the minimum spanning tree cut property. On a finite connected graph, the result is a minimum spanning tree.
The unique heaviest edge on a graph cycle belongs to no minimum spanning tree. If a spanning tree contains it, deleting it gives two components; the rest of the graph cycle has a lighter edge across that cut of a graph. Insert that edge to reduce the weight. This is the deletion certificate used by the reverse-delete algorithm.
The unique lightest edge across a cut of a graph belongs to every minimum spanning tree. If a spanning tree omits it, inserting it creates a graph cycle with another edge across that cut of a graph. Removing that heavier edge gives a lighter spanning tree, a contradiction. This proves the correctness of Prim algorithm and Kruskal algorithm for distinct weights.
On a connected locally finite recurrent graph, root Wilson's algorithm at a fixed graph vertex and process a countable enumeration of the graph vertices. Every walk hits the existing tree almost surely, since it contains . Each attached graph path is finite, and the union is a connected acyclic spanning subgraph. Its law is the infinite uniform spanning tree.
It is also the common free and wired finite-volume limit of a sequence along every graph exhaustion. For a finite edge set, run a finite initial segment of the chosen enumeration containing all its endpoints. Its membership is then permanently decided, because later attachments have new internal graph vertices. Only finitely many finite random-walk trajectories were used, and their graph vertices and graph neighbours fit inside all sufficiently large exhaustion sets. Coupling then gives convergence of those finite-dimensional edge laws for both boundary conventions. Finite Wilson's algorithm is root/order independent, so the limiting law is too. There is no uniform counting measure on all infinite spanning trees; the definition is this limiting probability law.
A uniform spanning forest is an infinite-volume limit of uniform spanning trees on finite graph approximations. Free and wired boundary identifications give the free uniform spanning forest and wired uniform spanning forest, respectively.
The free uniform spanning forest of an infinite locally finite graph is the weak limit of uniform spanning trees on finite induced connected exhaustions with free boundary. Every component is infinite almost surely.
For a uniform spanning tree, increasing events supported on disjoint sets of edges have nonpositive covariance. This negative association and the spatial Markov property imply monotonicity of free-boundary spanning-tree measures under exhaustion.
In a finite connected graph with unit electrical resistance on each edge, choose distinct undirected edges and orient each once. Define the transfer current as the signed electric current through when one unit of electric current enters the tail of and leaves its head. For a uniform spanning tree ,Reversing one orientation negates its row and column, leaving the determinant unchanged. Distinctness is necessary: repeating an edge repeats a row and gives zero, although its inclusion can have positive probability.
Electrical reciprocity makes symmetric. The two-edge case therefore givesThus edge inclusions are negatively correlated.[ref]
Local Characteristics, Entropy and Limit Theorems for Spanning Trees and Domino Tilings via Transfer-Impedances by Robert Burton and Robin Pemantle. Theorem1.1 and section4, transfer-impedance determinants
The positive-weight version uses the corresponding conductance-normalized transfer current. Every extendable finite forest has positive inclusion probability, since at least one positively weighted spanning tree contains it.In a finite connected graph with unit edge electrical resistances, orient two edges and . The transfer current is the signed current through when one unit of electric current is injected at and removed at . If is the resulting vertex potential, Ohm's law giveswhere is the graph Laplacian. Potentials are determined up to an additive constant, which cancels in the difference.
On a unit-resistance triangle, injecting across one edge sends of the current along that edge and along the two-edge alternative path. Thus . The transfer-current theorem identifies this diagonal value with the probability that the edge belongs to a uniform spanning tree; exactly two of the triangle's three spanning trees contain it.
Electrical reciprocity makes the unit-resistance kernel symmetric. Reversing one edge orientation changes the appropriate sign, while the determinants giving joint tree-edge probabilities remain unchanged.[ref]
Local Characteristics, Entropy and Limit Theorems for Spanning Trees and Domino Tilings via Transfer-Impedances by Robert Burton and Robin Pemantle. Theorem1.1 and section4, transfer-impedance kernel and determinants
In a finite unweighted connected graph, take distinct graph vertices and orient the unique graph path from to in a uniform spanning tree and assign signed unit current to its edges. Its mean over trees is the electrical unit flow from to . The Kirchhoff node law follows by averaging graph path divergences. For the graph cycle law, let be the two-component spanning forests separating the terminals and the component containing . Deleting a tree-path edge and conversely adjoining an edge across a forest cut are inverse operations. Hence the mean signed current on an edge isThis is the gradient of , proving the graph cycle law. In particular . For an oriented existing edge , that edge is used by the tree graph path exactly when it belongs to the tree, and then has positive orientation. Thus its mean current is , giving the edge-inclusion formula for a uniform spanning tree by Ohm's law.
For a finite electrical network with positive electrical conductances , choose a spanning tree with lawThe one-edge case of the transfer-current theorem gives for . A unit injected electric current produces voltage , and Ohm's law makes the electric current along equal to .
In a triangle of unit resistors, one resistor is parallel to a series pair, so . Each edge consequently has inclusion probability , also clear from the three equally likely spanning trees. For a wired uniform spanning forest, take the finite wired limit and use the limiting wired effective resistance.
On a transitive graph, the free and wired uniform spanning-forest measures are invariant and ergodic under the transitive automorphism group. Consequently every translation-invariant event has probability zero or one.
The Aldous-Broder algorithm samples a uniform spanning tree of a finite connected graph by running a simple random walk from any initial vertex. Whenever the random walk first visits a new vertex, retain the edge by which it arrived. Stop when every vertex has been visited.
Each retained edge joins a previously unseen vertex to the already visited connected subgraph. It cannot create a graph cycle; at termination the retained edges form a spanning tree. The stopping time is the cover time, finite almost surely. The nontrivial conclusion is that every spanning tree has exactly the same probability, independently of the starting vertex.[ref]
The Random Walk Construction of Uniform Spanning Trees and Uniform Labelled Trees by David Aldous. section1, equation1 and Proposition1
Repeated visits add no edges, which can make the method slow when only a few unvisited vertices remain. Wilson's algorithm instead attaches loop-erased random walks. On a recurrent infinite connected graph, the first-entrance construction continues indefinitely and gives the corresponding infinite-volume uniform spanning tree.
For a finite connected graph, Wilson's algorithm starts with a chosen root as the current tree. Choose an unvisited vertex, run a random walk until it hits the current tree, erase loops in chronological order, and attach the resulting simple path. Repeat until every vertex belongs to the tree.
Each attached path has no repeated vertices and first meets the old tree at its endpoint, so attachment preserves connectedness and cannot create a graph cycle. Finiteness and connectedness make each hitting time finite almost surely. The output is a uniform spanning tree, and its law does not depend on the order in which starting vertices were chosen.
For positive electrical conductances , use transition probabilities . The output then has probability proportional to . The proof uses cycle popping: independent stacks of prospective outgoing edges can be exposed and cyclic choices discarded in any order without changing the final rooted tree.[ref]
Generating Random Spanning Trees More Quickly than the Cover Time by David Bruce Wilson. RandomTreeWithRoot and cycle-popping correctness argument
The wired uniform spanning forest of an infinite graph is the weak limit of uniform spanning trees on finite exhaustions whose exterior vertices are identified to one wired boundary vertex.
Wilson's algorithm rooted at infinity builds the wired uniform spanning forest on a transient graph by successively adding loop-erased random walks, run forever when they never hit the forest already constructed.
For a locally finite connected graph with positive electrical conductances, the number of trees in its wired uniform spanning forest is almost surely a deterministic constant, possibly infinite. A precise characterization uses independent random walks with the conductance transition probabilities. Let be the probability that their full vertex ranges are pairwise disjoint. ThenThe right side depends only on the electrical network. The proof amplifies positive disjointness probability to probabilities arbitrarily close to one, then uses Wilson's algorithm rooted at infinity to obtain at least components. Conversely, distinct components force starting vertices admitting positive disjointness probability. This establishes the constant without treating component count as automatically invariant under finite edge changes.[ref]
Uniform Spanning Forests by Itai Benjamini and others. Theorem9.4, printed pages32–33
A directed spanning tree rooted towards a vertex is a spanning tree whose edges are oriented so that every other vertex has a unique directed path to .
The matrix-tree theorem expresses the weighted number of spanning trees of a finite graph as a cofactor of its Graph Laplacian. For a directed graph with out-Laplacian , deleting the row and column indexed by a root giveswhere the sum runs over directed spanning trees rooted towards .
Articles by others on the same topic
A **spanning tree** is a concept from graph theory and is particularly important in the field of computer science, networking, and related disciplines. Here’s a breakdown of the concept: 1. **Definition**: A spanning tree of a graph is a subgraph that includes all the vertices of the original graph and is connected, without any cycles. This means it is a tree structure that spans all the vertices in the graph.


