Download presentation
Presentation is loading. Please wait.
Published byCatherine McDaniel Modified over 9 years ago
1
1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion
2
2 Problem background Arbitrary non empty subset wake up spontaneously ans start executing common asynchronous distributed algorithm 517 192 67 12 3 4 4 3 2 1
3
3 Assumption ● Messages arrive without error after an arbitrary but finite delay
4
4 The algorithm ● Main idea : as long as a node did not surrender he tries to capture other nodes according to the edges. First he tries to capture the node at the end point of edge #1, then #2 and so on. 517 192 67 12 3 4 4 3 2 1
5
5 5 wants to capture 17 5 17 2. Let me ask my master 3. Master, 5 want to have a fight1. TEST: I want to capture you! 17 4. Lets have a fight: 5 vs 17
6
6 5 wants to capture 17 5 17 2. Let me ask my master 3. Master, 5 want to have a fight1. TEST: I want to capture you! 17 4. Lets have a fight: 5 vs 17 5. Answer to the fight 6. If 5 won- tell him
7
7 Wake up call WINNER(A) A:B:
8
8 Wake up call WINNER(A) A: STATE:active SIZE:0 MASTER:A B: STATE:active SIZE:0 MASTER:B STATE is active\stopped. Active means he was not captured yet SIZE is the size of my kingdom MASTER is the identity of my master
9
9 A process the message of type “WINNER” A: STATE:active SIZE:0 MASTER:A WINNER(A) If ID=id (yes) if state='active' then SIZE=SIZE+1 If SIZE=N stop if STATE='active' then send TEST(SIZE,ID) on edge SIZE B: STATE:active SIZE:0 MASTER:B
10
10 A process the message of type “WINNER” A: STATE:active SIZE:1 MASTER:A WINNER(A) If ID=id (yes) if state='active' then SIZE=SIZE+1 if SIZE=N stop! if STATE='active' then send TEST(SIZE,ID) on edge SIZE B: STATE:active SIZE:0 MASTER:B
11
11 A process the message of type “WINNER” A: STATE:active SIZE:1 MASTER:A WINNER(A) If ID=id (yes) if state='active' then SIZE=SIZE+1 if SIZE=N stop! if STATE='active' then send TEST(SIZE,ID) on edge SIZE B: STATE:active SIZE:0 MASTER:B
12
12 A process the message of type “WINNER” A: STATE:active SIZE:1 MASTER:A WINNER(A) If ID=id (yes) If STATE='active' then SIZE=SIZE+1 If SIZE=N stop if STATE='active' then Send TEST(SIZE,ID) on edge SIZE B: STATE:active SIZE:0 MASTER:B TEST(1,A)
13
13 B process the message of type “TEST” on edge 1 A: STATE:active SIZE:1 MASTER:A WINNER(A) If e >= SIZE then: \\{not in our domain, tell the master} EDGE_TO(id)=e PENDING=PENDING+1 IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,if) in PENDING_SET B: STATE:active SIZE:0 MASTER:B TEST(1,A) EDGE_TO(MASTER)= -1
14
14 B process the message of type “TEST” on edge 1 A: STATE:active SIZE:1 MASTER:A WINNER(A) If e >= SIZE then: \\{not in our domain, tell the master} EDGE_TO(id)=e \\{not in our domain, tell the master} PENDING=PENDING+1 IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,if) in PENDING_SET B: STATE:active SIZE:0 MASTER:B TEST(1,A) EDGE_TO(MASTER)=-1 EDGE_TO(A)=1
15
15 B process the message of type “TEST” on edge 1 A: STATE:active SIZE:1 MASTER:A WINNER(A) If e >= SIZE then: \\{not in our domain, tell the master} EDGE_TO(id)=e PENDING=PENDING+1 IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,if) in PENDING_SET B: STATE:active SIZE:0 MASTER:B TEST(1,A) EDGE_TO(MASTER)=-1 EDGE_TO(A)=1 PENDING=0+1=1 PENDING is the number of messages I received but did not finished responding
16
16 B process the message of type “TEST” on edge 1 A: STATE:active SIZE:1 MASTER:A WINNER(A) If e >= SIZE then: \\{not in our domain, tell the master} EDGE_TO(id)=e PENDING=PENDING+1 IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,if) in PENDING_SET B: STATE:active SIZE:0 MASTER:B TEST(1,A) EDGE_TO(MASTER)=-1 EDGE_TO(A)=1 PENDING=0+1=1 TEST(1,A)
17
17 B process the message of type “TEST” on edge -1 A: STATE:active SIZE:1 MASTER:A WINNER(A) If e >= SIZE then: \\{not in our domain, tell the master} EDGE_TO(id)=e PENDING=PENDING+1 IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,if) in PENDING_SET B: STATE:active SIZE:0 MASTER:B TEST(1,A) EDGE_TO(MASTER)=-1 EDGE_TO(A)=1 PENDING=0+1=1 TEST(1,A)
18
18 B process the message of type “TEST” on edge -1 A: STATE:active SIZE:1 MASTER:A WINNER(A) If e >= SIZE then: \\{not in our domain, tell the master} EDGE_TO(id)=e PENDING=PENDING+1 IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,if) in PENDING_SET else \\(e (SIZE,ID) then STATE='stopped' send WINNER(id) on edge e B: STATE:stopped SIZE:0 MASTER:B TEST(1,A) EDGE_TO(MASTER)=-1 EDGE_TO(A)=1 PENDING=0+1=1 TEST(1,A)
19
19 B process the message of type “TEST” on edge -1 A: STATE:active SIZE:1 MASTER:A WINNER(A) If e >= SIZE then: \\{not in our domain, tell the master} EDGE_TO(id)=e PENDING=PENDING+1 IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,if) in PENDING_SET else \\(e (SIZE,ID) then \\if (1,A) > (0,B) YES!!!! lexicographic order STATE='stopped' send WINNER(id) on edge e B: STATE:stopped SIZE:0 MASTER:B TEST(1,A) EDGE_TO(MASTER)=-1 EDGE_TO(A)=1 PENDING=0+1=1 TEST(1,A) WINNER(A)
20
20 B process the message of type “WINNER(A)” on edge -1 A: STATE:active SIZE:1 MASTER:A WINNER(A) B: STATE:stopped SIZE:0 MASTER:A TEST(1,A) EDGE_TO(MASTER)=-1 EDGE_TO(A)=1 PENDING=0+1=1 TEST(1,A) WINNER(A) If ID=id Else If MASTER <> id //if B<>A MASTER=id send WINNER(id) on EDGE_TO(A) PENDING=PENDING-1 If PENDING > 0 then..
21
21 B process the message of type “WINNER(A)” on edge -1 A: STATE:active SIZE:1 MASTER:A WINNER(A) B: STATE:stopped SIZE:0 MASTER:A TEST(1,A) EDGE_TO(MASTER)=-1 EDGE_TO(A)=1 PENDING=0+1=1 TEST(1,A) WINNER(A) If ID=id Else If MASTER <> id //if B<>A MASTER=id send WINNER(id) on EDGE_TO(A) PENDING=PENDING-1 If PENDING > 0 then.. WINNER(A)
22
22 B process the message of type “WINNER(A)” on edge -1 A: STATE:active SIZE:1 MASTER:A WINNER(A) B: STATE:stopped SIZE:0 MASTER:A TEST(1,A) EDGE_TO(MASTER)=-1 EDGE_TO(A)=1 PENDING=1-1=0 TEST(1,A) WINNER(A) If ID=id Else If MASTER <> id //if B<>A send WINNER(id) on EDGE_TO(A) PENDING=PENDING-1 If PENDING > 0 then.. WINNER(A)
23
23 A process the message of type “WINNER(A)” on edge 1 A: STATE:active SIZE:1 MASTER:A WINNER(A) B: STATE:stopped SIZE:0 MASTER:A TEST(1,A) EDGE_TO(MASTER)=-1 EDGE_TO(A)=1 PENDING=1-1=0 TEST(1,A) WINNER(A) If ID=id Else If MASTER <> id //if B<>A send WINNER(id) on EDGE_TO(A) PENDING=PENDING-1 If PENDING > 0 then.. WINNER(A)
24
24 A process the message of type “WINNER(A)” on edge 1 A: STATE:active SIZE:2 MASTER:A WINNER(A) B: STATE:stopped SIZE:0 MASTER:A TEST(1,A) EDGE_TO(MASTER)=-1 EDGE_TO(A)=1 PENDING=1-1=0 TEST(1,A) WINNER(A) If ID=id \\ if A=A if STATE='active then SIZE=SIZE+1 if SIZE=N then STOP Else If MASTER <> id //if B<>A send WINNER(id) on EDGE_TO(A) PENDING=PENDING-1 If PENDING > 0 then.. WINNER(A)
25
25 A process the message of type “WINNER(A)” on edge 1 A: STATE:active SIZE:1 MASTER:A WINNER(A) B: STATE:stopped SIZE:0 MASTER:A TEST(1,A) EDGE_TO(MASTER)=-1 EDGE_TO(A)=1 PENDING=1-1=0 TEST(1,A) WINNER(A) If ID=id \\ if A=A if STATE='active then SIZE=SIZE+1 if SIZE=N then STOP – you are the leader!!!!!!!!!! Else If MASTER <> id //if B<>A send WINNER(id) on EDGE_TO(A) PENDING=PENDING-1 If PENDING > 0 then.. WINNER(A)
26
26 The algorithm ● When node ID receive WINNER(id) : if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE ● else if MASTER <>id then MASTER=id send WINNER(id) on EDGE_TO(id) PENDING=PENDING-1 ● if PENDING > 0 then send a message from PENDING_SET on edge EDGE_TO(MASTER)
27
27 The algorithm ● When node ID receive TEST(size,id) on edge e: ● if e (SIZE,ID) then //lexicographic STATE='stopped' send WINNER(id) on edge e else send WINNER(ID) on edge e else //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 if PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET
28
28 Example WINNER(A) A: WINNER(C) C: D: B: E: WINNER(D) FGF H IJ
29
29 A<B<C<D<... WINNER(A) A: WINNER(C) C: D: B: E: WINNER(D) FGF H IJ
30
30 if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE A WINNER(A) A: WINNER(C) C: D: B: E: WINNER(D) FGF H IJ
31
31 if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE A WINNER(A) A: WINNER(C) C: D: B: E: WINNER(D) FGF H IJ
32
32 if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE A WINNER(A) A: WINNER(C) C: D: B: E: WINNER(D) TEST(1,A) FGF H IJ
33
33 if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE C WINNER(A) A: WINNER(C) C: D: B: E: WINNER(D)TEST(1,C) FGF H IJ
34
34 If e < SIZE //message comes from our Else //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET B-process A's message WINNER(A) A: WINNER(C) C: D: B: E: WINNER(D) TEST(1,A) FGF H IJ
35
35 If e < SIZE //message comes from our Else //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET WINNER(A) A: WINNER(C) C: D: B: E: WINNER(D) FGF H IJ B-process C's message(1,C)
36
36 If e < SIZE //message comes from our Else //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET B-process B's message (test(1,A)) WINNER(A) A: WINNER(C) C: D: B: E: WINNER(D) FGF H IJ
37
37 If e (SIZE,ID) then //lexicographic STATE='stopped' Send WINNER(id) on edge e Else Send WINNER(ID) on edge e B-process B's message (test(1,A)) WINNER(A) A: WINNER(C) C: D: B: E: WINNER(D) WINNER(A) FGF H IJ
38
38 ● if ID=id then ● ELSE if MASTER <>id then MASTER=id send WINNER(id) on EDGE_TO(id) PENDING=PENDING-1 ● if PENDING > 0 then send a message from PENDING_SET on edge EDGE_TO(MASTER) B-process B's message WINNER(A) WINNER(A) A: WINNER(C) C: D: B: E: WINNER(D) WINNER(A) TEST(1,C) FGF H IJ
39
39 ● if ID=id then ● if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE A-process B's message WINNER(A) A: C: D: B: E: TEST(2,A) FGF H IJ
40
40 If e (SIZE,ID) then //lexicographic STATE='stopped' Send WINNER(id) on edge e Else Send WINNER(ID) on edge e A-process B's message TEST(1,C) A: C: D: B: E: WINNER(A) FGF H IJ
41
41 ● if ID=id then ● else if MASTER <>id then MASTER=id send WINNER(id) on EDGE_TO(id) PENDING=PENDING-1 ● if PENDING > 0 then send a message from PENDING_SET on edge EDGE_TO(MASTER) B-process A's message WINNER(A) A: C: D: B: E: FGF H IJ
42
42 If e < SIZE Else //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) Else put TEST(size,id) in PENDING_SET C-process A's message TEST(2,A) A: C: D: B: E: TEST(2,A) FGF H IJ
43
43 If e (SIZE,ID) then //lexicographic STATE='stopped' Send WINNER(id) on edge e Else Send WINNER(ID) on edge e C-process C's message TEST(2,A) A: C: D: B: E: WINNER(A) FGF H IJ
44
44 if ID=id then else if MASTER <>id then MASTER=id send WINNER(id) on EDGE_TO(id) PENDING=PENDING-1 if PENDING > 0 then send a message from PENDING_SET on edge EDGE_TO(MASTER) C-process C's message WINNER(A) A: C: D: B: E: WINNER(A) FGF H IJ
45
45 ● if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE A-process C's message WINNER(A) A: C: D: B: E: TEST(3,A) FGF H IJ
46
46 ● if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE D-process awake WINNER(D) A: C: D: B: E: TEST(1,D) FGF H IJ
47
47 If e < SIZE Else //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET D-process A message TEST(3,A) A: C: D: B: E: TEST(3,A) FGF H IJ
48
48 If e (SIZE,ID) then //lexicographic STATE='stopped' Send WINNER(id) on edge e Else Send WINNER(ID) on edge e D-process D message TEST(3,A) A: C: D: B: E: WINNER(A) FGF H IJ
49
49 if ID=id then else if MASTER <>id then MASTER=id send WINNER(id) on EDGE_TO(id) PENDING=PENDING-1 if PENDING > 0 then send a message from PENDING_SET on edge EDGE_TO(MASTER) D-process D message WINNER(A) A: C: D: B: E: WINNER(A) FGF H IJ
50
50 ● if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE A-process D message WINNER(A) A: C: D: B: E: TEST(4,A) FGF H IJ
51
51 If e < SIZE Else //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER)Else put TEST(size,id) in PENDING_SET E-process A message TEST(4,A) A: C: D: B: E: TEST(4,A) FGF H IJ
52
52 If e (SIZE,ID) then //lexicographic STATE='stopped' Send WINNER(id) on edge e Else Send WINNER(ID) on edge e E-process E message TEST(4,A) A: C: D: B: E: WINNER(A) FGF H IJ
53
53 if ID=id then else if MASTER <>id then MASTER=id send WINNER(id) on EDGE_TO(id) PENDING=PENDING-1 if PENDING > 0 then send a message from PENDING_SET on edge EDGE_TO(MASTER) E-process E message WINNER(A) A: C: D: B: E: WINNER(A) FGF H IJ
54
54 ● if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE F woke up A: C: D: B: E: FGF H IJ
55
55 ● if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE F woke up A: C: D: B: E: FGF H IJ TEST(1,F)
56
56 If e < SIZE //message comes from our Else //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET G process the message TEST from F A: C: D: B: E: FGF H IJ TEST(1,F)
57
57 If e (SIZE,ID) then //lexicographic STATE='stopped' Send WINNER(id) on edge e Else Send WINNER(ID) on edge e G process the message TEST from G A: C: D: B: E: FGF H IJ WINNER(F)
58
58 ● if ID=id then ● ELSE if MASTER <>id then MASTER=id send WINNER(id) on EDGE_TO(id) PENDING=PENDING-1 ● if PENDING > 0 then send a message from PENDING_SET on edge EDGE_TO(MASTER) G process message WINNER from G A: C: D: B: E: F G F H IJ WINNER(F)
59
59 ● if ID=id then ● if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE F process message WINNER(F) from G A: C: D: B: E: F G F H IJ TEST(2,F)
60
60 If e < SIZE //message comes from our Else //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET H process message TEST from F A: C: D: B: E: F G F H IJ TEST(2,F)
61
61 If e (SIZE,ID) then //lexicographic STATE='stopped' Send WINNER(id) on edge e Else Send WINNER(ID) on edge e H process message TEST from H A: C: D: B: E: F G F H IJ WINNER(F)
62
62 ● if ID=id then ● ELSE if MASTER <>id then MASTER=id send WINNER(id) on EDGE_TO(id) PENDING=PENDING-1 ● if PENDING > 0 then send a message from PENDING_SET on edge EDGE_TO(MASTER) H process message WINNER(F) from H A: C: D: B: E: F G F H IJ WINNER(F)
63
63 ● if ID=id then ● if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE F process message WINNER(F) from H A: C: D: B: E: F G F H IJ TEST(3,F)
64
64 If e < SIZE //message comes from our Else //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET I process message TEST from F A: C: D: B: E: F G F H IJ TEST(3,F)
65
65 If e (SIZE,ID) then //lexicographic STATE='stopped' Send WINNER(id) on edge e Else Send WINNER(ID) on edge e I process message TEST from I A: C: D: B: E: F G F H IJ WINNER(F)
66
66 ● if ID=id then ● ELSE if MASTER <>id then MASTER=id send WINNER(id) on EDGE_TO(id) PENDING=PENDING-1 ● if PENDING > 0 then send a message from PENDING_SET on edge EDGE_TO(MASTER) I process message WINNER(F) from I A: C: D: B: E: F G F H IJ WINNER(F)
67
67 ● if ID=id then ● if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE F process message WINNER(F) from H A: C: D: B: E: F G F H IJ TEST(4,F)
68
68 If e < SIZE //message comes from our Else //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET J process message TEST from F A: C: D: B: E: F G F H IJ TEST(4,F)
69
69 If e (SIZE,ID) then //lexicographic STATE='stopped' Send WINNER(id) on edge e Else Send WINNER(ID) on edge e J process message TEST from J A: C: D: B: E: F G F H IJ WINNER(F)
70
70 If e (SIZE,ID) then //lexicographic STATE='stopped' Send WINNER(id) on edge e Else Send WINNER(ID) on edge e J process message WINNER(F) from J A: C: D: B: E: F G F H IJ WINNER(F)
71
71 if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE F process message WINNER(F) from J A: C: D: B: E: F G F H IJ TEST(5,F)
72
72 If e < SIZE //message comes from our Else //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET C process message TEST(5,F) from F A: C: D: B: E: F G F H IJ TEST(5,F)
73
73 ● if ID=id then ● if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE A-process E message WINNER(A) A: C: D: B: E: TEST(5,A) F G F H IJ
74
74 If e (SIZE,ID) then //lexicographic STATE='stopped' Send WINNER(id) on edge e A process message TEST(5,F) from C A: C: F if (5,F) > (5,A) WINNER(F)
75
75 ● if ID=id then ● else if MASTER <>id then MASTER=id send WINNER(id) on EDGE_TO(id) PENDING=PENDING-1 ● if PENDING > 0 then send a message from PENDING_SET on edge EDGE_TO(MASTER) C process message WINNER(F) from A A: C: F WINNER(F)
76
76 ● if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE F process message WINNER(F) from C A: C: F TEST(6,F)
77
77 If e < SIZE Else //message from outsize the domain EDGE_TO(id) = e PENDING = PENDING +1 If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET A process message TEST(6,F) from F A: C: F TEST(6,F)
78
78 If e (SIZE,ID) then //lexicographic STATE='stopped' Send WINNER(id) on edge e Else Send WINNER(ID) on edge e A process message TEST(6,F) from A A: C: F WINNER(F)
79
79 if ID=id then else if MASTER <>id then MASTER=id send WINNER(id) on EDGE_TO(id) PENDING=PENDING-1 if PENDING > 0 then send a message from PENDING_SET on edge EDGE_TO(MASTER) A process message WINNER(F) from A A: C: F WINNER(F)
80
80 if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! If STATE='active' then \\no fight has been lost send TEST(SIZE,ID) on edge SIZE F process message WINNER(F) from A A: F B: TEST(7,F)
81
81 B process message TEST(F) A: B: A: C: D: B: E: FGF H IJ TEST(7,F)
82
82 A: B: A: C: D: B: E: FGF H IJ WINNER(F)
83
83 A: B: A: C: D: B: E: FGF H IJ WINNER(F)
84
84 A: B: A: C: D: B: E: FGF H IJ TEST(8,F)
85
85 A: B: A: C: D: B: E: FGF H IJ TEST(8,F)
86
86 A: B: A: C: D: B: E: FGF H IJ WINNER(F)
87
87 A: B: A: C: D: B: E: FGF H IJ WINNER(F)
88
88 A: B: A: C: D: B: E: FGF H IJ TEST(9,F)
89
89 A: B: A: C: D: B: E: FGF H IJ TEST(9,F)
90
90 A: B: A: C: D: B: E: FGF H IJ WINNER(F) if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop!
91
91 A: B: A: C: D: B: E: FGF H IJ if ID=id then if STATE='active' then SIZE=SIZE+1 if SIZE=N then stop! WE HAVE A LEADER!!!!!!!!!!!
92
92 Correctness ● We would like to show : ● 1. Termination ● 2. One leader is elected and only one
93
93 Termination ● We will show: 1. The number of messages is bounded 2. There is no deadlock therefore the algorithm stop after a finite number of messages.
94
94 Termination- proof The number of messages is bounded: Each processor can send at most N-1 TEST messages. TEST message can cause at most more 3 messages (to the master,from the master,to the origin node-only if won). So total there is at most messages.
95
95 Termination- proof There is no deadlock: Assume there is a deadlock. Now let's look at the processor with the highest (SIZE,ID). He waits for an answer for his TEST message. Assume node u received the TEST message. Node u will eventually deliver it to it's master. At the end of the battle one will win and continue (send more TEST messages or win)- no deadlock. Bounded number of messages + no deadlock = termination
96
96 One leader is elected ● Define 'domain' of node ID at time t as the set of nodes from which it has receive winner(ID), including itself and the node was active. ● The domain size can not decrease ● For each active node: the domain size equal to SIZE: (from the code upon receiving WINNER(ID)) This is the only line SIZE is changed if ID=id then if STATE='active' then SIZE=SIZE+1
97
97 ● Let be the domain of node B at time tb ● Lemma 1: ● Proof: assume v in from time and in v joins so we will show by induction on j- the number of new masters v had after till (include)
98
98 ● Basis j=1: v belonged to domain A and then joined domain B (directly). AB V B sent TEST to v, who gave it to A. At time t', A processed this message: TEST(Bsize,B) v joined B so : either or but B>A. After v join Domain B Domain A no longer increase. In both cases after v join B :
99
99 ● Step: if the statement holds for some natural number j=x, then the statement holds for j=x+1. From the correctness for j=x we know that as in the basis we can prove that so total we can have:
100
100 ● So we proved that in other words:
101
101 ● Rank the nodes in order of decreasing order of SIZE at termination, breaking ties arbitrarily and denote by Si the final SIZE of the i”th ranked node. Lemma 2: Proof: ● each once was in the same size of Si. By lemma1 we know they all disjoin. If we divide all nodes (N) equally we will get
102
102 ONE LEADER ● The node with the largest (SIZE,ID) is S1, it is not possible it lost a fight (if it has there was Si with larger SIZE). So he won all the fights- at termination it's size is N. the size of S2 is smaller than S1 (lemma2 + S1 with SIZE=N) so S2 did not win. Same for all other nodes.
103
103 Complexity ● Each domain can at most send TEST message as it's size so: assume k woke up arbitrary (each test message can cause at most three more messages) So total we have O(N log(k)) messages
104
104 Lower bound From the paper “ Optimal lower bounds for some distributed algorithms for a complete network of predecessors “ Written by: E.Korach, S.Moran, S.Zaks
105
105 Main Idea- lower bound ● The adversary will always choose the “longest algorithm”. So we look at all possible executions, then we drop messages which don't use “new” edges, and we show that even if we drop messages our best algorithm is still bounded by
106
106 Lower bound ● Let A be a distributed algorithm acting on graph G=(V,E). Execution of A may consist events: sending a message, receiving a message or doing local computation. ● We assume no two message are sent in exactly the same time, therefor in each execution we associate a sequence ● SEND =
107
107 ● For every event where is the node sending the message and is the edge used by it ● Example 1 ● Example 2 V1V2 SEND= V1V2 SEND= <>
108
108 ● Let SEND(t) be the prefix of length t of SEND, ● If t<t' then we say SEND(t') is an extension of SEND(t) and SEND(t)<SEND(t')
109
109 ● Let NEW=NEW(SEND) be the subsequence of SEND that consist of all the events that use previously unused edges. V1V2 1 2 SEND= NEW =
110
110 ● G(NEW(t)) = (V,E(NEW(t))) where E(NEW(t)) is the set of edges used in NEW(t). NEW(t) - prefix of size t of NEW ● Example: V1V2 1 2 V3 G V1V2 G(NEW(1)) V3
111
111 ● If for every execution of the algorithm A the corresponding graph G(NEW) is connected then we term this algorithm global.
112
112 ● The edge complexity e(A) of an algorithm A acting on a graph G is the maximal length of a sequence NEW over all executions of A ● The message complexity m(A) of an algorithm A acting on a graph G is the maximal length of a sequence SEND over all executions of A. ● Clearly
113
113 ● For each algorithm A and graph G we define the exhaustive set of A with respect to G, denoted by EX(A,G) (or E(A)) as the set of all the sequences NEW(t) corresponding to possible executions of A
114
114 Axiom 1 ● The empty sequence is in EX(A,G) intuitive explanation: EX(A,G) is the set of all the sequences NEW(t) corresponding to possible executions of A, in particular EX(A,G) includes the sequence corresponding to NEW(0).
115
115 Axiom 2 ● If two sequences NEW1,NEW2 which do not interfere with each other are in EX(A,G) then so is also their concatenation NEW1 NEW2 Other nodes New1 New2
116
116 Axiom 3 ● If NEW(t) is a sequence in EX(A,G) with last element (v,e), and if e' is an unused edge adjacent to v, then the sequence obtained from NEW(t) by replacing e by e' is also in EX(A,G) Other nodes (v,e) Other nodes e The adversary Other nodes (v,e') Other nodes e'
117
117 Axiom 4 ● If NEW(t) is in EX(A,G) and C is a proper subgraph of G(NEW(t)) which is a union of some connected components, then there is an extension of NEW(t) in which the first new message (v,e) satisfies v in C. (A global) Other nodes C1 C2 C It is impossible that it's the end of the algorithm (and the other nodes sleep)
118
118 Lemma 1 ● Lemma 1: Let A be a global algorithm acting on a complete graph G=(V,E) and let ● then there exists a sequence of messages NEW in EX(A,G) such that G(NEW) has one connected component whose set of vertexes is U and the vertexes in V-U are isolated
119
119 Lemma 1 ● Proof:By induction we will build: If there is nothing to prove. If ( assume v1, v2) : we start with the empty sequence (axiom 1). Define C={v1},with axiom 4 we have extension which starts in v1. We have unused edged (v1,v2) so according to axiom 3 we can replace it.
120
120 Lemma 1 ● Proof: the main idea is we can keep this process as long we have an unused edge: Each iterate we pick a node from C(4). If it's connected to all it's neighbors in C- we done. Else- we can connect it to a neighbor it's not connected to (3), we can proceed until there is a node which is saturated (and then C is connected component) Other nodes
121
121 Theorem 1 ● Theorem 1: let A be a global algorithm acting on a completed graph G with n nodes. Then the edge complexity e(A) of A is at least O(n log n). ● Proof: for a subset U of V we define e(U) to be the maximal length of a sequence NEW in EX(A,G), which induces a graph that has a connected component whose set of vertexes is U and isolated vertexes otherwise (Exist from lemma 1)
122
122 Theorem 1- proof ● Define note: e(n) is the edge complexity of A. ● Now we will prove that Let U be a disjoint union of and {v} such that |U1|=|U2|=k so e(U)=e(2k+1).
123
123 Other nodes C U2U1 v U
124
124 NEW=NEW1 NEW2 (axiom 2) Other nodes C U2U1 v U NEW1NEW2
125
125 Axiom4: edge from C Other nodes C U2U1 v U NEW1NEW2
126
126 Axiom4: edge from C Other nodes C U2U1 v U NEW1NEW2
127
127 Axiom3: replace with unused edge Other nodes C U2U1 v U NEW1NEW2 Unused edges between U1 and U2
128
128 Axiom3: replace with unused edge Other nodes C U2U1 v U NEW1NEW2 Unused edges between U1 and U2
129
129 Axiom3: replace with unused edge Other nodes C U2U1 v U NEW1NEW2 Unused edges between U1 and U2
130
130 Axiom3: replace with unused edge- at least k times Other nodes C U2U1 v U NEW1NEW2 Unused edges between U1 and U2
131
131 Change C Other nodes C U2U1 v NEW1NEW2
132
132 Change C- axiom 4+3 Other nodes C U2U1 v NEW1NEW2
133
133 Change C- axiom 4+3 Other nodes C U2U1 v NEW1NEW2 Unused edge
134
134 Change C- axiom 4+3 Other nodes C U2U1 v NEW1NEW2
135
135 Total at least: e(U1)+e(U2)+k+1 Other nodes C U2U1 v NEW1NEW2
136
136 ● Let U be a disjoint union of and {v} such that |U1|=|U2|=k so e(U)=e(2k+1). Define Let NEW1,NEW2 be sequences in EX(A,G) of lengths e(U1),e(U2) inducing subgraphs G1,G2 that have one connected component with vertex set U1,U2 respectively (all other isolated). These two sequences do not interfere with each other and by axiom2 their concatenation NEW=NEW1 NEW2 is also in EX(A,G).
137
137 ● C satisfies the assumptions of axiom 4, each node in C has at least k unused edges, so there is an extension of NEW by a message (v',e) where v' in C. by axiom 3 we can change this with one of the unused edges. This process can be repeated until at least one vertex in C saturates all its edges to other vertexes in C. this requires at least k messages along previously unused edges. ● We change C to include now also {v} and from axiom 4+3 we will get an edge to v.
138
138 ● So we have: By induction we will show that for
139
139
140
140 Conclusion Theorem 2: Let A be a global algorithm acting on a complete graph G with n nodes. Then the message complexity m(A) is If k nodes woke up we get As we seen Humblet algorithm was therefore it reaches the lower bound.
141
141
142
142 THANK Y O U
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.