142
1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms , Technion

1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

Embed Size (px)

Citation preview

Page 1: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

1

Selecting leader in a clique in

O (n log n)

By Pierre A.Humblet

Presented by: Anat Berkman, 236357 Distributed Algorithms , Technion

Page 2: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

2

Problem background

Arbitrary non empty subset wake up spontaneously ans start executing common asynchronous distributed algorithm

5 17

19 2

67

1 2

3

4

4

32

1

Page 3: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

3

Assumption

● Messages arrive without error after an arbitrary but finite delay

Page 4: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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.

5 17

19 2

67

1 2

3

4

4

32

1

Page 5: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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

Page 6: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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 fight6. If 5 won- tell him

Page 7: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

7

Wake up call

WINNER(A)

A: B:

Page 8: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

8

Wake up call

WINNER(A)

A:STATE:active

SIZE:0MASTER:A

B:STATE:active

SIZE:0MASTER:B

STATE is active\stopped. Active means he was not captured yetSIZE is the size of my kingdom MASTER is the identity of my master

Page 9: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

9

A process the message of type “WINNER”

A:STATE:active

SIZE:0MASTER:A

WINNER(A)

If ID=id (yes)if state='active' then SIZE=SIZE+1If SIZE=N stopif STATE='active' then

send TEST(SIZE,ID) on edge SIZE

B:STATE:active

SIZE:0MASTER:B

Page 10: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

10

A process the message of type “WINNER”

A:STATE:active

SIZE:1MASTER:A

WINNER(A)

If ID=id (yes)if state='active' then SIZE=SIZE+1if SIZE=N stop!if STATE='active' then

send TEST(SIZE,ID) on edge SIZE

B:STATE:active

SIZE:0MASTER:B

Page 11: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

11

A process the message of type “WINNER”

A:STATE:active

SIZE:1MASTER:A

WINNER(A)

If ID=id (yes)if state='active' then SIZE=SIZE+1if SIZE=N stop!if STATE='active' then

send TEST(SIZE,ID) on edge SIZE

B:STATE:active

SIZE:0MASTER:B

Page 12: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

12

A process the message of type “WINNER”

A:STATE:active

SIZE:1MASTER:A

WINNER(A)

If ID=id (yes)If STATE='active' then SIZE=SIZE+1If SIZE=N stopif STATE='active' then

Send TEST(SIZE,ID) on edge SIZE

B:STATE:active

SIZE:0MASTER:B

TEST(1,A)

Page 13: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

13

B process the message of type “TEST” on edge 1

A:STATE:active

SIZE:1MASTER:A

WINNER(A)

If e >= SIZE then: \\{not in our domain, tell the master}EDGE_TO(id)=ePENDING=PENDING+1IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER)

else put TEST(size,if) in PENDING_SET

B:STATE:active

SIZE:0MASTER:B

TEST(1,A)EDGE_TO(MASTER)= -1

Page 14: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

14

B process the message of type “TEST” on edge 1

A:STATE:active

SIZE:1MASTER: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+1IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER)

else put TEST(size,if) in PENDING_SET

B:STATE:active

SIZE:0MASTER:B

TEST(1,A)EDGE_TO(MASTER)=-1EDGE_TO(A)=1

Page 15: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

15

B process the message of type “TEST” on edge 1

A:STATE:active

SIZE:1MASTER:A

WINNER(A)

If e >= SIZE then: \\{not in our domain, tell the master}EDGE_TO(id)=ePENDING=PENDING+1IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER)

else put TEST(size,if) in PENDING_SET

B:STATE:active

SIZE:0MASTER:B

TEST(1,A)EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=0+1=1

PENDING is the number of messages I received but did not finished responding

Page 16: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

16

B process the message of type “TEST” on edge 1

A:STATE:active

SIZE:1MASTER:A

WINNER(A)

If e >= SIZE then: \\{not in our domain, tell the master}EDGE_TO(id)=ePENDING=PENDING+1IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER)

else put TEST(size,if) in PENDING_SET

B:STATE:active

SIZE:0MASTER:B

TEST(1,A)

EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=0+1=1

TEST(1,A)

Page 17: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

17

B process the message of type “TEST” on edge -1

A:STATE:active

SIZE:1MASTER:A

WINNER(A)

If e >= SIZE then: \\{not in our domain, tell the master}EDGE_TO(id)=ePENDING=PENDING+1IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER)

else put TEST(size,if) in PENDING_SET

B:STATE:active

SIZE:0MASTER:B

TEST(1,A)

EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=0+1=1

TEST(1,A)

Page 18: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

18

B process the message of type “TEST” on edge -1

A:STATE:active

SIZE:1MASTER:A

WINNER(A)

If e >= SIZE then: \\{not in our domain, tell the master}EDGE_TO(id)=ePENDING=PENDING+1IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER)

else put TEST(size,if) in PENDING_SETelse \\(e<SIZE)

If (size,id) > (SIZE,ID) thenSTATE='stopped'send WINNER(id) on edge e

B:STATE:stopped

SIZE:0MASTER:B

TEST(1,A)

EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=0+1=1

TEST(1,A)

Page 19: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

19

B process the message of type “TEST” on edge -1

A:STATE:active

SIZE:1MASTER:A

WINNER(A)

If e >= SIZE then: \\{not in our domain, tell the master}EDGE_TO(id)=ePENDING=PENDING+1IF PENDING=1 then send TEST(size,id) on EDGE_TO(MASTER)

else put TEST(size,if) in PENDING_SETelse \\(e<SIZE)

