Download presentation

Presentation is loading. Please wait.

Published byDevante Faries Modified about 1 year ago

2
1

3
2 Lecture Outline 1.Problem description TThe distinct weights demand 2.Review of spanning trees PProperties of spanning trees KKruskal’s algorithm – reminder. 3.The distributed algorithm TThe idea PPreliminaries TThe algorithm – Finding the minimum weight outgoing edge TThe algorithm – changing the core TThe algorithm – Connecting fragments CCorrectness MMessage complexity TTime complexity

4
3 Each edge is associated with a weight which is finite and distinct. General Description In this problem we are given an undirected graph (communication network) with N nodes and E edges. Messages can be transmitted independently in both directions of an edge.

5
4 The algorithm is uniform (identical code for all nodes) General Description All messages arrive after a finite but unpredictable delay, without errors and in sequence (FIFO).

6
5 Lecture Outline 1.Problem description TThe distinct weights demand 2.Review of spanning trees PProperties of spanning trees KKruskal’s algorithm – reminder. 3.The distributed algorithm TThe idea PPreliminaries TThe algorithm – Finding the minimum weight outgoing edge TThe algorithm – changing the core TThe algorithm – Connecting fragments CCorrectness MMessage complexity TTime complexity

7
6 Distinct weights? If the weights are not distinct but the nodes have distinct identities, we can use the nodes’ identities to make the edges’ weight distinct. 1 7 5

8
7 Distinct weights? If the nodes don’t have distinct identities and the weights are not distinct then no uniform distributed algorithm exists.

9
8 Distinct weights? A natural approach is to try and have the nodes select random identities and send a message with these identities to their neighbors. Even though the expected number of times needed until all identities are distinct is small, for any finite number of trials the probability of failure is not zero.

10
9 Lecture Outline Problem description The distinct weights demand 2.Review of spanning trees PProperties of spanning trees KKruskal’s algorithm – reminder. 3.The distributed algorithm TThe idea PPreliminaries TThe algorithm – Finding the minimum weight outgoing edge TThe algorithm – changing the core TThe algorithm – Connecting fragments CCorrectness MMessage complexity TTime complexity

11
10 Review of spanning trees A fragment of an MST is a sub-tree, that is, a connected set of nodes and edges of the MST An outgoing edge is defined as an edge with exactly one end in the fragment Outgoing edge Outgoing edge

12
11 Property 1 Given a fragment of an MST, let e be a min. weight outgoing edge of the fragment. Then joining e and its adjacent non-fragment node to the fragment yields another fragment of an MST.

13
12 Property 1 - Proof Suppose e is not in an MST containing the fragment. e Adding e to the MST will create a cycle. x

14
13 Property 2 If all edges of a connected graph have different weights, then the MST is unique. Proof: Suppose there are 2 different MSTs. Let e be the minimum weight edge such that e belongs to one MST and not the other.

15
14 Property 2 - Proof Proof: Suppose there are 2 different MSTs. Let e be the minimum weight edge such that e belongs to T and does not belong to T’. e m m belongs to T’ and does not belong to T

16
15 An Idea The idea of the algorithm will be based on these two properties. We start with N fragments containing a single node. Using property 1 we can enlarge the fragments. Property 2 assures us that when two fragments have a common node, their union is also a fragment.

17
16 An Idea Our algorithm will be similar in some ways to Kruskal’s algorithm. 7 7 99 12 44 15 33 11 55 11 1.Sort the edges 2.For each edge, if it connects 2 previously unconnected components, add it. (,,,,,,,, )

18
17 Lecture Outline Problem description The distinct weights demand Review of spanning trees Properties of spanning trees Kruskal’s algorithm – reminder. 3.The distributed algorithm TThe idea PPreliminaries TThe algorithm – Finding the minimum weight outgoing edge TThe algorithm – changing the core TThe algorithm – Connecting fragments CCorrectness MMessage complexity TTime complexity

19
18 The Idea In the algorithm each fragment finds its minimum weight outgoing edge (asynchronously) and tries to combine with the fragment on the other side of the edge. Exactly how and when this takes place depends on the fragments’ levels. A fragment containing a single node is at level 0.

