Minimum spanning tree explained

A minimum spanning tree (MST) or minimum weight spanning tree is a subset of the edges of a connected, edge-weighted undirected graph that connects all the vertices together, without any cycles and with the minimum possible total edge weight.[1] That is, it is a spanning tree whose sum of edge weights is as small as possible.[2] More generally, any edge-weighted undirected graph (not necessarily connected) has a minimum spanning forest, which is a union of the minimum spanning trees for its connected components.

There are many use cases for minimum spanning trees. One example is a telecommunications company trying to lay cable in a new neighborhood. If it is constrained to bury the cable only along certain paths (e.g. roads), then there would be a graph containing the points (e.g. houses) connected by those paths. Some of the paths might be more expensive, because they are longer, or require the cable to be buried deeper; these paths would be represented by edges with larger weights. Currency is an acceptable unit for edge weight – there is no requirement for edge lengths to obey normal rules of geometry such as the triangle inequality. A spanning tree for that graph would be a subset of those paths that has no cycles but still connects every house; there might be several spanning trees possible. A minimum spanning tree would be one with the lowest total cost, representing the least expensive path for laying the cable.

Properties

Possible multiplicity

If there are vertices in the graph, then each spanning tree has edges.

There may be several minimum spanning trees of the same weight; in particular, if all the edge weights of a given graph are the same, then every spanning tree of that graph is minimum.

Uniqueness

If each edge has a distinct weight then there will be only one, unique minimum spanning tree. This is true in many realistic situations, such as the telecommunications company example above, where it's unlikely any two paths have exactly the same cost. This generalizes to spanning forests as well.

Proof:

  1. Assume the contrary, that there are two different MSTs and .
  2. Since and differ despite containing the same nodes, there is at least one edge that belongs to one but not the other. Among such edges, let be the one with least weight; this choice is unique because the edge weights are all distinct. Without loss of generality, assume is in .
  3. As is an MST, must contain a cycle with .
  4. As a tree, contains no cycles, therefore must have an edge that is not in .
  5. Since was chosen as the unique lowest-weight edge among those belonging to exactly one of and, the weight of must be greater than the weight of .
  6. As and are part of the cycle, replacing with in therefore yields a spanning tree with a smaller weight.
  7. This contradicts the assumption that is an MST.

More generally, if the edge weights are not all distinct then only the (multi-)set of weights in minimum spanning trees is certain to be unique; it is the same for all minimum spanning trees.[3]

Minimum-cost subgraph

If the weights are positive, then a minimum spanning tree is, in fact, a minimum-cost subgraph connecting all vertices, since if a subgraph contains a cycle, removing any edge along that cycle will decrease its cost and preserve connectivity.

Cycle property

For any cycle in the graph, if the weight of an edge of is larger than any of the individual weights of all other edges of, then this edge cannot belong to an MST.

Proof: Assume the contrary, i.e. that belongs to an MST . Then deleting will break into two subtrees with the two ends of in different subtrees. The remainder of reconnects the subtrees, hence there is an edge of with ends in different subtrees, i.e., it reconnects the subtrees into a tree with weight less than that of, because the weight of is less than the weight of .

Cut property

For any cut of the graph, if the weight of an edge in the cut-set of is strictly smaller than the weights of all other edges of the cut-set of, then this edge belongs to all MSTs of the graph.

Proof: Assume that there is an MST that does not contain . Adding to will produce a cycle, that crosses the cut once at and crosses back at another edge . Deleting we get a spanning tree of strictly smaller weight than . This contradicts the assumption that was a MST.

By a similar argument, if more than one edge is of minimum weight across a cut, then each such edge is contained in some minimum spanning tree.

Minimum-cost edge

If the minimum cost edge of a graph is unique, then this edge is included in any MST.

Proof: if was not included in the MST, removing any of the (larger cost) edges in the cycle formed after adding to the MST, would yield a spanning tree of smaller weight.

Contraction

If is a tree of MST edges, then we can contract into a single vertex while maintaining the invariant that the MST of the contracted graph plus gives the MST for the graph before contraction.

Algorithms