If (size,id) > (SIZE,ID) then \\if (1,A) > (0,B) YES!!!! lexicographic orderSTATE='stopped'send WINNER(id) on edge e

B:STATE:stopped

SIZE:0MASTER:B

TEST(1,A)

EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=0+1=1

TEST(1,A)WINNER(A)

Page 20: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

20

B process the message of type “WINNER(A)” on edge -1

A:STATE:active

SIZE:1MASTER:A

WINNER(A)

B:STATE:stopped

SIZE:0MASTER:A

TEST(1,A)

EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=0+1=1

TEST(1,A)WINNER(A)If ID=id

ElseIf MASTER <> id //if B<>A

MASTER=idsend WINNER(id) on EDGE_TO(A)

PENDING=PENDING-1If PENDING > 0 then ..

Page 21: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

21

B process the message of type “WINNER(A)” on edge -1

A:STATE:active

SIZE:1MASTER:A

WINNER(A)

B:STATE:stopped

SIZE:0MASTER:A

TEST(1,A)

EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=0+1=1

TEST(1,A)WINNER(A)If ID=id

ElseIf MASTER <> id //if B<>A

MASTER=idsend WINNER(id) on EDGE_TO(A)

PENDING=PENDING-1If PENDING > 0 then ..

WINNER(A)

Page 22: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

22

B process the message of type “WINNER(A)” on edge -1

A:STATE:active

SIZE:1MASTER:A

WINNER(A)

B:STATE:stopped

SIZE:0MASTER:A

TEST(1,A)

EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=1-1=0

TEST(1,A)WINNER(A)If ID=id

ElseIf MASTER <> id //if B<>A

send WINNER(id) on EDGE_TO(A)PENDING=PENDING-1If PENDING > 0 then ..

WINNER(A)

Page 23: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

23

A process the message of type “WINNER(A)” on edge 1

A:STATE:active

SIZE:1MASTER:A

WINNER(A)

B:STATE:stopped

SIZE:0MASTER:A

TEST(1,A)

EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=1-1=0

TEST(1,A)WINNER(A)If ID=id

ElseIf MASTER <> id //if B<>A

send WINNER(id) on EDGE_TO(A)PENDING=PENDING-1If PENDING > 0 then ..

WINNER(A)

Page 24: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

24

A process the message of type “WINNER(A)” on edge 1

A:STATE:active

SIZE:2MASTER:A

WINNER(A)

B:STATE:stopped

SIZE:0MASTER:A

TEST(1,A)

EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=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

ElseIf MASTER <> id //if B<>A

send WINNER(id) on EDGE_TO(A)PENDING=PENDING-1If PENDING > 0 then ..

WINNER(A)

Page 25: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

25

A process the message of type “WINNER(A)” on edge 1

A:STATE:active

SIZE:1MASTER:A

WINNER(A)

B:STATE:stopped

SIZE:0MASTER:A

TEST(1,A)

EDGE_TO(MASTER)=-1EDGE_TO(A)=1PENDING=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!!!!!!!!!!

ElseIf MASTER <> id //if B<>A

send WINNER(id) on EDGE_TO(A)PENDING=PENDING-1If PENDING > 0 then ..

WINNER(A)

Page 26: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

26

The algorithm

● When node ID receive WINNER(id) :if ID=id then

if STATE='active' then SIZE=SIZE+1if 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)

Page 27: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

27

The algorithm

● When node ID receive TEST(size,id) on edge e:● if e < SIZE then//message comes from our

domainif (size,id) > (SIZE,ID) then //lexicographic

STATE='stopped' send WINNER(id) on edge e

else send WINNER(ID) on edge e

else //message from outsize the domainEDGE_TO(id) = ePENDING = PENDING +1if PENDING =1 then

send TEST(size,id) on EDGE_TO(MASTER)

else put TEST(size,id) in

PENDING_SET

Page 28: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

28

STATE active

SIZE 0

MASTER B

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER C

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

ExampleSTATE active

SIZE 0

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

WINNER(A)

A:

WINNER(C)

C:

D:

B:

E:

WINNER(D)

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

Page 29: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

29

STATE active

SIZE 0

MASTER B

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER C

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

A<B<C<D<...STATE active

SIZE 0

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

WINNER(A)

A:

WINNER(C)

C:

D:

B:

E:

WINNER(D)

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

Page 30: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

30

if ID=id then if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!If STATE='active' then \\no fight has been lost

send TEST(SIZE,ID) on edge SIZE

STATE active

SIZE 0

MASTER B

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER C

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

ASTATE active

SIZE 1

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

WINNER(A)

A:

WINNER(C)

C:

D:

B:

E:

WINNER(D)

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

Page 31: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

31

if ID=id then if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!If STATE='active' then \\no fight has been lost

send TEST(SIZE,ID) on edge SIZE

STATE active

SIZE 0

MASTER B

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER C

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

ASTATE active

SIZE 1

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

WINNER(A)

A:

WINNER(C)

C:

D:

B:

E:

WINNER(D)

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

Page 32: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

32

if ID=id then if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!If STATE='active' then \\no fight has been lost

send TEST(SIZE,ID) on edge SIZE

STATE active

SIZE 0

MASTER B

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER C

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

ASTATE active

SIZE 1

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

WINNER(A)

A:

WINNER(C)

C:

D:

B:

E:

WINNER(D)

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

TEST(1,A)

F GF

H

I J

Page 33: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

33

if ID=id then if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!If STATE='active' then \\no fight has been lost

send TEST(SIZE,ID) on edge SIZE

STATE active