20
19 5 Case 1 If two fragments have the same level L and the same minimum weight outgoing edge, they combine to form a new fragment at level (L+1). 7 7 99 12 44 15 33 11 5 1 Fragment F at level 1 Fragment F’ at level 1 Fragment F at level 1 Fragment F new at level 2 Core of F new Core nodes

21
20 Case 2 If fragment F is at level L and fragment F’ at level L’>L is at the other end of the minimum outgoing edge of F, then fragment F is absorbed by F’ (The level remains L’). 7 7 99 19 44 15 17 11 16 1 Fragment F at level 0 Fragment F’ at level 1 A low level fragment trying to connect to a higher level fragment never waits

22
21 Case 3? If fragment F is at level L and fragment F’ at level L>L’ is at the other end of the minimum outgoing edge of F, then no absorption occurs. 7 7 16 19 44 15 8 11 9 1 Fragment F’ at level 0 Fragment F at level 1

23
22 Lecture Outline Problem description The distinct weights demand Review of spanning trees Properties of spanning trees Kruskal’s algorithm – reminder. 3.The distributed algorithm The idea PPreliminaries TThe algorithm – Finding the minimum weight outgoing edge TThe algorithm – changing the core TThe algorithm – Connecting fragments CCorrectness MMessage complexity TTime complexity

24
23 The nodes Each node can be in one of three states: Sleeping, Find and Found. Sleeping is the initial state of all nodes. In all other times the node will be in state Found. The node will be in state Find, when looking for the min. weight outgoing edge of the fragment it belongs to.

25
24 The nodes The algorithm starts when one or more nodes wake up spontaneously (or are awaken). A Sleeping node is awakened by the receipt of any algorithm message.

26
25 The edges For each edge e=(u,v) nodes u and v will have a variable with the edge’s state. An edge’s state can be one of the following three: Branch, Rejected and Basic. Branch: The edge is part of the MST Rejected: The edge is not part of the MST Basic: No decision has been made thus far

27
26 Lecture Outline Problem description The distinct weights demand Review of spanning trees Properties of spanning trees Kruskal’s algorithm – reminder. 3.The distributed algorithm The idea Preliminaries TThe algorithm – Finding the minimum weight outgoing edge TThe algorithm – changing the core TThe algorithm – Connecting fragments CCorrectness MMessage complexity TTime complexity

28
27 Finding the min. outgoing edge Level 0 (Single node) When the node awakens: 1.It chooses its minimum weight adjacent edge. 2.It marks it as a branch of the MST. 3.It sends a “Connect(0)” message on this edge. 4.It goes into state Found (waiting for a reply from the node on the other side). Details to come…

29
28 Finding the min. outgoing edge Level 0 (Single node) 7 9 12 4 15 3 11 5 1 basic branch Connect(0) State=found

30
29 Finding the min. outgoing edge Level L>0: Assume that two level L-1 components with the same minimum outgoing edge e, have just merged to form a new component at level L. The core of the new component’s weight w(e) is the new component’s identity.

31
30 Finding the min. outgoing edge Level L>0: The core nodes send initiate messages which are flooded through the branch edges. core 3 5 basic rejected branch Initiate contains: 1. Fragment Level 2. Fragment ID 3. Find

32
31 Finding the min. outgoing edge If two fragments have the same level L but not the same minimum weight outgoing edge. 7 7 99 12 44 15 33 11 55 1 Fragment F at level 1 Fragment F’ at level 1 Fragment F’’ at level 1 Fragment F new at level 2 Conclusion: When flooding the initiate message, if there are any components of level L-1 waiting to connect, we send the message to them as well.

33
32 Finding the min. outgoing edge Level L>0: The core nodes send initiate messages which are flooded through the branch edges and (L-1) fragments waiting to connect. core 3 5 basic rejected branch Level (L-1) fragment waiting to connect on the 5 edge

34
33 Finding the min. outgoing edge In response to receiving initiate message each node performs the following code: Response to receipt of Initiate (L, F, S) on edge j LN L; FN F; SN S; in-branch j; best-edge nil; best-wt ∞; for all i ≠j such that SE(i) = Branch do send Initiate(L, F, S) on edge i; if S = Find then find-count find-count + 1 end; if S = Find then execute procedure test end Fragment level Fragment ID (core weight) Go to state Find remember where the message came from The (L-1) fragments do not get the initiate here but in procedure (2)

