next up previous contents
Next: ServerConnection Up: ServerMeasure Previous: ServerMeasure   Contents

Calculating the minimum spanning tree

It was decided the most efficient data structure for the RTT information of each server would be a two-dimensional matrix. Since the C++ STL does not contain a suitable data structure for this purpose, LookupTable was written. This class defines operations to set the value of a single cell in the matrix, or update the values of an entire row (it was envisioned that the server would receive a complete row of RTT data from a server, hence it would be more efficient if the entire row could be inserted into the table in one operation). Also for efficiency reasons there are versions of the getValue() and getRow() operations which return the information as an updateable reference. Since this data structure could potentially be useful in other applications, C++'s template system was used to allow the key values and the values stored in the table to be any datatype.

There are two minimum spanning tree algorithms available: Prim and Kruskal[CLR90]. Prim grows a tree from one node, while Kruskal starts with a forest of trees and combines them into a single tree. Prim's algorithm was chosen as it is more space efficient and time efficient than Kruskal. For $N$ servers, Kruskal requires $N$ initial sets, with each one having some fixed overhead. In contrast Prim requires just two sets of nodes: servers that are in the tree and servers that are not yet in the tree.

Prim's algorithm will examine the same number of edges as Kruskal, but because it only adds edges to the priority queue as they are required (i.e. when it adds a new node to the tree it only adds to the priority queue those edges that go from that node to other nodes not already in the tree) it will require less lookups into the table to extract the edge information. These intuitions are supported by the analysis in [CLR90] which demonstrates that Prim has running time $O(E\ lg\ N)$ and Kruskal $O(E\ lg\ N)$. While these are asymptotically equal, in this program the total interconnect between nodes means that the number of edges, $E \approx N^2$, making Prim just a little quicker.


next up previous contents
Next: ServerConnection Up: ServerMeasure Previous: ServerMeasure   Contents
Nathan Dimmock 2001-06-20