The
Matlab Program
The documented code below executes the clustering algorithm and plots the
points as the algorithm proceeds. Each cluster will be a different color.
 cluster.m
Cluster reads data from a file called data.dat. It will arbitrarily
choose one point to be a hub and cluster all the points around this hub.
It then finds the point farthest away from the hub and makes this point a
new hub. Next it clusters the data around the hub it is nearest. This
process is repeated until the distance from every point to its hub is
less than half the average distance between all pairs of hubs.
 setup.m
This function assigns to the cluster array all ones, (telling that
all points belong to Hub 1), assigns to the hub array a one in
position 1 (telling that the first hub is point 1) and zeros in all
other locations. The distance array contains the square of the
distance from each point to hub one.
 distance.m
This finds the square of the distance between each point and its hub
d = data coordinates of points; c = cluster array contains index
of hub to which point is assigned; c(i)=j point i belongs to the
cluster whose hub is point j
 recluster.m
Reassigns each point to the nearest hub
 farout.m
Calculates stop condition. Stops if the point farthest from its
hub is within the average distance value.
 graph_data.m
Plots the points and draws the axes
 redraw.m
Redraw draws the points so that each cluster is a different color.
The hubs are represented by a + and the members are represented by a *.
 data.dat Gives a sample data set that corresponds to the algorithm as described on A Clustering Algorithm.