35
34 Finding the min. outgoing edge 3 5 basic rejected branch 2 initiate 1 reject accept test(id,L) initiate test(id,L) When a node receives a test message with an ID identical to it’s own it sends back reject. An exception to this rule is when the node already sent a test message on this edge and while waiting for the reply it received a test message with ID identical to it’s own When the other fragments level is greater than or equal to L it sends accept. If the level of the other fragment is smaller, it delays the answer until it’s level is large enough. state=find state= find state= find

36
35 Finding the min. outgoing edge In response to receiving test message the node performs the following code: procedure test if there are adjacent edges in the state Basic then test-edge the minimum-weight adjacent edge in state Basic; send Test(LN, FN) on test-edge end else test-edge nil; execute procedure report end

37
36 Finding the min. outgoing edge When the node has no basic edges left, receives a report from one of it’s “sons” or receives accept message it perform report. procedure report if find-count = 0 and test-edge = nil then SN Found; send Report(best-wt) on in-branch end This means that all the reports from the “sons” have been received This means that we found an edge or have gone through all the options

38
37 Finding the min. outgoing edge 3 5 basic rejected branch 2 initiate 1 reject accept report(∞) test(id,L) report(3) initiate test(id,L) state=find state= find state= find state= found state= found

39
38 Finding the min. outgoing edge Level L>0: The nodes send report messages back through the edge on which they received the initialize message. core 3 5 basic rejected branch Now both core nodes know in which side the minimum weight outgoing edge is

40
39 Lecture Outline Problem description The distinct weights demand Review of spanning trees Properties of spanning trees Kruskal’s algorithm – reminder. 3.The distributed algorithm The idea Preliminaries The algorithm – Finding the minimum weight outgoing edge TThe algorithm – changing the core TThe algorithm – Connecting fragments CCorrectness MMessage complexity TTime complexity

41
40 Changing the core After the minimum outgoing edge of the fragment has been identified, a change-core message is sent from the core node which is on the side of the minimum outgoing edge. The change-core message is passed on to all the nodes on the path from the core node to the minimum outgoing edge.

42
41 Changing the core core 5 3 basic rejected branch change-core connect(L)

43
42 Changing the core In response to receiving change-core message the node performs the following code: procedure change-core if SE (best-edge) = Branch then send Change-core on best-edge else send Connect(LN) on best-edge; SE (best-edge) Branch end Response to receipt of Change-core execute procedure change-core This checks if the current node is the one that found the minimum weight outgoing edge When we reach the node that found the minimum weight outgoing edge: 1.we mark the edge as part of the MST 2.attempt to connect to the fragment on the other side

44
43 Change core for all? As we saw the change-core message is not flooded to all the nodes, but instead, only on the nodes which are on the path from the core nodes to the node with the minimum weight of the best edge. Is that enough?

45
44 Change core for all? Yes!!! old core 3 5 basic rejected branch change-core new core All the nodes on this side continue sending their messages to the old core which knows of the change.

46
45 Lecture Outline Problem description The distinct weights demand Review of spanning trees Properties of spanning trees Kruskal’s algorithm – reminder. 3.The distributed algorithm The idea Preliminaries The algorithm – Finding the minimum weight outgoing edge The algorithm – changing the core TThe algorithm – Connecting fragments CCorrectness MMessage complexity TTime complexity

47
46 Connecting fragments If two fragments at level L have the same minimum outgoing edge, each sends the message connect(L) over this edge, one in each direction. This edge now becomes the core for the component with level (L+1). New initiate messages are sent by the new core’s nodes and the process of finding the minimum weight outgoing edge starts over. 7 99 12 44 15 33 11 55 1

48
47 Connecting fragments basic rejected branch change-core new core connect(L) change-core L L L+1

49
48 Connecting fragments Finally, consider a connect message from node n in a low level fragment with level L and identity F reaches a node n’ in a higher level L’ with identity F’. As we said before a lower level fragment never waits Node n’ immediately sends an initiate message with parameters F’ and L’ to n (which is flooded to all nodes in F)

50
49 Connecting fragments basic rejected branch change-core “new” core connect(L) L’ L Initiate(L’,F’,?) L’ L

51
50 Why ‘?’ If the node sending the initiate has not yet sent its report, then ?=Find The fragment F joins the search (The node will not send report until it also receives a report from v) v basic rejected branch L’ L Initiate(L’,F’,?) L

