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. load data.dat; graph_data; %Plots original points [clusters,dist,hubs] = setup(data); %Clusters all points around first point counter =1; %Keeps track of number of the present number of hubs continue = 1; % 1=true 0=false indicates whether to continue forming new %hubs while continue counter = counter + 1; % adding new hub [m,i]=max(dist); %m= maximum value in the distance array %i is the location of the maximum value in the % array hubs(counter)=i; %assigns index to new hub [dist,clusters] = recluster(data,dist,clusters,i); %Clusters points %to nearest hub pause redraw %Draws new clusters maxdist=max(dist); %returns distance of point farthest from its hub continue = farout(counter,hubs,data,maxdist); %Checks the stop condition end