In all of the algorithms below, is the number of edges in the graph and is the number of vertices.

Classic algorithms

The first algorithm for finding a minimum spanning tree was developed by Czech scientist Otakar Borůvka in 1926 (see Borůvka's algorithm). Its purpose was an efficient electrical coverage of Moravia. The algorithm proceeds in a sequence of stages. In each stage, called Boruvka step, it identifies a forest consisting of the minimum-weight edge incident to each vertex in the graph, then forms the graph as the input to the next step. Here denotes the graph derived from by contracting edges in (by the Cut property, these edges belong to the MST). Each Boruvka step takes linear time. Since the number of vertices is reduced by at least half in each step, Boruvka's algorithm takes time.

A second algorithm is Prim's algorithm, which was invented by Vojtěch Jarník in 1930 and rediscovered by Prim in 1957 and Dijkstra in 1959. Basically, it grows the MST one edge at a time. Initially, contains an arbitrary vertex. In each step, is augmented with a least-weight edge such that is in and is not yet in . By the Cut property, all edges added to are in the MST. Its run-time is either or, depending on the data-structures used.

A third algorithm commonly in use is Kruskal's algorithm, which also takes time.

A fourth algorithm, not as commonly used, is the reverse-delete algorithm, which is the reverse of Kruskal's algorithm. Its runtime is .

All four of these are greedy algorithms. Since they run in polynomial time, the problem of finding such trees is in FP, and related decision problems such as determining whether a particular edge is in the MST or determining if the minimum total weight exceeds a certain value are in P.

Faster algorithms

Several researchers have tried to find more computationally-efficient algorithms.

In a comparison model, in which the only allowed operations on edge weights are pairwise comparisons, found a linear time randomized algorithm based on a combination of Borůvka's algorithm and the reverse-delete algorithm.[4]

The fastest non-randomized comparison-based algorithm with known complexity, by Bernard Chazelle, is based on the soft heap, an approximate priority queue.[5] [6] Its running time is, where is the classical functional inverse of the Ackermann function. The function grows extremely slowly, so that for all practical purposes it may be considered a constant no greater than 4; thus Chazelle's algorithm takes very close to linear time.

Linear-time algorithms in special cases

Dense graphs

If the graph is dense (i.e., then a deterministic algorithm by Fredman and Tarjan finds the MST in time .[7] The algorithm executes a number of phases. Each phase executes Prim's algorithm many times, each for a limited number of steps. The run-time of each phase is . If the number of vertices before a phase is, the number of vertices remaining after a phase is at most

\tfrac{n'}{2m/n'

}. Hence, at most phases are needed, which gives a linear run-time for dense graphs.

There are other algorithms that work in linear time on dense graphs.[5] [8]

Integer weights

If the edge weights are integers represented in binary, then deterministic algorithms are known that solve the problem in integer operations.[9] Whether the problem can be solved deterministically for a general graph in linear time by a comparison-based algorithm remains an open question.

Decision trees

Given graph where the nodes and edges are fixed but the weights are unknown, it is possible to construct a binary decision tree (DT) for calculating the MST for any permutation of weights. Each internal node of the DT contains a comparison between two edges, e.g. "Is the weight of the edge between and larger than the weight of the edge between and ?". The two children of the node correspond to the two possible answers "yes" or "no". In each leaf of the DT, there is a list of edges from that correspond to an MST. The runtime complexity of a DT is the largest number of queries required to find the MST, which is just the depth of the DT. A DT for a graph is called optimal if it has the smallest depth of all correct DTs for .

For every integer, it is possible to find optimal decision trees for all graphs on vertices by brute-force search. This search proceeds in two steps.

A. Generating all potential DTs

2r

different graphs on vertices.
r2
2
.

{(r4)}

r2
(2)

=

(r2+2)
2
r

.

B. Identifying the correct DTsTo check if a DT is correct, it should be checked on all possible permutations of the edge weights.

Hence, the total time required for finding an optimal DT for all graphs with vertices is:

2r

(r2+2)
2
r

(r2+1)!,

which is less than
r2+o(r)
2
2

.

See also: Decision tree model.

Optimal algorithm

Seth Pettie and Vijaya Ramachandran have found a optimal deterministic comparison-based minimum spanning tree algorithm.[10] The following is a simplified description of the algorithm.

  1. Let, where is the number of vertices. Find all optimal decision trees on vertices. This can be done in time (see Decision trees above).
  2. Partition the graph to components with at most vertices in each component. This partition uses a soft heap, which "corrupts" a small number of the edges of the graph.
  3. Use the optimal decision trees to find an MST for the uncorrupted subgraph within each component.
  4. Contract each connected component spanned by the MSTs to a single vertex, and apply any algorithm which works on dense graphs in time to the contraction of the uncorrupted subgraph
  5. Add back the corrupted edges to the resulting forest to form a subgraph guaranteed to contain the minimum spanning tree, and smaller by a constant factor than the starting graph. Apply the optimal algorithm recursively to this graph.

The runtime of all steps in the algorithm is, except for the step of using the decision trees. The runtime of this step is unknown, but it has been proved that it is optimal - no algorithm can do better than the optimal decision tree. Thus, this algorithm has the peculiar property that it is optimal although its runtime complexity is unknown.

Parallel and distributed algorithms

Research has also considered parallel algorithms for the minimum spanning tree problem.With a linear number of processors it is possible to solve the problem in time.[11] [12]

The problem can also be approached in a distributed manner. If each node is considered a computer and no node knows anything except its own connected links, one can still calculate the distributed minimum spanning tree.

MST on complete graphs with random weights

Alan M. Frieze showed that given a complete graph on n vertices, with edge weights that are independent identically distributed random variables with distribution function

F

satisfying

F'(0)>0

, then as n approaches +∞ the expected weight of the MST approaches

\zeta(3)/F'(0)

, where

\zeta

is the Riemann zeta function (more specifically is

\zeta(3)

Apéry's constant). Frieze and Steele also proved convergence in probability. Svante Janson proved a central limit theorem for weight of the MST.

For uniform random weights in

[0,1]

, the exact expected size of the minimum spanning tree has been computed for small complete graphs.
VerticesExpected sizeApproximate expected size
20.5
30.75
40.8857143
50.9664502
61.0183151
71.053716
81.0790588
91.0979027

Fractional variant

There is a fractional variant of the MST, in which each edge is allowed to appear "fractionally". Formally, a fractional spanning set of a graph (V,E) is a nonnegative function f on E such that, for every non-trivial subset W of V (i.e., W is neither empty nor equal to V), the sum of f(e) over all edges connecting a node of W with a node of V\W is at least 1. Intuitively, f(e) represents the fraction of e that is contained in the spanning set. A minimum fractional spanning set is a fractional spanning set for which the sum

\sume\inf(e)w(e)

is as small as possible.

If the fractions f(e) are forced to be in, then the set T of edges with f(e)=1 are a spanning set, as every node or subset of nodes is connected to the rest of the graph by at least one edge of T. Moreover, if f minimizes

\sume\inf(e)w(e)

, then the resulting spanning set is necessarily a tree, since if it contained a cycle, then an edge could be removed without affecting the spanning condition. So the minimum fractional spanning set problem is a relaxation of the MST problem, and can also be called the fractional MST problem.

The fractional MST problem can be solved in polynomial time using the ellipsoid method. However, if we add a requirement that f(e) must be half-integer (that is, f(e) must be in), then the problem becomes NP-hard, since it includes as a special case the Hamiltonian cycle problem: in an

n

-vertex unweighted graph, a half-integer MST of weight

n/2

can only be obtained by assigning weight 1/2 to each edge of a Hamiltonian cycle.

Other variants

O(E+VlogV)

time using the Chu–Liu/Edmonds algorithm.

Applications

Minimum spanning trees have direct applications in the design of networks, including computer networks, telecommunications networks, transportation networks, water supply networks, and electrical grids (which they were first invented for, as mentioned above). They are invoked as subroutines in algorithms for other problems, including the Christofides algorithm for approximating the traveling salesman problem,[25] approximating the multi-terminal minimum cut problem (which is equivalent in the single-terminal case to the maximum flow problem),[26] and approximating the minimum-cost weighted perfect matching.[27]

Other practical applications based on minimal spanning trees include:

Further reading

External links

Notes and References

  1. Web site: scipy.sparse.csgraph.minimum_spanning_tree - SciPy v1.7.1 Manual . Numpy and Scipy Documentation — Numpy and Scipy documentation . 2021-12-10 . A minimum spanning tree is a graph consisting of the subset of edges which together connect all connected nodes, while minimizing the total sum of weights on the edges..
  2. Web site: networkx.algorithms.tree.mst.minimum_spanning_edges . NetworkX 2.6.2 documentation . 2021-12-13 . A minimum spanning tree is a subgraph of the graph (a tree) with the minimum sum of edge weights. A spanning forest is a union of the spanning trees for each connected component of the graph..
  3. Web site: Do the minimum spanning trees of a weighted graph have the same number of edges with a given weight?. cs.stackexchange.com. 4 April 2018.
  4. .
  5. .
  6. .
  7. 10.1145/28869.28874. Fibonacci heaps and their uses in improved network optimization algorithms. Journal of the ACM. 34. 3. 596. 1987. Fredman . M. L. . Tarjan . R. E. . 7904683. free.
  8. 10.1007/bf02579168. Efficient algorithms for finding minimum spanning trees in undirected and directed graphs. Combinatorica. 6. 2. 109. 1986. Gabow . H. N. . Harold N. Gabow . Galil . Z. . Spencer . T. . Tarjan . R. E. . 35618095.
  9. .
  10. .
  11. .
  12. .
  13. . ND12
  14. .
  15. .
  16. .
  17. .
  18. McDonald . Ryan . Pereira . Fernando . Ribarov . Kiril . Hajič . Jan . Non-projective dependency parsing using spanning tree algorithms . Proc. HLT/EMNLP . 2005 .
  19. .
  20. .
  21. .
  22. .
  23. Web site: Everything about Bottleneck Spanning Tree. flashing-thoughts.blogspot.ru. 5 June 2010 . 4 April 2018.
  24. Web site: Archived copy . 2014-07-02 . 2013-06-12 . https://web.archive.org/web/20130612080859/http://pages.cpsc.ucalgary.ca/~dcatalin/413/t4.pdf . dead .
  25. [Nicos Christofides]
  26. Dahlhaus . E. . Johnson . D. S. . David S. Johnson . Papadimitriou . C. H. . Christos Papadimitriou . Seymour . P. D. . Paul Seymour (mathematician) . Yannakakis . M. . Mihalis Yannakakis . August 1994 . The complexity of multiterminal cuts . dead . . 23 . 4 . 864–894 . 10.1137/S0097539792225297 . https://web.archive.org/web/20040824184059/http://akpublic.research.att.com/~dsj/papers/3way.pdf . 24 August 2004 . 17 December 2012.
  27. Supowit . Kenneth J. . Plaisted . David A. . Reingold . Edward M. . 1980 . Heuristics for weighted perfect matching . 12th Annual ACM Symposium on Theory of Computing (STOC '80) . New York, NY, USA . ACM . 398–419 . 10.1145/800141.804689.
  28. Sneath . P. H. A. . 1 August 1957 . The Application of Computers to Taxonomy . Journal of General Microbiology . 17 . 1 . 201–226 . 10.1099/00221287-17-1-201 . 13475686 . free.
  29. Asano . T. . Tetsuo Asano . Bhattacharya . B. . Keil . M. . Yao . F. . Frances Yao . 1988 . Clustering algorithms based on minimum and maximum spanning trees . Fourth Annual Symposium on Computational Geometry (SCG '88) . 1 . 252–257 . 10.1145/73393.73419.
  30. Gower . J. C. . Ross . G. J. S. . 1969 . Minimum Spanning Trees and Single Linkage Cluster Analysis . Journal of the Royal Statistical Society . C (Applied Statistics) . 18 . 1 . 54–64 . 10.2307/2346439 . 2346439.
  31. Päivinen . Niina . 1 May 2005 . Clustering with a minimum spanning tree of scale-free-like structure . Pattern Recognition Letters . 26 . 7 . 921–930 . 2005PaReL..26..921P . 10.1016/j.patrec.2004.09.039.
  32. Xu . Y. . Olman . V. . Xu . D. . 1 April 2002 . Clustering gene expression data using a graph-theoretic approach: an application of minimum spanning trees . Bioinformatics . 18 . 4 . 536–545 . 10.1093/bioinformatics/18.4.536 . 12016051 . free.
  33. Dalal . Yogen K. . Metcalfe . Robert M. . 1 December 1978 . Reverse path forwarding of broadcast packets . Communications of the ACM . 21 . 12 . 1040–1048 . 10.1145/359657.359665 . 5638057 . free.
  34. Ma . B. . Hero . A. . Gorman . J. . Michel . O. . 2000 . Image registration with minimum spanning tree algorithm . International Conference on Image Processing . 1 . 481–484 . 10.1109/ICIP.2000.901000 . https://ghostarchive.org/archive/20221009/http://web.eecs.umich.edu/~hero/Preprints/MinimumSpanningTree.pdf . 2022-10-09 . live.
  35. P. Felzenszwalb, D. Huttenlocher: Efficient Graph-Based Image Segmentation. IJCV 59(2) (September 2004)
  36. Suk . Minsoo . Song . Ohyoung . 1 June 1984 . Curvilinear feature extraction using minimum spanning trees . Computer Vision, Graphics, and Image Processing . 26 . 3 . 400–411 . 10.1016/0734-189X(84)90221-4.
  37. Book: Tapia . Ernesto . Graphics Recognition. Recent Advances and Perspectives . Rojas . Raúl . Springer-Verlag . 2004 . 978-3540224785 . Lecture Notes in Computer Science . 3088 . Berlin Heidelberg . 329–340 . Recognition of On-line Handwritten Mathematical Expressions Using a Minimum Spanning Tree Construction and Symbol Dominance . http://page.mi.fu-berlin.de/rojas/2003/grec03.pdf . https://ghostarchive.org/archive/20221009/http://page.mi.fu-berlin.de/rojas/2003/grec03.pdf . 2022-10-09 . live.
  38. Ohlsson . H. . 2004 . Implementation of low complexity FIR filters using a minimum spanning tree . 12th IEEE Mediterranean Electrotechnical Conference (MELECON 2004) . 1 . 261–264 . 10.1109/MELCON.2004.1346826.
  39. Assunção . R. M. . M. C. Neves . G. Câmara . C. Da Costa Freitas . 2006 . Efficient regionalization techniques for socio-economic geographical units using minimum spanning trees . International Journal of Geographical Information Science . 20 . 7 . 797–811 . 10.1080/13658810600665111 . 2006IJGIS..20..797A . 2530748.
  40. Devillers . J. . Dore . J.C. . 1 April 1989 . Heuristic potency of the minimum spanning tree (MST) method in toxicology . Ecotoxicology and Environmental Safety . 17 . 2 . 227–235 . 10.1016/0147-6513(89)90042-0 . 2737116. 1989EcoES..17..227D .
  41. Mori . H. . Tsuzuki . S. . 1 May 1991 . A fast method for topological observability analysis using a minimum spanning tree technique . IEEE Transactions on Power Systems . 6 . 2 . 491–500 . 1991ITPSy...6..491M . 10.1109/59.76691.
  42. Filliben . James J. . Kafadar . Karen . Karen Kafadar . Shier . Douglas R. . 1 January 1983 . Testing for homogeneity of two-dimensional surfaces . Mathematical Modelling . 4 . 2 . 167–189 . 10.1016/0270-0255(83)90026-X .
  43. Mantegna, R. N. (1999). Hierarchical structure in financial markets. The European Physical Journal B-Condensed Matter and Complex Systems, 11(1), 193–197.
  44. Djauhari, M., & Gan, S. (2015). Optimality problem of network topology in stocks market analysis. Physica A: Statistical Mechanics and Its Applications, 419, 108–114.