SIZE 0

MASTER B

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 1

MASTER C

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

CSTATE active

SIZE 1

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

WINNER(A)

A:

WINNER(C)

C:

D:

B:

E:

WINNER(D)

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

TEST(1,C)

F GF

H

I J

Page 34: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

34

If e < SIZE //message comes from our Else //message from outsize the domain

EDGE_TO(id) = ePENDING = PENDING +1If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER)

else put TEST(size,id) in PENDING_SET

STATE active

SIZE 0

MASTER B

PENDING

1

EDGE_TO

A-1

INPUT_SET

PENDING_SET

STATE active

SIZE 1

MASTER C

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

B-process A's messageSTATE active

SIZE 1

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

WINNER(A)

A:

WINNER(C)

C:

D:

B:

E:

WINNER(D)

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

TEST(1,A)

F GF

H

I J

Page 35: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

35

If e < SIZE //message comes from our Else //message from outsize the domain

EDGE_TO(id) = ePENDING = PENDING +1If PENDING =1 then send TEST(size,id) on EDGE_TO(MASTER)

else put TEST(size,id) in PENDING_SET

STATE active

SIZE 0

MASTER B

PENDING

2

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

TEST(1,C)

STATE active

SIZE 1

MASTER C

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 1

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

WINNER(A)

A:

WINNER(C)

C:

D:

B:

E:

WINNER(D)

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

B-process C's message(1,C)

Page 36: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

36

If e < SIZE //message comes from our Else //message from outsize the domain

EDGE_TO(id) = ePENDING = PENDING +1If PENDING =1 then

send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET

STATE active

SIZE 0

MASTER B

PENDING

2

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

TEST(1,C)

STATE active

SIZE 1

MASTER C

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 1

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

B-process B's message (test(1,A))

WINNER(A)

A:

WINNER(C)

C:

D:

B:

E:

WINNER(D)

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

Page 37: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

37

If e < SIZE //message comes from our If (size,id) > (SIZE,ID) then //lexicographic

STATE='stopped'Send WINNER(id) on edge e

ElseSend WINNER(ID) on edge e

STATE STOPPED

SIZE 0

MASTER B

PENDING

2

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

TEST(1,C)

STATE active

SIZE 1

MASTER C

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 1

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

B-process B's message (test(1,A))

WINNER(A)

A:

WINNER(C)

C:

D:

B:

E:

WINNER(D)

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

WINNER(A)

F GF

H

I J

Page 38: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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)

STATE STOPPED

SIZE 0

MASTER A

PENDING

1

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

STATE active

SIZE 1

MASTER C

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 1

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

B-process B's message WINNER(A)

WINNER(A)

A:

WINNER(C)

C:

D:

B:

E:

WINNER(D)

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

WINNER(A)

TEST(1,C)

F GF

H

I J

Page 39: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

39

●if ID=id then

●if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!If STATE='active' then \\no fight has been lost

send TEST(SIZE,ID) on edge SIZE

STATE STOPPED

SIZE 0

MASTER A

PENDING

1

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

STATE active

SIZE 1

MASTER C

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 2

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

A-process B's message WINNER(A)

A:

C:

D:

B:

E:

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

TEST(2,A)

F GF

H

I J

Page 40: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

40

If e < SIZE //message comes from our domainIf (size,id) > (SIZE,ID) then //lexicographic

STATE='stopped'Send WINNER(id) on edge e

ElseSend WINNER(ID) on edge e

STATE STOPPED

SIZE 0

MASTER A

PENDING

1

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

STATE active

SIZE 1

MASTER C

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 2

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

A-process B's message TEST(1,C)

A:

C:

D:

B:

E:

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

WINNER(A)

F GF

H

I J

Page 41: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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)

STATE STOPPED

SIZE 0

MASTER A

PENDING

0

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

STATE active

SIZE 1

MASTER C

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 2

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

B-process A's message WINNER(A)

A:

C:

D:

B:

E:

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

Page 42: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

42

If e < SIZEElse //message from outsize the domain

EDGE_TO(id) = ePENDING = PENDING +1If PENDING =1 then

send TEST(size,id) on EDGE_TO(MASTER)Else put TEST(size,id) in PENDING_SET

STATE STOPPED

SIZE 0

MASTER A

PENDING

0

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

STATE active

SIZE 1

MASTER C

PENDING

1

EDGE_TO

A-2

INPUT_SET

PENDING_SET

STATE active

SIZE 2

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

C-process A's message TEST(2,A)

A:

C:

D:

B:

E:

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

TEST(2,A) F GF

H

I J

Page 43: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

43

If e < SIZE //message comes from our domainIf (size,id) > (SIZE,ID) then //lexicographic

STATE='stopped'Send WINNER(id) on edge e

ElseSend WINNER(ID) on edge e

STATE STOPPED

SIZE 0

MASTER A

PENDING

0

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER C

PENDING

1

EDGE_TO

A-2

INPUT_SET

PENDING_SET

STATE active

SIZE 2

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

C-process C's message TEST(2,A)

A:

C:

D:

B:

E:

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

WINNER(A) F GF

H

I J

Page 44: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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)

STATE STOPPED

SIZE 0

MASTER A

PENDING

0

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER A

PENDING

0

EDGE_TO

A-2

INPUT_SET

PENDING_SET

STATE active

SIZE 2

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

C-process C's message WINNER(A)

A:

C:

D:

B:

E:

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

WINNER(A)

F GF

H

I J

Page 45: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

45

●if ID=id then if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!If STATE='active' then \\no fight has been lost

