# Minimum Spanning Trees

## Presentation on theme: "Minimum Spanning Trees"ā Presentation transcript:

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

Minimum-weight spanning tree
(MST) 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
Property 1: The union of a fragment and any of its MWOE is a fragment of some MST (so called blue rule). Property 2: If the weights are distinct then the MST is unique

Property 1: The union of a fragment FļT and any of its MWOE is a fragment of some MST. 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
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!

Suppose there are two MSTs

Take the smallest weight edge
not in intersection

Cycle in RED MST

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)

Delete and add in RED MST
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

Fragment MWOE

Fragment MWOE

Fragment MWOE

Fragment

Primās algorithm gives an MST
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 asynchronous and 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

Initially, every node is a fragment

Find the smallest MWOE

Merge the two fragments

Find the smallest MWOE

Merge the two fragments

Merge the two fragments

Resulting MST

Kruskalās algorithm gives an MST
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 Repeat in parallel: (Synchronous Phase) Each fragment ā coordinated by a fragment root node - 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: Find the MWOE for each node

Root Root Root Root Phase 1: Merge the nodes and select a new root
Symmetric MWOE Asymmetric MWOE The new root is adjacent to a symmetric MWOE

Rule for selecting a new root in a fragment
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
Merging more than 2 fragments

Rule for selecting a new root in a fragment
Merged Fragment Root Higher ID Node on symmetric MWOE asymmetric

Remark: ļ³ two zero Impossible Impossible In merged fragments there is
exactly one symmetric MWOE (n-1 edges vs n arrows) ļ³ two zero Impossible Impossible Creates a fragment with two MWOEs Creates a fragment with no MWOE

is the identity of the new fragment
After merging has taken place, the new root broadcasts New fragment(w(e)) to the new fragment, and afterwards a new phase starts e is the symmetric MWOE of the merged fragments is the identity of the new fragment

In our example, at the end of phase 1 each fragment has its new identity.
Root Root Root Root End of phase 1

At the beginning of each new phase each
node in fragment finds its MWOE MWOE MWOE MWOE MWOE

To discover its own MWOE, each node sends a Test message containing its identity over its basic edge of min weight, until it receives an Accept test(ļ”) accept test(ļ”) reject

Then it knows its local MWOE

Then each node sends a Report with the MWOE of the appended subfragment to the root with convergecast (the global minimum survives in propagation) MWOE MWOE MWOE MWOE

The root selects the minimum MWOE and sends along the appropriate path a Merge message, which will become a Connect message at the proper node MWOE

Phase 2 of our example: After receiving the new identity, find again the MWOE for each fragment

Phase 2: Merge the fragments
Root Root

At the end of phase 2 each fragment
has its own unique identity. Root Root End of phase 2

Phase 3: Find the MWOE for each fragment

Phase 3: Merge the fragments
Root

Phase 3: New fragment FINAL MST

Correctness To guarantee correctness, phases must be syncronized
But at the beginning of a phase, each fragment can have a different number of nodes, and thus the MWOE selection is potentially asynchronousā¦ But each fragment can have at most n nodes, has height at most n-1, and each node has at most n-1 incident edgesā¦ So, the MWOE selection requires at most 3n rounds, and the Merge message requires at most n rounds. Then, the Connect message must be sent at round 4n+1 of a phase, and so at round 4n+2 a node knows whether it is a new root Finally, the New fragment message will require at most n rounds. ļ A fixed number of 5n+2 total rounds can be used to complete each phase (in some rounds nodes do nothingā¦)!

Complexity Smallest Fragment size (#nodes) Phase

ļ Algorithm Time Complexity Maximum possible fragment size
Number of nodes Maximum # phases: ļ Total time = Phase time ā¢ #phases =

Algorithm Message Complexity
Thr: Synchronous GHS requires O(m+n logn) msgs. Proof: We have the following messages: Test-Reject msgs: at most 2 for each edge; Each node sends/receives at most a single: New Fragment, Test-Accept, Report, Merge, Connect message for each phase. Since from previous lemma we have at most log n phases, the claim follows. END OF PROOF

Asynchronous Version of GHS Algorithm
Simulates the synchronous version Works with uniform models, distinct weights, asynchronous start Every fragment F has a level L(F)ā„0: at the beginning, each node is a fragment of level 0 Two types of merges: absorption and join

Local description of asyncr. GHS
Like the synchronous, but: Identity of a fragment is now given by an edge weight plus the level of the fragment; A node has its own status, which can be either of {sleeping, finding, found}

Type of messages Like the synchronous, but now: New fragment(weight,level,status): coordination message sent just after a merge Test(weight,level): to test an edge Connect(weight,level): to perform the union

Absorption Fragment Fragment MWOE If then is absorbed by (cost of merging proportional to )

The combined level is New fragment MWOE and a New fragment(weight,level,status) message is broadcasted to nodes of F1 by the node of F2 on which the merge took place

Join Fragment Fragment MWOE If and F1 and F2 have a symmetric MWOE, then F1 joins with F2 (cost of merging proportional to )

The combined level is New fragment MWOE and a New fragment(weight,L(F2)+1,finding) message is broadcasted to all nodes of F1 and F2, where weigth is that of the edge on which the merge took place

Remark: a joining requires that fragment levels are equalā¦how to control this?
ļ If L(F1)>L(F2), then F1 waits until L(F1)= L(F2) (this is obtained by letting F2 not replying to Test messages from F1 ) Fragment Fragment Test

Algorithm Message Complexity
Lemma: A fragment of level L contains at least 2L nodes. Proof: By induction. For L=0 is trivial. Assume it is true up to L=k-1, and let F be of level k. But then, either: F was obtained by joining two fragments of level k-1, each containing at least 2k-1 nodes by inductive hypothesis ļ F contains at least 2k-1 + 2k-1 = 2k nodes; F was obtained after absorbing another fragment Fā of level<k ļ apply recursively to F\Fā, until case (1) applies. END OF PROOF

Algorithm Message Complexity (2)
Thr: Asynchronous GHS requires O(m+n logn) msgs. Proof: We have the following messages: Connect msgs: at most 2 for each edge; Test-Reject msgs: at most 2 for each edge; Each node sends/receives at most a single: New Fragment, Test-Accept, Merge, Report message each time the level of its fragment increases; and since from previous lemma each node can change at most log n levels, the claim follows. END OF PROOF

Homework Execute asynchronous GHS on the following graph:
assuming that system is pseudosynchronous: Start from 1 and 5, and messages sent from odd (resp., even) nodes are received after 1 (resp., 2) round(s)