Selecting leader in a clique in O (n log n) By Pierre A.Humblet

Post on 24-Feb-2016

30 views 0 download

Tags:

description

Selecting leader in a clique in O (n log n) By Pierre A.Humblet Presented by: Anat Berkman, 236357 Distributed Algorithms , Technion. Problem background. Arbitrary non empty subset wake up spontaneously ans start executing common asynchronous distributed algorithm. 5. 17. 4. 3. 1. 2. - PowerPoint PPT Presentation

transcript

1

Selecting leader in a clique inO (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

3

Assumption

● Messages arrive without error after an arbitrary but finite delay

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

5

5 wants to capture 17

5 172. Let me ask my master

3. Master, 5 want to have a fight1. TEST: I want to capture you!

174. Lets have a fight: 5 vs 17

6

5 wants to capture 17

5 172. Let me ask my master

3. Master, 5 want to have a fight1. TEST: I want to capture you!

174. Lets have a fight: 5 vs 17

5. Answer to the fight6. If 5 won- tell him

7

Wake up call

WINNER(A)

A: B:

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

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

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

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

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)

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

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

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

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)

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)

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)

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)

20

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

A:STATE:active

SIZE:1MASTER:A

WINNER(A)B:

STATE:stoppedSIZE:0

MASTER: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 ..

21

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

A:STATE:active

SIZE:1MASTER:A

WINNER(A)B:

STATE:stoppedSIZE:0

MASTER: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)

22

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

A:STATE:active

SIZE:1MASTER:A

WINNER(A)B:

STATE:stoppedSIZE:0

MASTER: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)

23

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

A:STATE:active

SIZE:1MASTER:A

WINNER(A)B:

STATE:stoppedSIZE:0

MASTER: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)

24

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

A:STATE:active

SIZE:2MASTER:A

WINNER(A)B:

STATE:stoppedSIZE:0

MASTER: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)

25

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

A:STATE:active

SIZE:1MASTER:A

WINNER(A)B:

STATE:stoppedSIZE:0

MASTER: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)

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)

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

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

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

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

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

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

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

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

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)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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)

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)

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)

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)

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)

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

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

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

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)

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

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

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

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)

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)

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)

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)

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)

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

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

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)

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)

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)

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-5INPUT_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)

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-5INPUT_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)

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-5INPUT_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)

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-5INPUT_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

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)

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)

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)

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)

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)

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)

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)

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)

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)

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!

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

92

Correctness

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

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.

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

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

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

● 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

● 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

● 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 ∣> ∣𝐷𝑥

𝑡 𝑥 ∣> ∣𝐷 𝐴𝑡 ′ ∣

100

● So we proved that

in other words:𝐷𝐵

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

𝑡𝑏 ∣≠ ∣𝐷 𝐴𝑡 𝑎 ∣

∣𝐷𝐵𝑡 𝑏∣=∣𝐷 𝐴

𝑡𝑎 ∣→𝐷𝐵𝑡 𝑏∩𝐷 𝐴

𝑡 𝑎=∅

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 ∣≥ ... ∣𝑆𝑛 ∣

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

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

+...+𝑁𝑘 )

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

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

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

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

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 )=⟨⟩

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

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

111

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

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

● 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

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

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

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 adversaryOther nodes

(v,e')Other nodes

e'

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

C1C2C

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

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

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

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

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

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

123

Other nodes

C

U2U1

v U

124

NEW=NEW1 NEW2 (axiom 2)

Other nodes

C

U2U1

v U

°

NEW1 NEW2

125

Axiom4: edge from C

Other nodes

C

U2U1

v U

NEW1 NEW2

126

Axiom4: edge from C

Other nodes

C

U2U1

v U

NEW1 NEW2

127

Axiom3: replace with unused edge

Other nodes

C

U2U1

v U

NEW1 NEW2

Unused edges between U1 and U2

128

Axiom3: replace with unused edge

Other nodes

C

U2U1

v U

NEW1 NEW2

Unused edges between U1 and U2

129

Axiom3: replace with unused edge

Other nodes

C

U2U1

v U

NEW1 NEW2

Unused edges between U1 and U2

130

Axiom3: replace with unused edge-at least k times

Other nodes

C

U2U1

v U

NEW1 NEW2

Unused edges between U1 and U2

131

Change C

Other nodes

C

U2U1

v

NEW1 NEW2

132

Change C- axiom 4+3

Other nodes

C

U2U1

v

NEW1 NEW2

133

Change C- axiom 4+3

Other nodes

C

U2U1

v

NEW1 NEW2

Unused edge

134

Change C- axiom 4+3

Other nodes

C

U2U1

v

NEW1 NEW2

135

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

Other nodes

C

U2U1

v

NEW1 NEW2

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

°

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

138

● So we have:

By induction we will show that for

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

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

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

2 )¿

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 𝑛+1

2+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+𝑁+14

=¿𝑁 +12

log 𝑁+12

− 𝑁−14

≥ 𝑁+12

log 𝑁 +12

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

141

142

T H A N K

Y O U