# 1 Minimum Spanning Trees Gallagher-Humblet-Spira (GHS) Algorithm.

## Presentation on theme: "1 Minimum Spanning Trees Gallagher-Humblet-Spira (GHS) Algorithm."— Presentation transcript:

1 Minimum Spanning Trees Gallagher-Humblet-Spira (GHS) Algorithm

2 Weighted Graph

3 Minimum weight spanning tree The sum of the weights is minimized (MST) For MST :is minimized

4 Spanning tree fragment: Any (connected) sub-tree of a MST

5 Minimum weight outgoing edge (MWOE) The adjacent edge to the fragment with the smallest weight that does not create a cycle

6 Property 1: The union of a fragment and its MWOE is a fragment (so called blue rule). Property 2: If the weights are unique then the MST is unique Two important properties for building MST

7 Property 1: The union of a fragment and its MWOE is a fragment Proof: Basic idea: we distinguish two cases: 1.the MWOE belongs to the MST 2.the MWOE does not belong to the MST In both cases, we can prove the claim.

8 MWOE Fragment MST T Case 1:

9 MWOE Fragment MST T Trivially, if then is a fragment

10 MWOE Fragment MST T Case 2:

11 MWOE Fragment MST T If then add toand remove

12 Fragment Since otherwise, wouldn’t be MST Obtain T’ and since

13 Fragment thus is a fragment of T’ END OF PROOF MST T’

14 Property 2: If the weights are unique then the MST is unique Proof:Basic Idea: Suppose there are two MST Then there is another MST of smaller weight Contradiction!

15 Suppose there are two MST

16 Take the smallest weight edge not in intersection

17 Cycle in RED MST

18 Cycle in RED MST e’: any red edge not in BLUE MST (  since blue tree is acyclic)

19 Cycle in RED MST Since is not in intersection, (the weight of is the smallest)

20 Cycle in RED MST Delete and add in RED MST We obtain a new tree with smaller weight Contradiction! END OF PROOF

21 Prim’s Algorithm (sequential version) Start with a node as an initial fragment Augment fragment with the MWOE Repeat Until no other edge can be added to

22 Fragment

23 Fragment MWOE

24 Fragment MWOE

25 Fragment MWOE

26 Fragment

27 Theorem:Prim’s algorithm gives an MST Proof: Use Property 1 repeatedly END OF PROOF

28 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 uniform models (and also with non-unique weights) Algorithm: 1.let vertex r be the root as well as the first fragment 2.(synchronous case) 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” MWOE) 3.convergecast (reverse broadcast) the local MWOE’s (each vertex sends the minimum it has seen) towards r 4.the MWOE is then selected by r and added to the fragment, by sending a connect message on the right path. Complexity: (time =) message = O(n 2 )

29 Local description of syncr. Prim Each processor stores: 1.The state of any of its incident edges, which can be either of {basic, branch, reject} 2.Its own state, which can be either {in, out} 3.“Local” MWOE 4.Parent channel (route towards the root) 5.MWOE channel (route towards the MWOE of its appended subfragment) Type of messages: 1.(synchronous case) Search MWOE: coordination message 2.Test: for checking the status of an edge 3.Reject, Accept: response to Test 4.Report(weight): for finding the MWOE 5.Add edge: to add the fragment’s MWOE 6.Connect: to perform the union of the MWOE to the fragment (this changes status of a node from out to in).

30 Kruskal’s Algorithm (sequential version) Initially, each node is a fragment Find the smallest MWOE of all fragments Merge the two fragments adjacent to Repeat Until there is one fragment

31 Initially, every node is a fragment

32 Find the smallest MWOE

33 Merge the two fragments

34 Find the smallest MWOE

35 Merge the two fragments

36 Resulting MST

37 Theorem:Kruskal’s algorithm gives an MST Proof: Use Property 1, and observe that no cycle is created. END OF PROOF