send TEST(SIZE,ID) on edge SIZE

STATE STOPPED

SIZE 0

MASTER A

PENDING

0

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER A

PENDING

0

EDGE_TO

A-2

INPUT_SET

PENDING_SET

STATE active

SIZE 3

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

A-process C's message WINNER(A)

A:

C:

D:

B:

E:

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 0

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

TEST(3,A)

F GF

H

I J

Page 46: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

46

●if ID=id then if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!If STATE='active' then \\no fight has been lost

send TEST(SIZE,ID) on edge SIZE

STATE STOPPED

SIZE 0

MASTER A

PENDING

0

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER A

PENDING

0

EDGE_TO

A-2

INPUT_SET

PENDING_SET

STATE active

SIZE 3

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

D-process awake WINNER(D)

A:

C:

D:

B:

E:

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 1

MASTER D

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

TEST(1,D)

F GF

H

I J

Page 47: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

47

If e < SIZEElse //message from outsize the domain

EDGE_TO(id) = ePENDING = PENDING +1If PENDING =1 then

send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET

STATE STOPPED

SIZE 0

MASTER A

PENDING

0

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER A

PENDING

0

EDGE_TO

A-2

INPUT_SET

PENDING_SET

STATE active

SIZE 3

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

D-process A message TEST(3,A)

A:

C:

D:

B:

E:

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE active

SIZE 1

MASTER D

PENDING

1

EDGE_TO

A-1

INPUT_SET

PENDING_SET

TEST(3,A)

F GF

H

I J

Page 48: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

48

If e < SIZE //message comes from our domainIf (size,id) > (SIZE,ID) then //lexicographic

STATE='stopped'Send WINNER(id) on edge e

ElseSend WINNER(ID) on edge e

STATE STOPPED

SIZE 0

MASTER A

PENDING

0

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER A

PENDING

0

EDGE_TO

A-2

INPUT_SET

PENDING_SET

STATE active

SIZE 3

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

D-process D message TEST(3,A)

A:

C:

D:

B:

E:

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER D

PENDING

1

EDGE_TO

A-1

INPUT_SET

PENDING_SET

WINNER(A)

F GF

H

I J

Page 49: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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)

STATE STOPPED

SIZE 0

MASTER A

PENDING

0

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER A

PENDING

0

EDGE_TO

A-2

INPUT_SET

PENDING_SET

STATE active

SIZE 3

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

D-process D message WINNER(A)

A:

C:

D:

B:

E:

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER A

PENDING

0

EDGE_TO

A-1

INPUT_SET

PENDING_SET

WINNER(A)

F GF

H

I J

Page 50: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

50

●if ID=id then if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!If STATE='active' then \\no fight has been lost

send TEST(SIZE,ID) on edge SIZE

STATE STOPPED

SIZE 0

MASTER A

PENDING

0

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER A

PENDING

0

EDGE_TO

A-2

INPUT_SET

PENDING_SET

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

A-process D message WINNER(A)

A:

C:

D:

B:

E:

STATE active

SIZE 0

MASTER E

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER A

PENDING

0

EDGE_TO

A-1

INPUT_SET

PENDING_SET

TEST(4,A)

F GF

H

I J

Page 51: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

51

If e < SIZEElse //message from outsize the domain

EDGE_TO(id) = ePENDING = PENDING +1If PENDING =1 then

send TEST(size,id) on EDGE_TO(MASTER) Else put TEST(size,id) in PENDING_SET

STATE STOPPED

SIZE 0

MASTER A

PENDING

0

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER A

PENDING

0

EDGE_TO

A-2

INPUT_SET

PENDING_SET

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

E-process A message TEST(4,A)

A:

C:

D:

B:

E:

STATE active

SIZE 0

MASTER E

PENDING

1

EDGE_TO

A-1

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER A

PENDING

0

EDGE_TO

A-1

INPUT_SET

PENDING_SET

TEST(4,A)

F GF

H

I J

Page 52: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

52

If e < SIZE //message comes from our domainIf (size,id) > (SIZE,ID) then //lexicographic

STATE='stopped'Send WINNER(id) on edge e

ElseSend WINNER(ID) on edge e

STATE STOPPED

SIZE 0

MASTER A

PENDING

0

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER A

PENDING

0

EDGE_TO

A-2

INPUT_SET

PENDING_SET

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

E-process E message TEST(4,A)

A:

C:

D:

B:

E:

STATE stopped

SIZE 0

MASTER E

PENDING

1

EDGE_TO

A-1

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER A

PENDING

0

EDGE_TO

A-1

INPUT_SET

PENDING_SET

WINNER(A)

F GF

H

I J

Page 53: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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)

STATE STOPPED

SIZE 0

MASTER A

PENDING

0

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER A

PENDING

0

EDGE_TO

A-2

INPUT_SET

PENDING_SET

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

E-process E message WINNER(A)

A:

C:

D:

B:

E:

STATE stopped

SIZE 0

MASTER A

PENDING

0

EDGE_TO

A-1

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER A

PENDING

0

EDGE_TO

A-1

INPUT_SET

PENDING_SET

WINNER(A)

F GF

H

I J

Page 54: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

54

●if ID=id then if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!If STATE='active' then \\no fight has been lost

send TEST(SIZE,ID) on edge SIZE

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

F woke up

A:

C:

D:

B:

E:STATE active

SIZE 1

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

Page 55: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

55

●if ID=id then if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!If STATE='active' then \\no fight has been lost

send TEST(SIZE,ID) on edge SIZE

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

F woke up

