Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

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

2 2 Weighted Graph G=(V,E), |V|=n, |E|=m

3 3 Spanning tree Any tree T=(V,E’) (connected acyclic graph) spanning all the nodes of G

4 4 Minimum-weight spanning tree A spanning tree s.t. the sum of its weights is minimized: (MST) For MST :is minimized

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

6 6 Minimum weight outgoing edge (MWOE) of a fragment An edge adjacent to the fragment with smallest weight and that does not create a cycle in the fragment Fragment

7 7 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 edge weights are distinct then the MST is unique Two important properties for building MST

8 8 Property 1: The union of a fragment F  T and any of its MWOE is a fragment of some MST. Proof: Distinguish two cases: 1.the MWOE belongs to T 2.the MWOE does not belong to T In both cases, we can prove the claim.

9 9 MWOE Fragment MST T Case 1:

10 10 MWOE Fragment MST T Trivially, if then is a fragment of T

11 11 MWOE Fragment MST T Case 2:

12 12 Fragment MST T If then add toand remove x (an edge of T forming a cycle with x and exiting from F)

13 13 Fragment But w(T ’)  w(T), since T is an MST  w(T ’)=w(T), i.e., T ’ is an MST Obtain T ‘ and since

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

15 15 Property 2: If the edge 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!

16 16 Suppose there are two MSTs

17 17 Take the smallest-weight edge not in the intersection, and assume w.l.o.g. it is blue

18 18 Cycle in RED MST

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

20 20 Cycle in RED MST Since is not in the intersection, (weights are distinct and the weight of e is the smallest among edges not in the intersection)

21 21 Cycle in RED MST Delete and add in RED MST  we obtain a new tree with smaller weight  contradiction! END OF PROOF

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

23 23 Fragment

24 24 Fragment MWOE

25 25 Fragment MWOE

26 26 Fragment MWOE

27 27 Fragment

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

29 29 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 (notice that r may be provided by a leader election algo) 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 finally, the root is notified the edge has been added UNTIL there is only one fragment left

30 30 Local description of asynchronous Prim Each processor stores: 1.The status of any of its incident edges, which can be either of {basic, branch, reject} 2.Its own status, which can be either {in, out} 3.Parent channel (route towards the root) 4.Children channels 5.Local MWOE 6.MWOE for each children channel 7.MWOE channel (route towards the MWOE of its appended subfragment)

31 31 Type of messages in asynchronous Prim 1.Search_MWOE: coordination message initiated by the root 2.Test: check the status of a basic edge 3.Reject, Accept: response to Test 4.Report(weight): report to the parent node the MWOE of the appended subfragment 5.Add_edge: say to the fragment node adjacent to the fragment’s MWOE to add it 6.Connect: perform the union of the found MWOE to the fragment (this changes the status of the corresponding end-node from out to in) 7.Connected: notify the root that connection has taken place Message complexity = O(n 2 )

32 32 Sample execution: The root sends a Search_MWOE message, and the message floods along the fragment, so that each node in fragment starts looking for its local MWOE

33 33 To discover its local MWOE, each node sends a Test message over its basic edge of min weight, until it receives an Accept Test Accept Test Reject

34 34 Then it knows its local MWOE MWOE

35 35 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

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

37 37 Finally, a Connected message is sent back along the appropriate path to the root, which then resumes the Search_MWOE procedure

38 38 Synchronous Prim It will work in O(n 2 ) rounds…think to it by yourself…

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

40 40 Initially, every node is a fragment

41 41 Find the smallest MWOE

42 42 Merge the two fragments

43 43 Find the smallest MWOE

44 44 Merge the two fragments

45 45 Merge the two fragments

46 46 Resulting MST

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

48 48 Synchronous GHS Algorithm Distributed version of Kruskal’s Algorithm Works by repeatedly applying the blue rule to multiple fragments Works with non-uniform model, distinct weights, synchronous start Initially, each node is a fragment Each fragment – coordinated by a fragment root node - finds its MWOE Merge fragments adjacent to MWOE’s Repeat in parallel: Until there is only one fragment left (Synchronous Phase)

49 49 Local description of syncr. GHS Each processor stores: 1.The status of any of its incident edges, which can be either of {basic, branch, reject} 2.Identity of its fragment (the weigth of a core edge, i.e., an edge of the fragment adjacent to the root node – for single-node fragments, the proc. id ) 3.Root channel (route towards the root) 4.Branching-out channels 5.Local MWOE 6.MWOE for each branching-out edge 7.MWOE channel (route towards the MWOE of its appended subfragment)

50 50 Type of messages 1.New_fragment(identity): coordination message sent by the root at the end of a phase 2.Test(identity): for checking the status of a basic edge 3.Reject, Accept: response to Test 4.Report(weight): for reporting to the parent node the MWOE of the appended subfragment 5.Merge: sent by the root to the node incident to the MWOE to activate union of fragments 6.Connect(My Id): sent by the node incident to the MWOE to perform the union

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

