+ All Categories
Home > Documents > 1 Minimum Spanning Trees Gallagher-Humblet-Spira (GHS) Algorithm.

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

Date post: 16-Dec-2015
Category:
Upload: terence-phelps
View: 253 times
Download: 2 times
Share this document with a friend
80
1 Minimum Spanning Trees Gallagher-Humblet-Spira (GHS) Algorithm
Transcript

1

Minimum Spanning Trees

Gallagher-Humblet-Spira (GHS) Algorithm

2

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

1

92

14

8

6

310 115

7

164

15

13

12

6)( ew

17

18

3

Spanning tree

1

92

14

8

6

310 11

7

164

15

13

12

17

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

5

18

4

1

92

14

8

6

310 115

4

15

13

12

Minimum-weight spanning tree

A spanning tree s.t. the sum of its weights is minimized:

17

(MST)

For MST :T

Te

ewTw )()( is minimized

18

7

16

5

Spanning tree fragment:

Any (connected) sub-tree of a MST

1

92

14

8

6

310 115

4

15

13

12

17

18

7

16

6

Minimum weight outgoing edge(MWOE)

An edge adjacent to the fragment with smallest weight and that does not create a cycle

1

92

14

8

6

310 115

4

15

13

12

17

18

7

16

7

Property 1: The union of a fragment and any of its MWOE is a fragment of some MST (so called blue rule).

Property 2: If the weights are distinctthen the MST is unique

Two important properties for building MST

8

Property 1: The union of a fragment FT and any of its MWOE is a fragment of some MST.

Proof: Distinguish two cases:1. the MWOE belongs to T2. the MWOE does not belong to TIn both cases, we can prove the

claim.

9

eMWOE

Fragment

MST T

F

Case 1: Te

10

eMWOE

Fragment}{eFF

MST T

Trivially, if then is a fragment Te }{eF

11

ex )()( xwew

MWOE

Fragment

F

MST T

Case 2: Te

12

ex )()( xwew

Fragment

F

MST T

If Te then add to e T and removex

13

ex)()( xwew

Fragment

F

But w(T’) w(T), since T is an MST

w(T’)=w(T), i.e., T’ is an MST

Obtain T’

w(T))w(T'

and since

14

e

Fragment

thus is a fragment of T’

}{eFF

}{eF END OF PROOF

MST T’

15

Property 2: If the weights are distinctthen the MST is unique

Proof: Basic Idea:

Suppose there are two MSTs

Then there is another MST of smaller weight

contradiction!

16

Suppose there are two MSTs

17

Take the smallest weight edge not in intersection

e

18

e

Cycle in RED MST

19

e

Cycle in RED MST

e

e’: any red edge not in BLUE MST

( since blue tree is acyclic)

20

e

Cycle in RED MST

e

)()( ewew Since is not in the intersection,e

(the weight of is the smallest)e

21

e

Cycle in RED MST

e

)()( ewew

Delete and add in RED MST e e

we obtain a new tree with smaller weight

contradiction! END OF PROOF

22

Prim’s Algorithm (sequential version)

Start with a node as an initial fragment

Augment fragment with a MWOE

Repeat

F

F

Until no other edge can be added to F

23

1

92

14

8

6

310 115

4

15

13

12

Fragment F

17

18

7

16

24

1

92

14

8

6

310 115

4

15

13

12

Fragment F

MWOE

17

18

7

16

25

1

92

14

8

6

310 115

4

15

13

12

Fragment F

MWOE

18

7

16

26

1

92

14

8

6

310 115

4

15

13

12

Fragment F

17

MWOE

18

7

16

27

Fragment F

1

92

14

8

6

310 115

4

15

13

12

17

18

7

16

28

Theorem: Prim’s algorithm gives an MST

Proof: Use Property 1 repeatedly

END OF PROOF

29

Prim’s algorithm (distributed version)• Works by repeatedly applying the blue rule to a single

fragment, to yield the MST for G• Works with both asynchronous and synchronous non-

anonymous, uniform models (and also with non-distinct weights)

Algorithm (asynchronous high-level version):Let vertex r be the root as well as the first fragmentREPEAT

• r broadcasts a message on the current fragment to search for the MWOE of the fragment (each vertex in the fragment searches for its local (i.e., adjacent) MWOE)

• convergecast (i.e., reverse broadcast towards r) the MWOE of the appended subfragment (i.e., the minimum of the local MWOEs of itself and its descendents)

• the MWOE of the fragment is then selected by r and added to the fragment, by sending an add-edge message on the appropriate path

• then, the root and nodes adjacent to that just entered in the fragment are notified the edge has been added

UNTIL there is only one fragment left

30

Local description of asynchronous Prim

Each processor stores:1. The state of any of its incident edges,

which can be either of {basic, branch, reject}

2. Its own state, which can be either {in, out}

3. Local MWOE 4. MWOE for each branch-down edge5. Parent channel (route towards the root)6. MWOE channel (route towards the

MWOE of its appended subfragment)

31

Type of messages in asynchronous Prim1. Search MWOE: coordination message initiated by

the root2. Test: check the status of a basic edge3. Reject, Accept: response to Test4. Report(weight): report to the parent node the

MWOE of the appended subfragment5. Add edge: say to the fragment node adjacent to

the fragment’s MWOE to add it6. Connect: perform the union of the found MWOE to

the fragment (this changes the status of the corresponding end-node from out to in)

7. Connected: notify the root and adjacent nodes that connection has taken place

Message complexity = O(n2)

32

Synchronous Prim

It will work in O(n2) rounds…think to it by yourself…

33

Kruskal’s Algorithm (sequential version)

Initially, each node is a fragment

• Find the smallest MWOE e of all fragments• Merge the two fragments adjacent to e

Repeat

Until there is only one fragment left

34

1

92

14

8

6

310 115

4

15

13

12

17

Initially, every node is a fragment

18

7

16

35

1

92

14

8

6

310 115

4

15

13

12

17

Find the smallest MWOE

18

7

16

36

1

92

14

8

6

310 115

4

15

13

12

17

Merge the two fragments

18

7

16

37

1

92

14

8

6

310 115

4

15

13

12

17

Find the smallest MWOE

18

7

16

38

1

92

14

8

6

310 115

4

15

13

12

17

Merge the two fragments

18

7

16

39

1

92

14

8

6

310 115

4

15

13

12

17

Merge the two fragments

18

7

16

40

Resulting MST

1

92

14

8

6

310 115

4

15

13

12

17

18

7

16

41

Theorem: Kruskal’s algorithm gives an MST

Proof: Use Property 1, and observe that no cycle is created.

END OF PROOF

42

Synchronous GHS AlgorithmDistributed version of Kruskal’s Algorithm• Works by repeatedly applying the blue rule to

multiple fragments• Works with non-uniform models, distinct

weights, synchronous start

Initially, each node is a fragment

•Each fragment – coordinated by a fragment root node - finds its MWOE

•Merge fragments adjacent to MWOE’s

Repeat in parallel:

Until there is only one fragment left

(Synchronous Phase)

43

Local description of syncr. GHS

Each processor stores:1. The state of any of its incident edges, which

can be either of {basic, branch, reject} 2. Identity of its fragment (the weigth of a core

edge – for single-node fragments, the proc. id )

3. Local MWOE4. MWOE for each branching-out edge5. Parent channel (route towards the root)6. MWOE channel (route towards the MWOE of

its appended subfragment)

44

Type of messages

1. New fragment(identity): coordination message sent by the root at the end of a phase

2. Test(identity): for checking the status of a basic edge

3. Reject, Accept: response to Test4. Report(weight): for reporting to the parent

node the MWOE of the appended subfragment

5. Merge: sent by the root to the node incident to the MWOE to activate union of fragments

6. Connect(My Id): sent by the node incident to the MWOE to perform the union

45

Phase 0: Initially, every node is a fragment…

1

92

14

8

6

310 115

4

15

13

12

17

18

7

16

… and every node is a root of a fragment

46

1

92

14

8

6

310 115

4

15

13

12

17

Phase 1: Find the MWOE for each node

18

7

16

47

1

92

14

8

6

310 115

4

15

13

12

17

Phase 1: Merge the nodes and select a new root

18

Root

RootRoot

Root

Asymmetric MWOE

Symmetric MWOE

The new root is adjacent to a symmetric MWOE

48

Rule for selecting a new root in a fragment

Fragment 1Fragment 2

root

rootMWOE

Merging 2 fragments

49

Merged Fragment

root

Higher ID Node on MWOE(non-anonymity)

Rule for selecting a new root in a fragment

50

Rule for selecting a new root in a fragment

Merging more than 2 fragments

1F2F

3F

5F

4F 6F

7Frootroot

root

root

root root

root

51

Rule for selecting a new root in a fragment

Higher ID Node on symmetric MWOE

Merged Fragment

Root

asymmetric

52

In merged fragments there is exactly one symmetric MWOE (n-1 edges vs n arrows)

Remark:

Impossible Impossible

1F2F

4F3F

5F

6F

Creates a fragment with two MWOEs

zero two

Creates a fragmentwith no MWOE

1F2F

4F3F

5F

6F

7F

8F

53

After merging has taken place, the new root broadcasts New fragment(w(e)) to the new fragment, and afterwards a new phase starts

ee is the symmetric MWOE of the merged fragments

)(ew

)(ew)(ew

)(ew )(ew)(ew

)(ew

)(ew is the identity of the new fragment

)(ew

)(ew

)(ew )(ew

)(ew)(ew)(ew

)(ew

54

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

1

92

14

8

6

310 115

4

15

13

12

17

18

Root Root

Root

Root

4

End of phase 1

5

1

2

7

16

4

4

1 1

2

2

2

2

2

5

5

55

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

MWOEMWOE

MWOE

MWOE

10

3

15

4

7

25

35 19 22

12

56

10

15

3

To discover its own MWOE, each node sends a Test message containing its identity over its basic edge of min weight, until it receives an Accept

test()accept

test()

6reject

57

10

3

Then it knows its local MWOE

MWOE

58

Then each node sends a Report with the MWOE of the appended subfragment to the root with convergecast (the global minimum survives in propagation)

MWOEMWOE

MWOE

MWOE

10

3

15

4

7

25

35 19 22

12

193 22

73

103

3

59

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

MWOE

10

3

15

4

7

25

35 19 22

12

3

60

1

92

14

8

6

310 115

4

15

13

12

17

18

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

7

16

61

1

92

14

8

6

310 115

4

15

13

12

17

18

7

16

Phase 2: Merge the fragments

Root

Root

62

At the end of phase 2 each fragmenthas its own unique identity.

End of phase 2

1

92

14

8

6

310 115

4

15

13

12

17

18

7

16Root

Root7

97 77

79

9

9 9

9

9

9

63

1

92

14

8

6

310 115

4

15

13

12

17

18

7

16

Phase 3: Find the MWOE for each fragment

64

1

92

14

8

6

310 115

4

15

13

12

17

18

7

16

Phase 3: Merge the fragments

Root

65

Phase 3: New fragment

1

92

14

8

6

310 115

4

15

13

12

17

18

7

16

FINAL MST

66

Correctness• To guarantee correctness, phases must be syncronized• But at the beginning of a phase, each fragment can have a

different number of nodes, and thus the MWOE selection is potentially asynchronous…

• But each fragment can have at most n nodes, has height at most n-1, and each node has at most n-1 incident edges…

• So, the MWOE selection requires at most 3n rounds, and the Merge message requires at most n rounds.

• Then, the Connect message must be sent at round 4n+1 of a phase, and so at round 4n+2 a node knows whether it is a new root

• Finally, the New fragment message will require at most n rounds.

A fixed number of 5n+2 total rounds can be used to complete each phase (in some rounds nodes do nothing…)!

67

Smallest Fragment size (#nodes)Phase

0 1

1 2

2 4

i i2

Complexity

68

Maximum # phases: ni 2log

Maximum possible fragment size ni 2

Number of nodes

Algorithm Time Complexity

Total time = Phase time • #phases =nlog)(nO

)log( nnO

69

Thr: Synchronous GHS requires O(m+n logn) msgs. Proof: We have the following messages:

1. Test-Reject msgs: at most 2 for each edge;

2. Each node sends/receives at most a single: New Fragment, Test-Accept, Report, Merge, Connect message for each phase.

Since from previous lemma we have at most log n phases, the claim follows.

Algorithm Message Complexity

END OF PROOF

70

Asynchronous Version of GHS Algorithm

•Simulates the synchronous version•Works with uniform models, distinct weights, asynchronous start

•Every fragment F has a level L(F)≥0: at the beginning, each node is a fragment of level 0

•Two types of merges: absorption and join

71

Local description of asyncr. GHS

Like the synchronous, but:1. Identity of a fragment is now given by an

edge weight plus the level of the fragment;2. A node has its own status, which can be

either of {sleeping, finding, found}

72

Type of messages

Like the synchronous, but now:

1. New fragment(weight,level,status): coordination message sent just after a merge

2. Test(weight,level): to test an edge3. Connect(weight,level): to perform

the union

73

FragmentFragment

1F 2FMWOE

If then is absorbed by)()( 21 FLFL 1F2F

(cost of merging proportional to )1F

Absorption

74

New fragment

1F 2FMWOE

The combined level is )()( 2FLFL

and a New fragment(weight,level,status) message is broadcasted to nodes of F1 by the node of F2 on which the merge took place

75

MWOE

FragmentFragment

1F 2F

If and F1 and F2 have a symmetric MWOE, then F1 joins with F2

)()( 21 FLFL

(cost of merging proportional to ) 1F 2F

Join

76

New fragment

1F 2FMWOE

The combined level is 1)()( 2,1 FLFL

and a New fragment(weight,L(F2)+1,finding) message is broadcasted to all nodes of F1 and F2, where weigth is that of the edge on which the merge took place

77

Fragment Fragment

1F2FTest

If L(F1)>L(F2), then F1 waits until L(F1)= L(F2) (this is obtained by letting F2 not replying to Test messages from F1 )

Remark: a joining requires that fragment levels are equal…how to control this?

78

Lemma: A fragment of level L contains at least 2L nodes.

Proof: By induction. For L=0 is trivial. Assume it is true up to L=k-1, and let F be of level k. But then, either:

1. F was obtained by joining two fragments of level k-1, each containing at least 2k-1 nodes by inductive hypothesis F contains at least 2k-1 + 2k-1 = 2k nodes;

2. F was obtained after absorbing another fragment F’ of level<k apply recursively to F\F’, until case (1) applies.

Algorithm Message Complexity

END OF PROOF

79

Thr: Asynchronous GHS requires O(m+n logn) msgs. Proof: We have the following messages:

1. Connect msgs: at most 2 for each edge;2. Test-Reject msgs: at most 2 for each

edge;3. Each node sends/receives at most a

single: New Fragment, Test-Accept, Merge, Report message each time the level of its fragment increases;

and since from previous lemma each node can change at most log n levels, the claim follows.

Algorithm Message Complexity (2)

END OF PROOF

80

HomeworkExecute asynchronous GHS on the following graph:

assuming that system is pseudosynchronous: Start from 1 and 5, and messages sent from odd (resp., even) nodes are received after 1 (resp., 2) round(s)

1

9

2

24

8

6

3

10115

4

12

14

18

7

1

4

87

6

2

9

17


Recommended