52
51 Why ‘?’ If the node sending the initiate has sent its report, then ?=Found Since it has sent its report, this edge was not its minimum outgoing edge. Therefore, fragment F does not need to join the search v basic rejected branch L’ L Initiate(L’,F’,?) L

53
52 An overdue explanation We said before that a lower level fragment never waits on a higher level fragment and that a higher level fragment can be made to wait by a lower level fragment. Reminder:

54
53 Case 2 If fragment F is at level L and fragment F’ at level L’>L is at the other end of F’s minimum outgoing edge, then fragment F is absorbed by F’ (The level remains L’). 7 7 99 19 44 15 17 11 16 1 Fragment F at level 0 Fragment F’ at level 1 A low level fragment trying to connect to a higher level fragment never waits

55
54 Case 3? If fragment F is at level L and fragment F’ at level L>L’ is at the other end of F’s minimum outgoing edge, then no absorption occurs. 7 7 16 19 44 15 8 11 9 1 Fragment F at level 0

56
55 An overdue explanation As we saw before a low level fragment can connect to a higher level fragment without waiting and even join in on its search for the minimum outgoing edge if needed. What if we reversed things? What if a higher level fragment would not wait on a lower level fragment?

57
56 What if we reversed things? 3 5 basic rejected branch 2 initiate 1 reject accept test(id,L) initiate state=find state= find state= find state= found state= found L L’ L

58
57 state=found state=find Running example connect(0) 1073658 connect(0) state=found level=0 ID=10 state=found level=0 ID=7 state=found level=0 ID=3 level=0 initiate(1,3,Find) ID=3 initiate(1,3,Find) level=1 initiate(1,3,Find) level=1 state=find level=1 ID=3 initiate(1,3,Find) state=find level=1 ID=3ID=5 state=found level=0 connect(0) ID=5 level=0 state=found initiate(1,5,Find) test(3,1) level=1 state=find test(5,1) ID=8 level=0 state=found connect(0) initiate(1,5,Find) ID=5 level=1 accept report(∞) report(6) report(∞) report(6) change-core(6) connect(1) initiate(2,6,Find) report(∞) state=find level=2 ID=6 level=2 ID=6 level=2 ID=6 level=2

59
58 Lecture Outline Problem description The distinct weights demand Review of spanning trees Properties of spanning trees Kruskal’s algorithm – reminder. 3.The distributed algorithm The idea Preliminaries The algorithm – Finding the minimum weight outgoing edge The algorithm – changing the core The algorithm – Connecting fragments CCorrectness MMessage complexity TTime complexity

60
59 Correctness We need to show: –Fragments indeed find their minimum-weight outgoing edges –No deadlocks

61
60 Correctness – no deadlock why deadlocks? because some nodes may wait for responses after they sent test or connect. why no deadlocks? Assume that the algorithm has started but not finished. There exist fragments which are not sleeping nodes. Consider the fragment with the lowest level and with the smallest minimum-weight outgoing edge, excluding zero-level sleeping nodes.

62
61 Correctness – no deadlock When sending test : - case 1: sleeping node awakens 1 2 3 1 1 0 0 2 test(id,L)

63
62 Correctness – no deadlock When sending test : - case 2: responded to without waiting 1 2 3 1 1 0 0 2 test(id,L) accept

64
63 0 Correctness – no deadlock When sending connect : - case 1: a sleeping node awakens 2 1 3 0 1 0 0 2 connect

65
64 Correctness – no deadlock When sending connect : - case 2: it reaches a higher level fragment 1 2 3 1 1 0 0 2 connect initiate

66
65 Correctness – no deadlock When sending connect : - case 3: it reaches a fragment with the same level 3 2 1 1 1 0 0 2 connect 2

67
66 Lecture Outline Problem description The distinct weights demand Review of spanning trees Properties of spanning trees Kruskal’s algorithm – reminder. 3.The distributed algorithm The idea Preliminaries The algorithm – Finding the minimum weight outgoing edge The algorithm – changing the core The algorithm – Connecting fragments Correctness MMessage complexity TTime complexity

68
67 Connecting fragments Notice that in a level L component there are at least 2 L nodes (easy to prove by induction). If this is the case the maximum level possible is log 2 N.

69
68 Communication Cost We now determine an upper bound for the number of messages. The most complex message in the algorithm contains one edge weight, one level between 0 and logN, and 3 bits to indicate the message type.

