function [energyArr,dataMapArr] =kMain(data,boxExtreme,iter)

rand('state',sum(100*clock));
iterations = iter;

energyArr = zeros(iterations,1);
dataMapArr = zeros(iterations,size(data,1));

% M = moviein(n-1);


for(i=1:iterations)
	i
	if(i == 1)
		[centroids, energy,dataMap]=kClusters(i,data,boxExtreme,0,realmax);
	end
	if(i > 1)
		[centroids, energy,dataMap]=kClusters(i,data,boxExtreme,centroids,energy);
	end

	% 	plot(centroids(:,1),centroids(:,2), 'bo', data(:,1),data(:,2),'mx')
	% 	pause
	% 	M(:,i-1) = getframe;	
	
	energyArr(i)=energy;
	dataMapArr(i,:) = dataMap;
end

% movie(M,-20)
% save M


% for i=1:10
% 	cellGenerators = cvtIteration(boxExtreme, cellGenerators,50);
% end
disp('done')

centroids
