Distributed Minimum Spanning Tree: The GHS Algorithm and Applications
In a distributed network, nodes must routinely exchange messages, synchronize state, and coordinate actions. A naive mechanism to propagate a message across a cluster is network flooding, where a node transmits copies of a message across every outbound connection. Flooding quickly saturates network buffers, wastes link bandwidth, and leads to broadcast storms.
To broadcast messages efficiently without creating cycles or saturating links, distributed systems construct and maintain a Minimum Spanning Tree (MST). In an environment where communication links have varying financial costs, differing latency profiles, or unequal congestion levels, an MST guarantees that every machine in the network is reachable with the minimum possible aggregate edge weight.
However, constructing an MST in a distributed system is fundamentally different from running centralized algorithms like Kruskal’s or Prim’s. In a distributed topology, no single node possesses a global map of the network.
The Gallager-Humblet-Spira (GHS) algorithm solves this problem by using a decentralized, bottom-up approach to construct an MST using local state, message passing, and progressive component merging.
The Centralized vs. Distributed Setting
In classical graph theory, computing an MST assumes an algorithm has complete in-memory access to the entire graph G=(V,E) along with all edge weights w(e).
In a distributed network:
- No Global Topology: Nodes only know their immediate neighbors and the weights of their incident edges.
- Identities: Nodes have unique identifiers (UIDs), and each edge has an assigned weight. For simplicity, assume all edge weights are unique (ties can be broken deterministically using endpoint UIDs).
- Network Size: Nodes only know the total number of machines N in the cluster.
- Goal: Every node must locally decide which of its incident edges are part of the MST (
tree edges) and which are not (rejected edges).
+---------+ e1 (wt: 4) +---------+
| Node A |-----------------------------| Node B |
+---------+ +---------+
| |
| e2 (wt: 2) e3 (wt: 7) |
| |
+---------+ e4 (wt: 1) +---------+
| Node C |-----------------------------| Node D |
+---------+ +---------+
Each node only perceives its local connections and weights without knowing the broader graph topology.
2. The Core Strategy: Forest Merging
The GHS algorithm applies a distributed divide-and-conquer strategy:
- It begins with a spanning forest of N independent trees, where every individual node forms its own isolated tree component at Level 0.
- Iteratively, neighboring components discover the cheapest connection leading outside of themselves—known as the Minimum Weight Outgoing Edge (MWOE).
- Components merge along their mutual MWOEs, creating larger sub-spanning trees at progressively higher levels.
- Merging continues until only a single component remains, which encompasses every node in the network.
graph TD
subgraph Level 0 [Level 0: Isolated Nodes]
A((Node A))
B((Node B))
C((Node C))
D((Node D))
end
subgraph Level 1 [Level 1: Sub-Spanning Trees]
AB((Comp AB))
CD((Comp CD))
end
subgraph Level 2 [Level 2: Final MST]
ABCD((Full MST Component))
end
A & B --> AB
C & D --> CD
AB & CD --> ABCD
3. Step-by-Step Breakdown of the GHS Algorithm
Step 3.1: Component Identification and Levels
Every component (sub-spanning tree) maintains:
- A Component Leader: A designated node representing the component during coordinate-and-merge phases.
- A Component Identifier: Determined by the UID of the component’s leader or the core edge.
- A Level: A non-negative integer indicating the component’s growth stage.
At Level 0, every node is the leader of its own single-node component, and its component ID is its own UID.
Step 3.2: Finding the Minimum Weight Outgoing Edge (MWOE)
To merge safely without introducing cycles, a component must find the lowest-weight edge that connects one of its members to an external component.
sequenceDiagram
autonumber
participant L as Component Leader
participant N as Boundary Node
participant X as Neighbor (Other Comp)
L->>N: Broadcast SEARCH via BFS
N->>X: Send TEST (Leader UID: L)
X-->>N: Respond with its Leader UID: L'
Note over N: If L != L', edge is OUTGOING.
N->>L: Convergecast Local MWOE
Note over L: Leader computes Global Component MWOE
- Search Propagation: The component leader initiates a search by broadcasting a
SEARCH message down the existing tree edges of the component via Breadth-First Search (BFS).
- Local Probing: Upon receiving the
SEARCH message, each node checks its incident edges to find an outgoing edge:
- It sends a
TEST message along an edge, carrying its current component identifier (Leader UID).
- The neighbor replies with its own component identifier.
- If the IDs match, the edge is internal to the same component and is marked as
rejected.
- If the IDs differ, the edge is verified as an outgoing edge.
- Local Minimum Selection: Each node selects the minimum-weight outgoing edge among all its tested incident links.
- Convergecast to Leader: Nodes aggregate their local findings and send them back up the component tree toward the leader using convergecast. Intermediate nodes compare candidate edges from their subtrees and only forward the minimum upstream.
- Global Component Decision: The leader receives all responses, computes the global minimum among all candidate edges, and designates that link as the component’s official MWOE.
Step 3.3: Component Merging and Leader Election
Once the leader identifies the component’s MWOE, it directs the merge operation:
- The leader sends an activation message down the tree to the specific boundary node adjacent to the MWOE.
- The boundary node communicates across the MWOE with the peer boundary node in the neighboring component to finalize the merge.
- Both endpoints mark this edge as a permanent
tree edge of the MST.
Component 1 (Level L1) Component 2 (Level L2)
+-----------------------+ +-----------------------+
| Leader: Node 10 | | Leader: Node 25 |
| | | |
| [Boundary Node 4] |====== MWOE ======= | [Boundary Node 7] |
+-----------------------+ (Weight: 3) +-----------------------+
Resolving the New Component Leader
To avoid complex distributed consensus across the newly merged component, leadership is resolved locally between the two nodes that flank the MWOE:
New Leader=max(UIDNode u,UIDNode v)
The endpoint node with the higher UID becomes the leader of the unified component. This leader then broadcasts its identity and the new component status across all tree edges.
Step 3.4: Level Advancement and Synchronization
Uncontrolled merges can cause distributed deadlocks, livelocks, or race conditions. GHS enforces strict merge semantics based on component levels:
- Equal Levels (L1=L2): When two components at the same level share the same MWOE, they merge to form a new component at level L+1.
- Unequal Levels (L1<L2): A component at a lower level merges into a higher-level component. The resulting component retains the higher level L2, preventing unnecessary level inflation.
Because level increments require balanced merges, a component at level k must contain at least 2k nodes. This mathematical ceiling guarantees stability and bounds total operational rounds.
Step 3.5: Algorithm Termination
A distributed algorithm must establish deterministic termination conditions:
- At the final stage, the entire network belongs to a single component.
- The component leader initiates a standard
SEARCH cycle for the next MWOE.
- All nodes query their neighbors; however, because every node in the graph now shares the same Leader UID, all candidate links are internal.
- Nodes report
null back to the leader via convergecast.
- When the leader evaluates the convergecast and receives
null from all branches, it concludes that no outgoing edges remain.
- The leader halts execution. The edges marked
tree across the entire cluster now form the final Minimum Spanning Tree.
4. Complexity Analysis
| Metric | Complexity | Explanation |
|---|
| Max Component Level | O(logN) | A component at level k contains at least 2k nodes. Thus, the maximum level is ⌊log2N⌋. |
| Time Complexity | O(NlogN) | Each level requires O(N) rounds for BFS search, edge testing, and convergecast aggregation across O(logN) levels. |
| Message Complexity | O((E+N)logN) | At each level, each node sends O(1) messages per incident edge to test boundaries, plus O(N) coordination messages. |
5. Applications of the MST: Efficient Leader Election
Once an MST is established, complex distributed coordination problems become straightforward. One example is Leader Election.
On an arbitrary graph with cycles, leader election requires complex state machines (e.g., Bully algorithm, Paxos, or Ring-based protocols) to prevent duplicate leaders and reconcile partitions. On an MST, leader election can be executed using a single Convergecast pass.
graph BT
Leaf1((Leaf Node 1)) -->|UID: 1| Int1((Internal Node))
Leaf2((Leaf Node 2)) -->|UID: 8| Int1
Int1 -->|max UID: 8| Root((Elected Leader))
Leaf3((Leaf Node 3)) -->|UID: 12| Root
The Convergecast Election Algorithm
- Initiation by Leaf Nodes: Any node with degree 1 in the MST (a leaf node) initiates the election. It forwards its own UID to its single neighbor.
- Internal Node Behavior:
- An internal node with degree d waits until it receives candidate messages from d−1 neighbors.
- It computes the maximum UID among all received candidates and its own UID.
- It transmits this local maximum across the single remaining unvisited edge.
- Termination and Leader Determination:
- Case A (Single Root Peak): An internal node receives election messages from all d of its neighbors without having forwarded one. This node possesses the global maximum UID, elects itself as the cluster leader, and broadcasts the result.
- Case B (Two-Node Tie): In symmetrical or even topologies, two adjacent nodes might send messages to each other concurrently across their shared edge. In this scenario, the node with the higher UID among the two declares itself the leader.
By leveraging the tree structure, leader election completes in O(N) message exchanges without the risk of cycles or split-brain states.
6. Summary and Architectural Takeaways
- Decentralized Coordination: The GHS algorithm constructs a global Minimum Spanning Tree without requiring any single node to maintain the entire network topology.
- Forest Merging: By starting at Level 0 with isolated nodes and repeatedly joining components along their Minimum Weight Outgoing Edge (MWOE), the algorithm builds the MST bottom-up.
- Level Invariants: Enforcing logarithmic level bounds (2k nodes per component at level k) guarantees that the algorithm completes in O(NlogN) time and avoids distributed deadlocks.
- Foundation for Network Primitives: Once an MST is established, downstream protocols—such as low-latency message broadcasts, network multicasting, and convergecast-based leader election—can operate with minimal communication overhead.