Minimum Spanning Trees
Gallagher-Humblet-Spira (GHS)
Algorithm
1
Weighted Graph
14
1
7
16
4
9
15
12
6
13
10
5
17
8
11
w (e ) 6
2
3
2
(MST)
Minimum weight spanning tree
14
1
7
13
16
4
12
18
9
15
10
5
8
11
17
6
2
3
The sum of the weights is minimized
For MST T : w (T ) w (e ) is minimized
e T
3
Spanning tree fragment:
14
1
7
13
16
4
12
18
9
15
10
5
17
8
11
6
2
3
Any (connected) sub-tree of a MST
4
Minimum weight outgoing edge (MWOE)
14
1
7
13
16
4
12
18
9
15
10
5
17
8
11
6
2
3
The adjacent edge to the fragment with the
smallest weight that does not create a cycle 5
Two important properties for building MST
Property 1: The union of a fragment and
its MWOE is a fragment (so
called blue rule).
Property 2: If the weights are unique
then the MST is unique
6
Property 1: The union of a fragment and
its MWOE is a fragment
Proof: Basic idea: we distinguish two cases:
1. the MWOE belongs to the MST
2. the MWOE does not belong to the
MST
In both cases, we can prove the
claim.
7
Case 1: e T
Fragment
F
MWOE
MST T
e
8
Trivially, if e T then F {e } is a fragment
Fragment
F F {e }
MWOE
MST T
e
9
Case 2: e T
Fragment
F
MST T
MWOE
x
e
w (e ) w (x )
10
If e T then add
e to T and remove x
Fragment
F
MWOE
MST T
x
e
w (e ) w (x )
11
Fragment
F
Obtain T’
and since
w (e ) w (x )
x
e
w(T' ) w(T)
w(T' ) w(T)
Since otherwise, T
wouldn’t be MST
12
Fragment
F F {e }
e
MST T’
thus F {e } is a fragment of T’
END OF PROOF
13
Property 2: If the weights are unique
then the MST is unique
Proof:
Basic Idea:
Suppose there are two MST
Then there is another MST
of smaller weight
Contradiction!
14
Suppose there are two MST
15
Take the smallest weight edge
not in intersection
e
16
Cycle in RED MST
e
17
Cycle in RED MST
e
e
e’: any red edge not in BLUE MST
( since blue tree is acyclic)
18
Cycle in RED MST
e
e
Since e is not in intersection, w (e ) w (e )
(the weight of e is the smallest)
19
w (e ) w (e )
Cycle in RED MST
e
e
Delete e and add e in RED MST
We obtain a new tree with smaller weight
Contradiction!
END OF PROOF 20
Prim’s Algorithm (sequential version)
Start with a node as an initial fragment F
Repeat
Augment fragment F with the MWOE
Until no other edge can be added to F
21
Fragment F
14
1
7
13
16
4
12
18
9
15
10
5
17
8
11
6
2
3
22
Fragment F
7
MWOE
14
1
13
16
4
12
18
9
15
10
5
17
8
11
6
2
3
23
Fragment F
MWOE
7
14
1
13
16
4
12
18
9
15
5
10
8
11
6
2
3
24
Fragment F
MWOE
14
1
7
13
16
4
12
18
9
15
10
5
17
8
11
6
2
3
25
Fragment F
14
1
7
13
16
4
12
18
9
15
10
5
17
8
11
6
2
3
26
Theorem:
Proof:
Prim’s algorithm gives an MST
Use Property 1 repeatedly
END OF PROOF
27
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
uniform models (and also with non-unique weights)
Algorithm:
1. let vertex r be the root as well as the first fragment
2. (synchronous case) 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” MWOE)
3. convergecast (reverse broadcast) the local MWOE’s
(each vertex sends the minimum it has seen) towards r
4. the MWOE is then selected by r and added to the
fragment, by sending a connect message on the right
path.
Complexity: (time =) message = O(n2)
28
Local description of syncr. 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. Parent channel (route towards the root)
5.
MWOE channel (route towards the MWOE of its appended
subfragment)
Type of messages:
1. (synchronous case) Search MWOE: coordination
message
2. Test: for checking the status of an edge
3. Reject, Accept: response to Test
4. Report(weight): for finding the MWOE
5. Add edge: to add the fragment’s MWOE
6. Connect: to perform the union of the MWOE to the
fragment (this changes status of a node from out to in).29
Kruskal’s Algorithm (sequential version)
Initially, each node is a fragment
Repeat
Find the smallest MWOE e of all fragments
Merge the two fragments adjacent to e
Until there is one fragment
30
Initially, every node is a fragment
14
1
7
13
16
4
12
18
9
15
10
5
17
8
11
6
2
3
31
Find the smallest MWOE
14
1
7
13
16
4
12
18
9
15
10
5
17
8
11
6
2
3
32
Merge the two fragments
14
1
7
13
16
4
12
18
9
15
10
5
17
8
11
6
2
3
33
Find the smallest MWOE
14
1
7
13
16
4
12
18
9
15
10
5
17
8
11
6
2
3
34
Merge the two fragments
14
1
7
13
16
4
12
18
9
15
10
5
17
8
11
6
2
3
35
Resulting MST
14
1
7
13
16
4
12
18
9
15
10
5
17
8
11
6
2
3
36
Theorem:
Kruskal’s algorithm gives an MST
Proof: Use Property 1, and observe that no
cycle is created.
END OF PROOF
37
Synchronous GHS Algorithm
Distributed version of Kruskal’s Algorithm
•Works by repeatedly applying the blue rule to
multiple fragments, to yield the MST for G
•Works with non-uniform models, unique weights
Initially, each node is a fragment
Repeat in parallel: (Synchronous Phase)
Each fragment finds its MWOE
Merge fragments adjacent to MWOE’s
Until there is one fragment
38
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 an
edge)
3. “Local” MWOE
4. Parent channel (route towards the root)
5. MWOE channel (route towards the MWOE of
its appended subfragment)
39
Type of messages
1. New fragment(identity): coordination
message sent at the end of a phase
2. Test(identity): for checking the status of
an edge
3. Reject, Accept: response to Test
4. Report(weight): for finding the MWOE
5. Merge: send by the root to the node
incident to the MWOE to activate union
of fragments
6. Connect(My Id): to perform the union
40
Phase 0: Initially, every node is a fragment…
14
1
7
13
16
4
12
18
9
15
10
5
17
8
11
6
2
3
… and every node is a root of a fragment
41
Phase 1: Find the MWOE for each fragment
14
1
7
13
16
4
12
18
9
15
10
5
17
8
11
6
2
3
42
Phase 1: Merge the fragments and select a new root
Root
Root
14
1
13
4
12
18
9
15
10
5
17
Root
8
11
6
2
3
Root
symmetric MWOE
Asymmetric MWOE
The new root is adjacent to a symmetric MWOE
43
Rules for selecting a new root in a fragment
Fragment 2
Fragment 1
root
MWOE
root
Merging 2 fragments
44
Rules for selecting a Root in fragment
Merged Fragment
root
Higher ID Node
on MWOE
45
Rules for selecting a Root in fragment
F2
root
root
F3
F1
F7
F4
root
F5
root
F6
root
root
root
Merging more than 2 fragments
46
Rules for selecting a Root in fragment
Merged Fragment
Root
Higher ID Node
on symmetric MWOE
asymmetric
47
Remark:
In merged fragments there is
exactly one symmetric MWOE
two
zero
F1
F2
F3
F4
F1
F2
F3
F4
F7
F5
F5
F6
Impossible
Creates a fragment
with no MWOE
F6
F8
Impossible
Creates a fragment
with two MWOE
48
e is the symmetric MWOE of the merged fragments
After merging has taken place, the new root
broadcasts New fragment(w(e)) to the new
fragment
w (e )
w (e )
w (e )
w (e )
e
w (e )
w (e )
w (e )
w (e )
w (e )
w (e )
w (e )
w (e )
w (e )
w (e )
w (e )
w (e )
is the identity of the new fragment
49
And so, at the end of a phase each fragment
has its own unique identity.
4
1
Root
7
4
1
4
4
1
Root 14
1
13
16
15
5
5
Root
End of phase 1
10
5
12
5
9
17
2
18
2
11
2
6
8
3
2
2
2
2
Root
50
Phase 2: Find the MWOE for each fragment
14
1
7
13
16
4
12
18
9
15
10
5
17
8
11
6
2
3
51
Phase 2: Merge the fragments
Root7
14
1
13
16
4
15
12
10
5
17
18
Root
9
8
11
6
2
3
52
At the end of a phase each fragment
has its own unique identity.
7
Root7
7
7
15
10
End of phase 2
17
6
Root18
9
5
9
9
13
9
12
14
7
16
4
7
1
9
11
8
3
2
9
9
9
9
53
Phase 3: Find the MWOE for each fragment
14
1
7
13
16
4
12
18
9
15
10
5
17
8
11
6
2
3
54
Phase 3: Merge the fragments
14
1
7
13
16
4
12
18
9
15
10
5
17
8
11
6
2
3
Root
55
Phase 3: New fragment
14
1
7
13
16
4
12
18
9
15
10
5
8
11
17
6
2
3
FINAL MST
56
At the beginning of each phase each
node in fragment finds its MWOE
MWOE
10
15
MWOE
7
3
25
12
4
MWOE
35
19
MWOE
22
57
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()
3
10
accept
15
test()
6
reject
58
Then it knows its “local” MWOE
10
MWOE
3
59
Then each node sends a Report with its local MWOE
to the fragment root with convergecast
(the global minimum survives in propagation)
MWOE
10
10
3
3
15
3
3
4
MWOE
7
19
3
MWOE
7
25
22
12
35
19
MWOE
22
60
The root selects the minimum MWOE and sends along
the right path a Merge message, which will become a
Connect message at the right node
3
10
15
7
3
25
12
4
MWOE
35
19
22
61
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 asyncronous…
• But each fragment can have at most n nodes, has height at
most n, and each node has at most n 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!
62
Complexity
Phase
Smallest Fragment size
(#nodes)
0
1
1
2
2
4
i
2
i
63
Algorithm Time Complexity
Maximum possible fragment size 2i n
Maximum # phases: i log2 n
Number of
nodes
Total time = Phase time • #phases = O (n logn )
logn
O (n )
64
Algorithm Message Complexity
Thr: Synchronous GHS requires O(|E|+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.
END OF PROOF
65
Asynchronous Version of GHS Algorithm
•Simulates the synchronous version
•Works with uniform models, unique weights
•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
66
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}
67
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 edge
3. Connect(weight,level): to perform the
union
68
Absorption
Fragment
Fragment
F1
MWOE
F2
If L(F1 ) L(F2 ) then F1 is absorbed by F2
(cost of merging proportional to F1 )
69
The combined level is L(F ) L(F2 )
New fragment
F1
MWOE
F2
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
70
Join
Fragment
Fragment
F1
MWOE
F2
If L(F1 ) L(F2 ) then F1 joins with
F2
(cost of merging proportional to F1 F2 )
71
The combined level is L(F ) L(F2 ) 1
New fragment
F1
MWOE
F2
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
72
Remark: the cost of joining would be
proportional to F1 for every small joined
fragment, and this would be inefficient!!
Fragment
F1
Fragment
MWOE
F2
If L(F1 ) L(F2 ) then F1 waits until previous
rules apply (this is obtained by letting F2
not replying to Test messages from F1 )
73
Algorithm Message Complexity
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 F apply recursively to
F\F’, until 1. applies.
END OF PROOF
74
Algorithm Message Complexity (2)
Thr: Asynchronous GHS requires O(|E|+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.
END OF PROOF
75
Homework
Execute asynchronous GHS on the following graph:
18
2
3
4
2
4
1
17
11
9
7
8
8
24
14
5
10
6
6
1
9
7
12
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)
76
© Copyright 2026 Paperzz