Content deleted Content added
Rescuing 1 sources and tagging 0 as dead.) #IABot (v2.0.9.5 |
|||
(21 intermediate revisions by 18 users not shown) | |||
Line 6:
If <math>G</math> is [[Glossary_of_graph_theory_terms#unweighted_graph|edge-unweighted]] every spanning tree possesses the same number of edges and thus the same weight. In the [[Glossary_of_graph_theory_terms#weighted_graph|edge-weighted]] case, the spanning tree, the sum of the weights of the edges of which is lowest among all spanning trees of <math>G</math>, is called a [[minimum spanning tree]] (MST). It is not necessarily unique. More generally, graphs that are not necessarily [[Glossary_of_graph_theory_terms#connected|connected]] have minimum spanning [[Tree_(graph_theory)#Forest|forests]], which consist of a [[Union_(set_theory)|union]] of MSTs for each [[Connected_component_(graph_theory)|connected component]].
As finding MSTs is a widespread problem in graph theory, there exist many [[Sequential_algorithm|sequential algorithms]] for solving it. Among them are [[Prim's algorithm|Prim's]], [[Kruskal's algorithm|Kruskal's]] and [[Borůvka's algorithm|Borůvka's]] algorithms, each utilising different properties of MSTs. They all operate in a similar fashion - a subset of <math>E</math> is iteratively grown until a valid MST has been discovered. However, as practical problems are often quite large (road networks sometimes have billions of edges), [[Time_complexity|performance]] is a key factor. One option of improving it is by [[Parallel algorithm|parallelising]] known [[Minimum_spanning_tree#Algorithms|MST algorithms]].<ref>{{cite book |last1=Sanders |last2=Dietzfelbinger |last3=Martin |last4=Mehlhorn |last5=Kurt |last6=Peter |title=Algorithmen und Datenstrukturen Die Grundwerkzeuge |publisher=Springer Vieweg |isbn=978-3-642-05472-3|date=2014-06-10 }}</ref>
== Prim's algorithm ==
This algorithm utilises the [[Minimum_spanning_tree#Cut_property|cut-property]] of MSTs. A simple high-level pseudocode implementation is provided
Each edge is observed exactly twice - namely when examining each of its endpoints. Each vertex is examined exactly once for a total of <math>O(n + m)</math> operations aside from the selection of the lightest edge at each loop iteration. This selection is often performed using a [[priority queue]] (PQ). For each edge at most one decreaseKey operation ([[Amortized_analysis|amortised]] in <math>O(1)</math>) is performed and each loop iteration performs one deleteMin operation (<math>O(\log n)</math>). Thus using [[Fibonacci heap|Fibonacci heaps]] the total runtime of Prim's algorithm is [[Asymptotic_computational_complexity|asymptotically]] in <math>O(m + n \log n)</math>.
Line 24:
It is important to note that the loop is inherently sequential and can not be properly parallelised. This is the case, since the lightest edge with one endpoint in <math>S</math> and on in <math>V \setminus S</math> might change with the addition of edges to <math>T</math>. Thus no two selections of a lightest edge can be performed at the same time. However, there do exist some attempts at [[Prim%27s algorithm#Parallel Algorithm|parallelisation]].
One possible idea is to use <math>O(n)</math> processors to support PQ access in <math>O(1)</math> on an [[Parallel random-access machine|EREW-PRAM]] machine,<ref>{{citation
| last1 = Brodal
|
| last2 = Träff
| first2 = Jesper Larsson
Line 38:
| pages = 4–21| doi = 10.1006/jpdc.1998.1425
| citeseerx = 10.1.1.48.3272
}}</ref>
== Kruskal's algorithm ==
Line 44:
Kruskal's MST algorithm utilises the [[Minimum_spanning_tree#Cycle_property|cycle property]] of MSTs. A high-level pseudocode representation is provided below.
<math>T \gets T \cup \{(u,v)\}</math>
The subtrees of <math>T</math> are stored in [[Disjoint-set data structure|union-find]] data structures, which is why checking whether or not two vertices are in the same subtree is possible in amortised <math>O(\alpha(m, n))</math> where <math>\alpha(m, n)</math> is the inverse [[
=== Approach 1: Parallelising the sorting step ===
Line 68:
| title = The filter-kruskal minimum spanning tree algorithm
| journal = Proceedings of the Eleventh Workshop on Algorithm Engineering and Experiments (ALENEX). Society for Industrial and Applied Mathematics
| pages = 52–61| citeseerx = 10.1.1.218.2574
Filter-Kruskal is better suited for parallelisation, since sorting, partitioning and filtering have intuitively easy parallelisations where the edges are simply divided between the cores.
Line 103 ⟶ 104:
The main idea behind Borůvka's algorithm is [[edge contraction]]. An edge <math>\{u, v\}</math> is contracted by first removing <math>v</math> from the graph and then redirecting every edge <math>\{w, v\} \in E</math> to <math>\{w, u\}</math>. These new edges retain their old edge weights. If the goal is not just to determine the weight of an MST but also which edges it comprises, it must be noted between which pairs of vertices an edge was contracted. A high-level pseudocode representation is presented below.
It is possible that contractions lead to multiple edges between a pair of vertices. The intuitive way of choosing the lightest of them is not possible in <math>O(m)</math>. However, if all contractions that share a vertex are performed in parallel this is doable. The recursion stops when there is only a single vertex remaining, which means the algorithm needs at most <math>\log n</math> iterations, leading to a total runtime in <math>O(m \log n)</math>.
Line 117 ⟶ 118:
=== Parallelisation ===
One possible parallelisation of this algorithm<ref>{{cite web |last1=Sanders |first1=Peter |title=Parallel Algorithms script |url=https://algo2.iti.kit.edu/sanders/courses/paralg18/skript.pdf |website=Parallel Algorithms KIT Homepage |
The MST then consists of all the found lightest edges.
Line 134 ⟶ 135:
Now each processor determines the lightest edge incident to each of its vertices.
Here the issue arises some vertices are handled by more than one processor. A possible solution to this is that every processor has its own <math>prev</math> array which is later combined with those of the others using a reduction. Each processor has at most two vertices that are also handled by other processors and each reduction is in <math>O(\log p)</math>. Thus the total runtime of this step is in <math>O(\frac{m}{p} + \log n + \log p)</math>.
Line 147 ⟶ 148:
Observe the graph that consists solely of edges collected in the previous step. These edges are directed away from the vertex to which they are the lightest incident edge. The resulting graph decomposes into multiple weakly connected components. The goal of this step is to assign to each vertex the component of which it is a part. Note that every vertex has exactly one outgoing edge and therefore each component is a pseudotree - a tree with a single extra edge that runs in parallel to the lightest edge in the component but in the opposite direction. The following code mutates this extra edge into a loop:
Now every [[Glossary_of_graph_theory_terms#weakly_connected|weakly connected]] component is a directed tree where the root has a [[Glossary_of_graph_theory_terms#loop|loop]]. This root is chosen as the representative of each component. The following code uses doubling to assign each vertex its representative:
Now every subgraph is a [[Glossary_of_graph_theory_terms#star|star]]. With some advanced techniques this step needs <math>O(\frac{n}{p} + \log n)</math> time.
Line 164 ⟶ 165:
In this step each subgraph is contracted to a single vertex.
Finding the bijective function is possible in <math>O(\frac{n}{p} + \log p)</math> using a prefix sum. As we now have a new set of vertices and edges the adjacency array must be
=== Complexity ===
Each iteration now needs <math>O(\frac{m}{p} + \log n)</math> time and just like in the sequential case there are <math>\log n</math>
== Further algorithms ==
Line 192 ⟶ 193:
| volume = 48
| year = 2001| citeseerx = 10.1.1.32.1554
| s2cid = 1778676
}}</ref><ref>{{citation
| last1 = Pettie | first1 = Seth
Line 203 ⟶ 205:
| volume = 31
| year = 2002| url = http://www.eecs.umich.edu/~pettie/papers/sicomp-randmst.pdf
}}</ref>
| last1 = Bader
| first1 = David A.
| author1-link = David
| last2 = Cong
| first2 = Guojing
Line 215 ⟶ 217:
| title = Fast shared-memory algorithms for computing the minimum spanning forest of sparse graphs
| volume = 66
| year = 2006}}</ref>
Another challenge is the External Memory model - there is a proposed algorithm due to Dementiev et al. that is claimed to be only two to five times slower than an algorithm that only makes use of internal memory<ref>{{citation
| last1 = Dementiev
| first1 = Roman | last2 = Sanders
| first2 = Peter | last3 = Schultes
| first3 = Dominik | last4 = Sibeyn
| first4 = Jop F. | contribution = Engineering an external memory minimum spanning tree algorithm
| pages = 195–208
| title = Proc. IFIP 18th World Computer Congress, TC1 3rd International Conference on Theoretical Computer Science (TCS2004)
| url = http://algo2.iti.kit.edu/dementiev/files/emst.pdf
| year = 2004
| access-date = 2019-05-24
| archive-date = 2011-08-09
| archive-url = https://web.archive.org/web/20110809075049/http://algo2.iti.kit.edu/dementiev/files/emst.pdf
| url-status = dead
}}.</ref>
== References ==
|