Saral Shiksha Yojna
Courses/Distributed Systems

Distributed Systems

CS3.401
Prof. Kishore KothapalliMonsoon 2025-264 credits
Revision Notes/Unit 10 — Distributed Minimum Spanning Tree (GHS Algorithm)/GHS Rules A/B/C + Fragment Levels + Test/Accept/Reject

GHS Rules A/B/C + Fragment Levels + Test/Accept/Reject

NotesStory

Intuition

Computing a minimum spanning tree centrally is easy (Prim, Kruskal). Doing it without a central coordinator — each node only knows its incident edges and their weights — is harder. GHS is distributed Kruskal: many small fragments grow in parallel, repeatedly absorbing or merging via their minimum outgoing edge (MWOE). Three combining rules manage the growth: smaller fragments rush into larger ones immediately (A); equal-level fragments merge only if they both chose the same edge (B); otherwise wait (C).

Explanation

MST definition + uniqueness. For a weighted graph with nodes, a spanning tree has edges connecting all nodes. The MST has minimum total edge weight. If all edge weights are distinct, the MST is unique.

Two fundamental MST properties. Cycle property: for any cycle in , the heaviest edge in does NOT appear in the MST. (Rules edges OUT.) Cut property: for any proper non-empty subset of vertices, the lightest edge with exactly one endpoint in belongs to the MST. (Rules edges IN.) GHS is built on the cut property.

Proof of cut property (sketch). Suppose the lightest edge crossing the cut were NOT in MST . Adding to creates a unique cycle; some other edge in also crosses the cut. is still a spanning tree; . Contradicts minimality. ∎

Fragment — definition. A *fragment* is a subtree of some MST. Key lemma: if is a fragment and is the minimum-weight outgoing edge (MWOE) of (lightest edge with exactly one endpoint in ), then is also a fragment. This is the heart of GHS.

Classical MST algorithms — analogy. Prim's: grow a single fragment by repeatedly adding its MWOE. Kruskal's: start with single-node fragments; merge fragments by adding the MWOE of some fragment. GHS is the distributed analogue of Kruskal's — many fragments grow in parallel.

Assumptions of GHS. Each edge has a unique weight (or use tiebreaker like the pair of node IDs). Reliable, bidirectional communication channels. All nodes initially asleep; on receiving any message, a node first runs the local initialisation procedure.

High-level outline of GHS. (1) Start with each node as a level-0, one-node fragment. (2) Nodes in a fragment cooperate to find the fragment's MWOE. (3) Combine the fragment with the one on the other side of the MWOE. (4) Terminate when only one fragment remains.

Fragment naming and levels. Each fragment has a name (FN) and a level, both initially 0. The fragment's core edge is the most recently used combining edge; its weight is the new fragment name.

Three combining rules (A, B, C) — high-yield. Fragment with MWOE leading to neighbour fragment . Rule A (Absorption): if absorbs into . New fragment takes 's name and level. 's nodes informed via initiate. Rule B (Merger): if AND 's MWOE is also (mutual choice) — merge into a new fragment of level and name . Rule C (Wait): otherwise — wait until Rule A or B applies.