38 Synchronous GHS Algorithm Distributed version of Kruskal’s Algorithm Works by repeatedly applying the blue rule to multiple fragments, to yield the MST for G Works with non-uniform models, unique weights Initially, each node is a fragment Each fragment finds its MWOE Merge fragments adjacent to MWOE’s Repeat in parallel: Until there is one fragment (Synchronous Phase)

39 Local description of syncr. GHS Each processor stores: 1.The state of any of its incident edges, which can be either of {basic, branch, reject} 2.Identity of its fragment (the weigth of an edge) 3.“Local” MWOE 4.Parent channel (route towards the root) 5.MWOE channel (route towards the MWOE of its appended subfragment)

40 Type of messages 1.New fragment(identity): coordination message sent at the end of a phase 2.Test(identity): for checking the status of an edge 3.Reject, Accept: response to Test 4.Report(weight): for finding the MWOE 5.Merge: send by the root to the node incident to the MWOE to activate union of fragments 6.Connect(My Id): to perform the union

41 Phase 0: Initially, every node is a fragment… … and every node is a root of a fragment

42 Phase 1: Find the MWOE for each fragment

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

44 Rules for selecting a new root in a fragment Fragment 1 Fragment 2 root MWOE Merging 2 fragments

45 Merged Fragment root Higher ID Node on MWOE Rules for selecting a Root in fragment

46 Rules for selecting a Root in fragment Merging more than 2 fragments root

47 Rules for selecting a Root in fragment Higher ID Node on symmetric MWOE Merged Fragment Root asymmetric

48 In merged fragments there is exactly one symmetric MWOE Remark: Impossible Creates a fragment with two MWOE zero two Creates a fragment with no MWOE

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

50 And so, at the end of a phase each fragment has its own unique identity. Root End of phase 1

51 Phase 2: Find the MWOE for each fragment

52 Phase 2: Merge the fragments Root

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

54 Phase 3: Find the MWOE for each fragment

55 Phase 3: Merge the fragments Root

56 Phase 3: New fragment FINAL MST

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

58 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

59 Then it knows its “local” MWOE MWOE

60 Then each node sends a Report with its local MWOE to the fragment root with convergecast (the global minimum survives in propagation) MWOE

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

62 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 asyncronous… But each fragment can have at most n nodes, has height at most n, and each node has at most n 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!

63 Smallest Fragment size (#nodes) Phase Complexity

64 Maximum # phases: Maximum possible fragment size Number of nodes Algorithm Time Complexity  Total time = Phase time #phases =

65 Thr: Synchronous GHS requires O(|E|+n logn) msgs. Proof: We have the following messages: 1.Test-Reject msgs: at most 2 for each edge; 2.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. Algorithm Message Complexity END OF PROOF

66 Asynchronous Version of GHS Algorithm Simulates the synchronous version Works with uniform models, unique weights 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

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

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

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

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

71 MWOE Fragment If then joins with (cost of merging proportional to ) Join

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

73 Fragment MWOE If then waits until previous rules apply (this is obtained by letting F 2 not replying to Test messages from F 1 ) Remark: the cost of joining would be proportional to F 1 for every small joined fragment, and this would be inefficient!!

74 Lemma: A fragment of level L contains at least 2 L 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: 1.F was obtained by joining two fragments of level k-1, each containing at least 2 k-1 nodes by inductive hypothesis  F contains at least 2 k-1 + 2 k-1 = 2 k nodes; 2.F was obtained after absorbing another fragment F’ of level<k  F apply recursively to F\F’, until 1. applies. Algorithm Message Complexity END OF PROOF

75 Thr: Asynchronous GHS requires O(|E|+n logn) msgs. Proof: We have the following messages: 1.Connect msgs: at most 2 for each edge; 2.Test-Reject msgs: at most 2 for each edge; 3.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. Algorithm Message Complexity (2) END OF PROOF

76 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)

Similar presentations