A:

C:

D:

B:

E:STATE active

SIZE 1

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

TEST(1,F)

Page 56: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

56

If e < SIZE //message comes from our Else //message from outsize the domain

EDGE_TO(id) = ePENDING = PENDING +1If PENDING =1 then

send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

G process the message TEST from F

A:

C:

D:

B:

E:STATE active

SIZE 1

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

STATE active

SIZE 0

MASTER E

PENDING

1

EDGE_TO

F-1

INPUT_SET

PENDING_SET

TEST(1,F)

Page 57: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

57

If e < SIZE //message comes from our If (size,id) > (SIZE,ID) then //lexicographic

STATE='stopped'Send WINNER(id) on edge e

ElseSend WINNER(ID) on edge e

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

G process the message TEST from G

A:

C:

D:

B:

E:STATE active

SIZE 1

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

STATE stopped

SIZE 0

MASTER E

PENDING

1

EDGE_TO

F-1

INPUT_SET

PENDING_SET

WINNER(F)

Page 58: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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)

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

G process message WINNER from G

A:

C:

D:

B:

E:STATE active

SIZE 1

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

STATE stopped

SIZE 0

MASTER F

PENDING

0

EDGE_TO

F-1

INPUT_SET

PENDING_SET

WINNER(F)

Page 59: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

59

●if ID=id then

●if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!If STATE='active' then \\no fight has been lost

send TEST(SIZE,ID) on edge SIZE

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

F process message WINNER(F) from G

A:

C:

D:

B:

E:STATE active

SIZE 2

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

TEST(2,F)

Page 60: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

60

If e < SIZE //message comes from our Else //message from outsize the domain

EDGE_TO(id) = ePENDING = PENDING +1If PENDING =1 then

send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

H process message TEST from F

A:

C:

D:

B:

E:STATE active

SIZE 2

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

TEST(2,F)

STATE active

SIZE 0

MASTER H

PENDING

1

EDGE_TO

F-1

INPUT_SET

PENDING_SET

Page 61: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

61

If e < SIZE //message comes from our If (size,id) > (SIZE,ID) then //lexicographic

STATE='stopped'Send WINNER(id) on edge e

ElseSend WINNER(ID) on edge e

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

H process message TEST from H

A:

C:

D:

B:

E:STATE active

SIZE 2

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

WINNER(F)

STATE stopped

SIZE 0

MASTER H

PENDING

1

EDGE_TO

F-1

INPUT_SET

PENDING_SET

Page 62: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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)

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

H process message WINNER(F) from H

A:

C:

D:

B:

E:STATE active

SIZE 2

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

WINNER(F)

STATE stopped

SIZE 0

MASTER F

PENDING

0

EDGE_TO

F-1

INPUT_SET

PENDING_SET

Page 63: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

63

●if ID=id then

●if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!If STATE='active' then \\no fight has been lost

send TEST(SIZE,ID) on edge SIZE

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

F process message WINNER(F) from H

A:

C:

D:

B:

E:STATE active

SIZE 3

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

TEST(3,F)

Page 64: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

64

If e < SIZE //message comes from our Else //message from outsize the domain

EDGE_TO(id) = ePENDING = PENDING +1If PENDING =1 then

send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

I process message TEST from F

A:

C:

D:

B:

E:STATE active

SIZE 3

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

TEST(3,F)

STATE active

SIZE 0

MASTER I

PENDING

1

EDGE_TO

F-1

INPUT_SET

PENDING_SET

Page 65: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

65

If e < SIZE //message comes from our If (size,id) > (SIZE,ID) then //lexicographic

STATE='stopped'Send WINNER(id) on edge e

ElseSend WINNER(ID) on edge e

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

I process message TEST from I

A:

C:

D:

B:

E:STATE active

SIZE 3

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

WINNER(F)

STATE stopped

SIZE 0

MASTER I

PENDING

1

EDGE_TO

F-1

INPUT_SET

PENDING_SET

Page 66: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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)

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

I process message WINNER(F) from I

A:

C:

D:

B:

E:STATE active

SIZE 3

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

WINNER(F)

STATE stopped

SIZE 0

MASTER F

PENDING

0

EDGE_TO

F-1

INPUT_SET

PENDING_SET

Page 67: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

67

●if ID=id then

●if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!If STATE='active' then \\no fight has been lost

send TEST(SIZE,ID) on edge SIZE

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

F process message WINNER(F) from H

A:

C:

D:

B:

E:STATE active

SIZE 4

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

TEST(4,F)

Page 68: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

68

If e < SIZE //message comes from our Else //message from outsize the domain

EDGE_TO(id) = ePENDING = PENDING +1If PENDING =1 then

send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

J process message TEST from F

A:

C:

D:

B:

E:STATE active

SIZE 4

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

STATE active

SIZE 0

MASTER J

PENDING

1

EDGE_TO

F-1

INPUT_SET

PENDING_SET

TEST(4,F)

Page 69: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

69

If e < SIZE //message comes from our If (size,id) > (SIZE,ID) then //lexicographic

STATE='stopped'Send WINNER(id) on edge e

ElseSend WINNER(ID) on edge e

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

J process message TEST from J

A:

C:

D:

B:

E:STATE active

SIZE 4

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

STATE stopped

SIZE 0

MASTER J

PENDING

1

EDGE_TO

F-1

INPUT_SET

PENDING_SET

WINNER(F)

Page 70: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

70

If e < SIZE //message comes from our If (size,id) > (SIZE,ID) then //lexicographic

STATE='stopped'Send WINNER(id) on edge e