Combining rules intuition. Smaller fragments rush into larger ones immediately (don't slow the bigger one down). Equal fragments merge only if mutual MWOE (avoid premature merging). Larger fragments wait if other side is smaller and not pointing at the same edge (other side will grow and re-evaluate).

Node and edge state variables. — basic = undecided; branch = in MST; reject = known non-MST. — find = currently searching for MWOE; found = done. — pointer towards the core edge. Plus .

Five message types in GHS. connect ⟨L⟩ — request to combine fragments. initiate ⟨L, F, state⟩ — broadcast inside a fragment to inform of new level/name and to start a new MWOE search. test ⟨L, F⟩ — sent across a candidate edge to check whether the other end is in a different fragment. accept / reject — replies to a test. report ⟨w⟩ — child reports its sub-fragment's MWOE up to its parent. changeroot — sent from the core edge down to the node incident on the MWOE, to instruct it to send connect.

Test/Accept/Reject mechanism. A node inspects its basic edges in increasing weight order. For each edge , sends test ⟨⟩ to . ** replies: reject** if (same fragment, internal edge); accept if AND ; defer if (because might in fact be in 's fragment but the initiate hasn't arrived yet).

Test/Reject optimisation. If sent a test to and sent a test to , only ONE reject is needed — the other end can locally mark the edge rejected. Without this, two rejects would be exchanged.

Reporting the MWOE. Each fragment node reports the minimum (report ⟨⟩) of its own MWOE candidate and its children's reports UP toward the core. The two endpoints of the core edge each receive a report from their subtree; the side whose minimum is smaller initiates a changeroot, which travels along bestch pointers to the node incident on the MWOE; that node then sends connect ⟨⟩ along the MWOE.

Termination. When both endpoints of the core edge have reported (no outgoing edges found anywhere), the algorithm halts — only one fragment remains, which is the MST.

Max level a node can reach. Level grows only when fragments combine. Level requires nodes (two level- fragments merging by Rule B). Therefore for nodes, **max level **.

Complexity of GHS. Messages: , where = number of edges. The term comes from initiates sent down at each of up to level increases. Time: . Optimal among comparison-based distributed MST algorithms.

Definitions

  • Spanning treeAn acyclic subgraph that connects all vertices using exactly edges.
  • MSTSpanning tree with minimum total edge weight. Unique if edge weights are distinct.
  • Cut propertyFor any non-empty proper subset of vertices, the lightest edge crossing the cut is in the MST. Foundation of GHS.
  • Cycle propertyFor any cycle in , the heaviest edge is NOT in the MST.
  • FragmentA subtree of some MST. Has a (name, level) pair. Initial single-node fragments are level 0 with name = node id.
  • Core edgeThe most recently used combining edge of a fragment (Rule B merger). Its weight becomes the fragment's new name.
  • MWOE (Minimum-Weight Outgoing Edge)Lightest edge of a fragment with exactly one endpoint outside the fragment. Adding it preserves the fragment property.
  • Rule A (absorption) absorbs into , taking 's name and level. Smaller fragment rushes into bigger.
  • Rule B (merger) AND mutual MWOE → merge into new fragment, level , name = .
  • Rule C (wait)Else — wait until conditions for A or B are met.
  • GHS message typesconnect, initiate, test, accept, reject, report, changeroot.
  • Test reply rulesSame fragment → reject. Different fragment AND → accept. Different fragment AND → defer.

Formulas

Derivations

Max level ≤ log N (proof). Level grows only when two equal-level fragments merge (Rule B). A level- fragment is the merger of two level- fragments. By induction, a level- fragment contains nodes. With total nodes, . ∎

Cut property (formal). Let be an MST. Suppose there's a cut and edge with one endpoint in each side, , for every edge crossing the cut. Adding to creates a unique cycle . must use some edge from crossing the cut (else stays in ). Replace with : has and is still a spanning tree. Contradicts minimality. Hence .

Why Rule C (wait). Suppose . If we absorbed immediately, we'd be doing it before confirms its MWOE choice — might be about to merge into a yet-bigger fragment . Better to wait until either: grows to and they share MWOE (Rule B), or chooses our MWOE while we have higher level (Rule A applies in reverse).

Examples

  • Small GHS example, 4 nodes. A, B, C, D with edges A-B (1), B-C (2), C-D (3), A-D (5), A-C (4), B-D (6). Phase 0: 4 fragments, all level 0. Each finds MWOE: A→B(1), B→A(1), C→B(2), D→C(3). A and B mutual choice + equal level → Rule B: merge to {A,B} level 1, name = . C's MWOE is BC(2), wants to join {A,B} (now level 1). C is level 0 < 1 → Rule A: C absorbs into {A,B}; now {A,B,C} level 1. D's MWOE CD(3) → same logic, Rule A: D absorbs. Now {A,B,C,D} level 1. MST = {AB, BC, CD}.
  • Test/Accept/Reject scenario. in fragment level 2 sends test ⟨2, ⟩ on its lightest basic edge to . (a) in same , level 2 → reject. (b) in , level 2 → accept (different fragment, equal level, edge is cross-fragment outgoing candidate). (c) in , level 1 < 2 → defer (q might be about to be in — hasn't received the initiate yet). Once 's level catches up, it answers definitively.
  • Level increment bound (4 nodes max level). With 4 nodes, max possible level is . Indeed: 4 single-node fragments → 2 pair fragments (level 1) → 1 four-node fragment (level 2). Cannot grow further.

Diagrams

  • GHS fragment merger by Rule B: two level- fragments with mutual MWOE → merge to level , name = (the 'core edge').
  • Combining rules table: rows = Rule A / B / C; cols = condition, action, level/name update.
  • Test/Accept/Reject decision tree at : same fragment → reject; diff fragment, → accept; diff, → defer.
  • Message flow on a 4-node example: connect → initiate → test/accept/reject → report → changeroot → connect (next level).
  • Level tree: each level- fragment shown as a subtree of the merger tree; height ≤ log N.

Edge cases

  • Equal-weight edges break uniqueness. Use lex order.
  • Sleeping nodes must initialise on first received message — otherwise they don't participate.
  • Async vs sync semantics — GHS is asynchronous but assumes reliable channels. With unreliable channels, retransmission protocols layer underneath.
  • Test/defer chain — a defer can cascade through multiple levels before resolution; eventually resolved when levels catch up.
  • Network partition during GHS — undefined behaviour without additional fault tolerance; GHS assumes reliable channels.

Common mistakes

  • Saying 'GHS finds MST by Prim's algorithm'. No — GHS is closer to Kruskal's (parallel fragments merging by MWOE).
  • Confusing Rule A and Rule B. A: smaller absorbs into larger (level diff). B: equal level + mutual MWOE → merge to level+1.
  • Saying 'max level = N - 1'. No — max level = . Each level requires doubling fragment size.
  • Forgetting tie-breaking for equal weights. GHS assumes unique edge weights; without a tiebreaker, behaviour is undefined.
  • Saying 'test → accept always means edge in MST'. No — accept means 'different fragment, eligible candidate'; the final MWOE selection happens via report aggregation.

Shortcuts

  • Cut property: lightest edge crossing cut ∈ MST.
  • Rule A: smaller absorbs into larger.
  • Rule B: equal level + mutual MWOE → merge level+1.
  • Rule C: else WAIT.
  • Max level: log N.
  • **Complexity: msgs.**
  • 5 message types: connect, initiate, test, accept/reject, report, changeroot.
  • **Test reply: reject (same F), accept (diff F + ), defer (diff + ).**

Proofs / Algorithms

Cut property formal proof. Let be any MST, non-empty, with the lightest edge crossing the cut, and . Adding to creates a unique cycle . has other edge crossing the cut (else stays inside contradicting acyclicity of ); pick such an edge . Form . is a spanning tree (connected + edges + acyclic). since . Contradicts minimality of . Hence .

**Max level .** By induction on level. Level 0: 1 node. Suppose level- fragments have nodes. A level- fragment results from Rule B merging of two level- fragments → nodes. With total, .

Correctness of GHS — each combining step extends a fragment. By the MWOE lemma, if is a fragment and is its MWOE, is also a fragment. By Rules A and B, each combining step adds the MWOE. Hence GHS always builds fragments that are subtrees of the MST.