70
69 Communication Cost - failed - successful types of messages: –reject –accept –test –initiate –connect –report –change-core

71
70 Communication Cost An edge can be rejected only once. Rejection requires 2 messages: failed test and reject (or possibly two failed tests). 2E messages 3 5 basic rejected branch 2 initiate 1 reject initiate test(id,L)

72
71 Communication Cost - failed - successful types of messages: –reject –accept –test –initiate –connect –report –change-core

73
72 Communication Cost (cont.) A node in any level beside 0 and the last can receive at most 1 initiate and 1 accept message.

74
73 basic rejected branch connect(L) L L L+1 initiate

75
74 basic rejected branch connect(L) L’ L Initiate(L’,F’,?) L’ L

76
75 Communication Cost (cont.) A node in any level beside 0 and the last can receive at most 1 initiate and 1 accept message. It can transmit at most 1 successful test message, 1 report message and 1 change-core or connect message. A node can go through at most logN - 1 levels (not counting level 0 and the last). 5N(logN -1) messages

77
76 Communication Cost (cont.) At level 0, a node can receive at most 1 initiate message, and transmit at most 1 connect message. 2N messages at the last level, each node can send at most 1 report message. N messages 2E + 5N(logN -1) + 3N < 2E + 5N(logN)

78
77 An overdue explanation We said before that a lower level fragment never waits on a higher level fragment and that a higher level fragment can be made to wait by a lower level fragment. Reminder:

79
78 Case 2 If fragment F is at level L and fragment F’ at level L’>L is at the other end of F’s minimum outgoing edge, then fragment F is absorbed by F’ (The level remains L’). 7 7 99 19 44 15 17 11 16 1 Fragment F at level 0 Fragment F’ at level 1 A low level fragment trying to connect to a higher level fragment never waits

80
79 Case 3? If fragment F is at level L and fragment F’ at level L>L’ is at the other end of F’s minimum outgoing edge, then no absorption occurs. 7 7 16 19 44 15 8 11 9 1 Fragment F at level 0

81
80 An overdue explanation As we saw before a low level fragment can connect to a higher level fragment without waiting and even join in on its search for the minimum outgoing edge if needed. What if we reversed things? What if a higher level fragment would not wait on a lower level fragment?

82
81 What if we reversed things? 3 5 basic rejected branch 2 initiate 1 reject accept test(id,L) initiate state=find state= find state= find state= found state= found L L’ L

83
82 Lecture Outline Problem description The distinct weights demand Review of spanning trees Properties of spanning trees Kruskal’s algorithm – reminder. 3.The distributed algorithm The idea Preliminaries The algorithm – Finding the minimum weight outgoing edge The algorithm – changing the core The algorithm – Connecting fragments Correctness Message complexity TTime complexity

84
83 Timing Cost If we allow only one node to initially wake up, time complexity is Θ(N 2 ). an example: each node sequentially sends test and receives reject from every i j-2 before j’>j is awakened. S’ S 0123 N-3 0.5 221+ 22+ 23+ 2N-3+ 2 1234

85
84 Timing Cost If all nodes awaken originally, time complexity is O(N logN). Awakening all nodes can be done at the beginning in at most N-1 time units. by time N – each node will wake up and send connect. by time 2N each node will be at level 1.

86
85 Timing Cost By time 5 l N – 3N each node is at level l. proof by induction: true for l =1. assume all nodes are at level l by 5 l N – 3N. - each node can send up to N test messages. - these messages are answered. - all nodes send report to the core. - the core nodes spread out change-core. - initiate may be sent as a result (5 l N – 3N) + 5N = 5( l +1)N – 3N 5N5N

87
86 Timing Cost At the last level only test, reject and report messages are sent (total 3N). Since l logN, the algorithm is complete by time 5 l N – 3N + 3N 5NlogN

88
87 Executive Producer:Guy Flysher Directed by:Amir Rubinshtein Music Consultant:Guy Flysher Make Up:Amir Rubinshtein Sound Effects:Guy Flysher Special Effects:Guy Flysher Stunt Double:Amir Rubinshtein Casting ByAmir Rubinshtein Caterer Guy Flysher Countless interruptionsTaub, entire floor 4 Nerd Images Courtesy of Google

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google