ElseSend WINNER(ID) on edge e

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

J process message WINNER(F) from J

A:

C:

D:

B:

E:STATE active

SIZE 4

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

STATE stopped

SIZE 0

MASTER F

PENDING

0

EDGE_TO

F-1

INPUT_SET

PENDING_SET

WINNER(F)

Page 71: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

71

if ID=id then

if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!If STATE='active' then \\no fight has been lost

send TEST(SIZE,ID) on edge SIZE

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

F process message WINNER(F) from J

A:

C:

D:

B:

E:STATE active

SIZE 5

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

TEST(5,F)

Page 72: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

72

If e < SIZE //message comes from our Else //message from outsize the domain

EDGE_TO(id) = ePENDING = PENDING +1If PENDING =1 then

send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET

STATE active

SIZE 4

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

C process message TEST(5,F) from F

A:

C:

D:

B:

E:STATE active

SIZE 5

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F GF

H

I J

TEST(5,F)

STATE stopped

SIZE 1

MASTER A

PENDING

1

EDGE_TO

A-2F-5

INPUT_SET

PENDING_SET

Page 73: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

73

●if ID=id then

●if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!If STATE='active' then \\no fight has been lost

send TEST(SIZE,ID) on edge SIZE

STATE STRPPED

SIZE 0

MASTER A

PENDING

0

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

STATE stopped

SIZE 1

MASTER A

PENDING

0

EDGE_TO

A-2

INPUT_SET

PENDING_SET

STATE active

SIZE 5

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

A-process E message WINNER(A)

A:

C:

D:

B:

E:

STATE stopped

SIZE 0

MASTER A

PENDING

0

EDGE_TO

A-1

INPUT_SET

PENDING_SET

STATE stopped

SIZE 5

MASTER A

PENDING

0

EDGE_TO

A-1

INPUT_SET

PENDING_SET

TEST(1,C)

TEST(5,A)

F GF

H

I J

Page 74: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

74

If e < SIZE //message comes from our domainIf (size,id) > (SIZE,ID) then //lexicographic

STATE='stopped'Send WINNER(id) on edge e

STATE stopped

SIZE 5

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

A process message TEST(5,F) from C

A:

C:STATE active

SIZE 5

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F

STATE stopped

SIZE 1

MASTER A

PENDING

1

EDGE_TO

A-2F-5

INPUT_SET

PENDING_SET

if (5,F) > (5,A)WINNER(F)

Page 75: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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)

STATE stopped

SIZE 5

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

C process message WINNER(F) from A

A:

C:

STATE active

SIZE 5

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F

STATE stopped

SIZE 1

MASTER F

PENDING

0

EDGE_TO

A-2F-5

INPUT_SET

PENDING_SET

WINNER(F)

Page 76: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

76

●if ID=id then if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!If STATE='active' then \\no fight has been lost

send TEST(SIZE,ID) on edge SIZE

STATE stopped

SIZE 5

MASTER A

PENDING

EDGE_TO

INPUT_SET

PENDING_SET

F process message WINNER(F) from C

A:

C:

STATE active

SIZE 6

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F

STATE stopped

SIZE 1

MASTER F

PENDING

0

EDGE_TO

A-2F-5

INPUT_SET

PENDING_SET

TEST(6,F)

Page 77: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

77

If e < SIZEElse //message from outsize the domain

EDGE_TO(id) = ePENDING = PENDING +1If PENDING =1 then

send TEST(size,id) on EDGE_TO(MASTER) else put TEST(size,id) in PENDING_SET

STATE stopped

SIZE 5

MASTER A

PENDING

1

EDGE_TO

F-5

INPUT_SET

PENDING_SET

A process message TEST(6,F) from F

A:

C:

STATE active

SIZE 6

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F

STATE stopped

SIZE 1

MASTER F

PENDING

0

EDGE_TO

A-2F-5

INPUT_SET

PENDING_SET

TEST(6,F)

Page 78: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

78

If e < SIZE //message comes from our domainIf (size,id) > (SIZE,ID) then //lexicographic

STATE='stopped'Send WINNER(id) on edge e

ElseSend WINNER(ID) on edge e

STATE stopped

SIZE 5

MASTER A

PENDING

1

EDGE_TO

F-5

INPUT_SET

PENDING_SET

A process message TEST(6,F) from A

A:

C:

STATE active

SIZE 6

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F

STATE stopped

SIZE 1

MASTER F

PENDING

0

EDGE_TO

A-2F-5

INPUT_SET

PENDING_SET

WINNER(F)

Page 79: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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)

STATE stopped

SIZE 5

MASTER F

PENDING

0

EDGE_TO

F-5

INPUT_SET

PENDING_SET

A process message WINNER(F) from A

A:

C:

STATE active

SIZE 6

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F

STATE stopped

SIZE 1

MASTER F

PENDING

0

EDGE_TO

A-2F-5

INPUT_SET

PENDING_SET

WINNER(F)

Page 80: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

80

if ID=id then

if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!If STATE='active' then \\no fight has been lost

send TEST(SIZE,ID) on edge SIZE

STATE stopped

SIZE 5

MASTER F

PENDING

0

EDGE_TO

F-5

INPUT_SET

PENDING_SET

F process message WINNER(F) from A

A:

STATE active

SIZE 7

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

F

B:

TEST(7,F)

STATE STOPPED

SIZE 0

MASTER A

PENDING

0

EDGE_TO

A-1C-2

INPUT_SET

PENDING_SET

Page 81: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

81

B process message TEST(F)

A:

STATE active

SIZE 7

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

