830 likes | 1.26k Views
Minimum Spanning Trees. Gallagher-Humblet-Spira (GHS) Algorithm. Weighted Graph G=(V,E), |V|=n, |E|=m. Spanning tree. Any tree T=(V,E’) (connected acyclic graph) spanning all the nodes of G. (MST). Minimum-weight spanning tree. A spanning tree s.t. the sum of its weights is minimized:.
E N D
Minimum Spanning Trees Gallagher-Humblet-Spira (GHS) Algorithm
Spanning tree Any tree T=(V,E’) (connected acyclic graph) spanning all the nodes of G
(MST) Minimum-weight spanning tree A spanning tree s.t. the sum of its weights is minimized: For MST : is minimized
Spanning tree fragment: Any (connected) sub-tree of a MST
Minimum weight outgoing edge (MWOE) An edge adjacent to the fragment with smallest weight and that does not create a cycle
Two important properties for building MST The union of a fragment and any of its MWOE is a fragment of some MST (so called blue rule). Property 1: Property 2: If the weights are distinct then the MST is unique
The union of a fragment FT and any of its MWOE is a fragment of some MST. Property 1: Proof: • Distinguish two cases: • the MWOE belongs to T • the MWOE does not belong to T • In both cases, we can prove the claim.
Case 1: Fragment MWOE MST T
Trivially, if then is a fragment Fragment MWOE MST T
Case 2: Fragment MWOE MST T
If then add to and remove Fragment MST T
Fragment Obtain T’ and since But w(T’) w(T), since T is an MST w(T’)=w(T), i.e., T’ is an MST
Fragment MST T’ thus is a fragment of T’ END OF PROOF
Property 2: If the weights are distinct then the MST is unique Proof: Basic Idea: Suppose there are two MSTs Then there is another MST of smaller weight contradiction!
Take the smallest weight edge not in intersection
Cycle in RED MST e’: any red edge not in BLUE MST ( since blue tree is acyclic)
Cycle in RED MST Since is not in the intersection, (the weight of is the smallest)
Cycle in RED MST Delete and add in RED MST we obtain a new tree with smaller weight contradiction! END OF PROOF
Prim’s Algorithm (sequential version) Start with a node as an initial fragment Repeat Augment fragment with a MWOE Until no other edge can be added to
Fragment MWOE
Fragment MWOE
Fragment MWOE
Theorem: Prim’s algorithm gives an MST Proof: Use Property 1 repeatedly END OF PROOF
Prim’s algorithm (distributed version) • Works by repeatedly applying the blue rule to a single fragment, to yield the MST for G • Works with both asynchronousand synchronous non-anonymous, uniform models (and also with non-distinct weights) • Algorithm (asynchronous high-level version): • Let vertex r be the root as well as the first fragment • REPEAT • r broadcasts a message on the current fragment to search for the MWOE of the fragment (each vertex in the fragment searches for its local (i.e., adjacent) MWOE) • convergecast (i.e., reverse broadcast towards r) the MWOE of the appended subfragment (i.e., the minimum of the local MWOEs of itself and its descendents) • the MWOE of the fragment is then selected by r and added to the fragment, by sending an add-edge message on the appropriate path • then, the root and nodes adjacent to that just entered in the fragment are notified the edge has been added • UNTIL there is only one fragment left
Local description of asynchronous Prim • Each processor stores: • The state of any of its incident edges, which can be either of {basic, branch, reject} • Its own state, which can be either {in, out} • Local MWOE • MWOE for each branch-down edge • Parent channel (route towards the root) • MWOE channel (route towards the MWOE of its appended subfragment)
Type of messages in asynchronous Prim • Search MWOE: coordination message initiated by the root • Test: check the status of a basic edge • Reject, Accept: response to Test • Report(weight): report to the parent node the MWOE of the appended subfragment • Add edge: say to the fragment node adjacent to the fragment’s MWOE to add it • Connect: perform the union of the found MWOE to the fragment (this changes the status of the corresponding end-node from out to in) • Connected: notify the root and adjacent nodes that connection has taken place Message complexity = O(n2)
Synchronous Prim • It will work in O(n2) rounds…think to it by yourself…
Kruskal’s Algorithm (sequential version) Initially, each node is a fragment Repeat • Find the smallest MWOE e of all fragments • Merge the two fragments adjacent to e Until there is only one fragment left
Theorem: Kruskal’s algorithm gives an MST Proof: Use Property 1, and observe that no cycle is created. END OF PROOF
Synchronous GHS Algorithm • Distributed version of Kruskal’s Algorithm • Works by repeatedly applying the blue rule to multiple fragments • Works with non-uniform models, distinct weights, synchronous start Initially, each node is a fragment (Synchronous Phase) Repeat in parallel: • Each fragment – coordinated by a fragment rootnode - finds its MWOE • Merge fragments adjacent to MWOE’s Until there is only one fragment left
Local description of syncr. GHS • Each processor stores: • The state of any of its incident edges, which can be either of {basic, branch, reject} • Identity of its fragment (the weigth of a core edge – for single-node fragments, the proc. id ) • Local MWOE • MWOE for each branching-out edge • Parent channel (route towards the root) • MWOE channel (route towards the MWOE of its appended subfragment)
Type of messages • New fragment(identity): coordination message sent by the root at the end of a phase • Test(identity): for checking the status of a basic edge • Reject, Accept: response to Test • Report(weight): for reporting to the parent node the MWOE of the appended subfragment • Merge: sent by the root to the node incident to the MWOE to activate union of fragments • Connect(My Id): sent by the node incident to the MWOE to perform the union
Phase 0: Initially, every node is a fragment… … and every node is a root of a fragment
Phase 1: Merge the nodes and select a new root Root Root Root Root Symmetric MWOE Asymmetric MWOE The new root is adjacent to a symmetric MWOE
Rule for selecting a new root in a fragment Fragment 2 Fragment 1 root root MWOE Merging 2 fragments
Rule for selecting a new root in a fragment Merged Fragment root Higher ID Node on MWOE (non-anonymity)
Rule for selecting a new root in a fragment root root root root root root root Merging more than 2 fragments