52 52 Phase 1: Find the MWOE for each node

53 53 Phase 1: Merge the nodes and select a new root Root Asymmetric MWOE (arrow denotes the direction of the Connect message) Symmetric MWOE The new root is adjacent to a symmetric MWOE

54 54 Rule for selecting a new root in a fragment Fragment 1 Fragment 2 root MWOE Case 1: Merging 2 fragments

55 55 Merged Fragment root Higher ID Node on MWOE (non-anonymity) Rule for selecting a new root in a fragment Case 1: Merging 2 fragments

56 56 Rule for selecting a new root in a fragment root Case 2: Merging more than 2 fragments

57 57 Rule for selecting a new root in a fragment Higher ID Node on symmetric MWOE Merged Fragment Root asymmetric Case 2: Merging more than 2 fragments

58 Correctness: While merging fragments, no cycles are created. Proof: Recall that edge weights are distinct. Then: Merging more than 2 fragments Impossible: either F 1 or F 2 is choosing a wrong MWOE! Merging 2 fragments FiFi FjFj Impossible: let (F i,F j ) be the max-weight edge on the cycle; then either F i or F j is choosing a wrong MWOE!

59 59 Correctness: In merged fragments there is exactly one symmetric MWOE. Proof: Recall that each merging fragment has exactly 1 MWOE. Then, since no cycles are created, we have that if k fragments are merged, k-1 edges with k arrows are used: Impossible: Requires (at least) a fragment with two MWOEs More than 1 symmetric edge Impossible: Requires a fragment with no MWOE No symmetric edges

60 60 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

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

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

63 63 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

64 64 Then it knows its local MWOE MWOE

65 65 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

66 66 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

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

68 68 Phase 2: Merge the fragments Root

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

70 70 Phase 3: Find the MWOE for each fragment

71 71 Phase 3: Merge the fragments Root

72 72 Phase 3: New fragment FINAL MST

73 73 Syncronicity 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…)!

74 74 Smallest Fragment size (#nodes) Phase Complexity

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

76 76 Thr: Synchronous GHS requires O(m+n log n) 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 we have at most log n phases, the claim follows. Algorithm Message Complexity END OF PROOF

77 77 Asynchronous Version of GHS Algorithm Simulates the synchronous version, but it is even stronger: Works with uniform models and asynchronous start Two types of merges, depending on the identity of the merging fragments, as we will see: absorption and join

78 78 Local description of asyncr. GHS Like the synchronous, but: 1.Identity of a fragment is now given by a pair: (weight of the core edge, level of the fragment) where the level is a non-negative integer; at the beginning, each node is a fragment of level 0, while during the execution, the level of a fragment increases and depends on the level of the fragments which created it, as we will see. 2.A node has its own status, which can be either of {sleeping, finding, found}

79 79 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 merge Notice that when level=0, then weight is actually the id of the node sending the message!

80 80 Fragment MWOE If then is absorbed by Absorption Connect xy

81 81 New fragment MWOE The combined level is and a New_fragment(weight(F2),level(F2),status(y)) message is broadcasted to nodes of F 1 by the node y of F 2 on which the merge took place New_fragment xy (cost of merging, in terms of number of messages, proportional to the size of F 1 )

82 82 MWOE Fragment If and F 1 and F 2 have a symmetric MWOE, then F 1 joins with F 2 Join Connect  xy

83 83 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 weight is that of the edge on which the merge took place (the new root is the node with min max id between x and y) (cost of merging, in terms of number of messages, proportional to the size of ) New_fragment xy

84 84 Fragment Test  this is obtained by letting F 2 not replying to Test messages from F 1, in case L(F 1 )>L(F 2 ), until L(F 1 ) = L(F 2 ) (this prevents F 1 to find its MWOE, i.e., to ask a connection to F 2, while L(F 1 )≤L(F 2 )) Remark: by definition, a Connect message cannot travel from a fragment of higher level to a fragment of lower level (actually, this is for message-complexity efficiency reasons, since absorption has a cost proportional to the size of the absorbed fragment, as we mentioned before). How to control this?

85 85 Full proof is very complicated. It must address the following general properties: Termination: Response to Test are sometimes delayed  deadlock is a priori possible! Syncronization: Message transmission time is unbounded  inaccurate information in a node about its own fragment is a priori possible! Absorption while searching for a MWOE: in this case, new nodes are added to the fragment, and they dynamically are involved in the on-going MWOE searching process. Is that feasible? Correctness of asynchronous GHS

86 86 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  apply recursively to F\F’, until case (1) applies. Algorithm Message Complexity END OF PROOF

87 87 Thr: Asynchronous GHS requires O(m+n log n) msgs. Proof: We have the following messages: 1.Connect: at most 2 for each edge; 2.Test-Reject: 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

88 88 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 read after 1 (resp., 2) round(s)


Download ppt "1 Minimum Spanning Trees Gallagher-Humblet-Spira (GHS) Algorithm."

Similar presentations


Ads by Google