B:A:

C:

D:

B:

E:

F GF

H

I J

TEST(7,F)

Page 82: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

82

A:

STATE active

SIZE 7

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

B:A:

C:

D:

B:

E:

F GF

H

I J

WINNER(F)

Page 83: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

83

A:

STATE active

SIZE 7

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

B:A:

C:

D:

B:

E:

F GF

H

I J

WINNER(F)

Page 84: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

84

A:

STATE active

SIZE 8

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

B:A:

C:

D:

B:

E:

F GF

H

I J

TEST(8,F)

Page 85: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

85

A:

STATE active

SIZE 8

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

B:A:

C:

D:

B:

E:

F GF

H

I J

TEST(8,F)

Page 86: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

86

A:

STATE active

SIZE 8

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

B:A:

C:

D:

B:

E:

F GF

H

I J

WINNER(F)

Page 87: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

87

A:

STATE active

SIZE 8

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

B:A:

C:

D:

B:

E:

F GF

H

I J

WINNER(F)

Page 88: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

88

A:

STATE active

SIZE 9

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

B:A:

C:

D:

B:

E:

F GF

H

I J

TEST(9,F)

Page 89: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

89

A:

STATE active

SIZE 9

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

B:A:

C:

D:

B:

E:

F GF

H

I J

TEST(9,F)

Page 90: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

90

A:

STATE active

SIZE 10

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

B:A:

C:

D:

B:

E:

F GF

H

I J

WINNER(F)

if ID=id then if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!

Page 91: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

91

A:

STATE active

SIZE 10

MASTER F

PENDING

0

EDGE_TO

INPUT_SET

PENDING_SET

B:A:

C:

D:

B:

E:

F GF

H

I J

if ID=id then if STATE='active' then SIZE=SIZE+1if SIZE=N then stop!

WE HAVE A LEADER!!!!!!!!!!!

Page 92: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

92

Correctness

● We would like to show :● 1. Termination● 2. One leader is elected and only one

Page 93: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

93

Termination

● We will show:1. The number of messages is bounded2. There is no deadlocktherefore the algorithm stop after a finite number of messages.

Page 94: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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.4 ⋅𝑛2

Page 95: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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

Page 96: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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

Page 97: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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)

𝐷𝐵𝑡 𝑏

𝐷𝐵𝑡 𝑏∩𝐷 𝐴

𝑡 𝑎≠∅→ ∣ 𝐷𝐵𝑡𝑏 ∣≠ ∣𝐷 𝐴

𝑡 𝑎 ∣

𝑡𝑎𝐷 𝐴𝑡𝑏

𝐷𝐵 ∣𝐷𝐵𝑡 𝑏∣> ∣ 𝐷𝐴

𝑡 𝑎 ∣

𝑡𝑎 𝑡𝑏

Page 98: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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 :

∣𝐷𝐵𝑡 𝑏∣> ∣ 𝐷𝐴

𝑡 ′ ∣

∣𝐷𝐵 ∣> ∣ 𝐷𝐴 ∣ ∣𝐷𝐵 ∣=∣𝐷 𝐴∣

Page 99: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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:

∣𝐷𝑥

𝑡𝑥 ∣> ∣𝐷 𝐴𝑡 ′ ∣

∣𝐷𝑥+1𝑡 𝑥+1 ∣> ∣𝐷𝑥

𝑡 𝑥 ∣

∣𝐷𝑥+1𝑡 𝑥+1 ∣> ∣𝐷𝑥

𝑡 𝑥 ∣> ∣𝐷 𝐴𝑡 ′ ∣

Page 100: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

100

● So we proved that

in other words:𝐷𝐵

𝑡 𝑏∩𝐷 𝐴𝑡 𝑎≠∅→ ∣ 𝐷𝐵

𝑡𝑏 ∣≠ ∣𝐷 𝐴𝑡 𝑎 ∣

∣𝐷𝐵𝑡 𝑏∣=∣𝐷 𝐴

𝑡𝑎 ∣→𝐷𝐵𝑡 𝑏∩𝐷 𝐴

𝑡 𝑎=∅

Page 101: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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

𝑆 𝑖≤𝑁𝑖

𝑆1 ,𝑆2 , . ..𝑆𝑖− 1

𝑆 𝑖≤𝑁𝑖

∣ 𝑆1∣≥ ∣𝑆2∣ ≥ ∣𝑆3 ∣≥ ... ∣𝑆𝑛 ∣

Page 102: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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.

Page 103: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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

4 ⋅(𝑁1 +𝑁2

+𝑁3

+...+𝑁𝑘 )

Page 104: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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

Page 105: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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Ω (𝑛 log𝑛)

Page 106: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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 = ⟨ 𝑠𝑒𝑛𝑑1 , 𝑠𝑒𝑛𝑑2 , . ..𝑠𝑒𝑛𝑑𝑘 ⟩

Page 107: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

107

● For every event where is the node sending the message and

is the edge used by it● Example 1

● Example 2

𝑠𝑒𝑛𝑑𝑖=(𝑣 (𝑠𝑒𝑛𝑑𝑖 ) ,𝑒 (𝑠𝑒𝑛𝑑𝑖 ))𝑣 (𝑠𝑒𝑛𝑑𝑖 )𝑒 (𝑠𝑒𝑛𝑑𝑖 )

V1 V2 SEND= <(v1,(v1,v2))>

V1 V2 SEND= <>

Page 108: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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

