function final = streemer(dataname, threshold1, threshold2, num_clusters, percent_bg, minsize_guess, resultname)

% The Streemer clustering algorithm.
%
% dataname is the filename of the dataset
% resultname is the filename under which the results will be saved
%
% data is a m by n sparse matrix, with m as feature numbers and n as
% element numbers 
%
% cluster is a n by n sparse matrix, with columns as clusters and rows
% as elements
%
% cen is a m by n sparse matrix, with m as feature numbers and n as
% cluster numbers
%
% newCluster is a n-dim vector, with n as cluster numbers


%    Copyright (C) 2007  Vasileios Kandylas, Peng Bi.
%
%    This file is part of Streemer.
%
%    Streemer is free software: you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as published by
%    the Free Software Foundation, either version 3 of the License, or
%    (at your option) any later version.
%
%    This program is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.
%
%    You should have received a copy of the GNU General Public License
%    along with this program.  If not, see <http://www.gnu.org/licenses/>.


%get L2-normalized data
%also transposes the input, so that vectors are columns
data = init(dataname);


% Step1
fprintf('step1...\n');
[cluster, cen] = step1(data, threshold1); 

% Step2
fprintf('step2...\n');
[newCluster, minsize] = step2(data, cluster, cen, threshold2, num_clusters, minsize_guess);


% Step3
fprintf('step3...\n');
final = step3(data, cen, newCluster, percent_bg, resultname);