𝑆𝐸𝑁𝐷 (𝑡 )= ⟨𝑠𝑒𝑛𝑑1 , 𝑠𝑒𝑛𝑑2 , . ..𝑠𝑒𝑛𝑑𝑡 ⟩𝑆𝐸𝑁𝐷 (0 )=⟨⟩

Page 109: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

109

● Let NEW=NEW(SEND) be the subsequence of SEND that consist of all the events that use previously unused edges.

V1 V21

2

SEND= <(v1,(v1,v2)),(v2,(v1,v2)) >NEW = <(v1,(v1,v2)) >

Page 110: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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:

V1 V21

2

V3

G

V1 V2

G(NEW(1))

V3

Page 111: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

111

● If for every execution of the algorithm A the corresponding graph G(NEW) is connected then we term this algorithm global.

Page 112: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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𝑚 (𝐴 )≥𝑒 (𝐴)

Page 113: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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

Page 114: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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

Page 115: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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

Page 116: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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'

Page 117: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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

C2C

It is impossible that it's the end of the algorithm (and the other nodes sleep)

Page 118: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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

𝑈⊆𝑉

Page 119: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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.

∣𝑈 ∣≤1

∣𝑈 ∣=2

Page 120: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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

Page 121: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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)

Page 122: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

122

Theorem 1- proof

● Definenote: 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).

𝑒 (𝑘)=𝑚𝑖𝑛 {𝑒 (𝑈 )∣𝑈⊆𝑉 ,∣𝑈 ∣=𝑘 }

𝑒 (2k+1 )≥2𝑒 (𝑘 )+𝑘+1(𝑘<𝑛2 )

𝐶=𝑈 1∪𝑈 2

𝑈 1 ,𝑈 2

Page 123: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

123

Other nodes

C

U2U1

v U

Page 124: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

124

NEW=NEW1 NEW2 (axiom 2)

Other nodes

C

U2U1

v U

°

NEW1 NEW2

Page 125: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

125

Axiom4: edge from C

Other nodes

C

U2U1

v U

NEW1 NEW2

Page 126: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

126

Axiom4: edge from C

Other nodes

C

U2U1

v U

NEW1 NEW2

Page 127: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

127

Axiom3: replace with unused edge

Other nodes

C

U2U1

v U

NEW1 NEW2

Unused edges between U1 and U2

Page 128: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

128

Axiom3: replace with unused edge

Other nodes

C

U2U1

v U

NEW1 NEW2

Unused edges between U1 and U2

Page 129: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

129

Axiom3: replace with unused edge

Other nodes

C

U2U1

v U

NEW1 NEW2

Unused edges between U1 and U2

Page 130: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

130

Axiom3: replace with unused edge-at least k times

Other nodes

C

U2U1

v U

NEW1 NEW2

Unused edges between U1 and U2

Page 131: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

131

Change C

Other nodes

C

U2U1

v

NEW1 NEW2

Page 132: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

132

Change C- axiom 4+3

Other nodes

C

U2U1

v

NEW1 NEW2

Page 133: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

133

Change C- axiom 4+3

Other nodes

C

U2U1

v

NEW1 NEW2

Unused edge

Page 134: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

134

Change C- axiom 4+3

Other nodes

C

U2U1

v

NEW1 NEW2

Page 135: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

135

Total at least: e(U1)+e(U2)+k+1

Other nodes

C

U2U1

v

NEW1 NEW2

Page 136: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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

𝐶=𝑈 1∪𝑈 2

𝑈 1 ,𝑈 2

°

Page 137: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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.

𝑒 (2k+1 )=𝑒 (𝑈 )≥𝑒 (𝑈 1 )+𝑒 (𝑈 2 )+𝑘+1≥2𝑒 (𝑘 )+𝑘+1

Page 138: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

138

● So we have:

By induction we will show that for

𝑒 (2k+1 )≥2𝑒 (𝑘 )+𝑘+1

𝑛=2𝑖−1 ,𝑒 (1 )=0

𝑒 (𝑛 )≥ 𝑛+12log(𝑛+1

2 )¿

Page 139: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

139

𝑏𝑎𝑠𝑖𝑠 : 𝑖=1 :𝑛=21−1=1

𝑒 (1 )=1≥ 22log (1 )=0

𝑎𝑠𝑠𝑢𝑚𝑒𝑡 h𝑒𝑐𝑜𝑟𝑟𝑒𝑡𝑛𝑒𝑠𝑠𝑜𝑓𝑛=2𝑖−1∧𝑠 h𝑜𝑤𝑓𝑜𝑟 2 (𝑖+1)−1

❑/2k+1=2𝑖+1−1𝑠𝑜𝑘=2𝑖−1𝑒 (2𝑖+1−1 )≥2𝑒 (2𝑖−1 )+2𝑖−1+1

≥2𝑒 (𝑛)+2𝑖≥2𝑛+12log𝑛+12

+2𝑖=¿2 ⋅ 2𝑖

2log

2𝑖

2+2𝑖=2𝑖 ⋅ log 2

𝑖

2+2𝑖=¿2𝑖 ⋅ log 2𝑖 −1+2𝑖=❑/2𝑖+1−1=𝑁

𝑁+12

log𝑁 +14

+𝑁 +14

=𝑁+12⋅ log 𝑁+1

2+ log 1

2+𝑁+1

4=¿𝑁 +1

2log𝑁+12

−𝑁−14

≥𝑁+12

log𝑁 +12

Page 140: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

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.

Ω (𝑛 log𝑛)

Ω (𝑛 log𝑘 )

𝑂 (𝑛 log𝑘 )

Page 141: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

141

Page 142: 1 Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms, Technion

142

T H A N K

YO

U