function [newNodes] = CreateNewNodesFromClusters(data, test_clustering, noiseNumAddedPHs)

% Sigal 5.12.13:
% add additinal parameters noiseNumAddedPHs
% if noiseNumAddedPHs > 0, i.e. the last # PHs are noise
% thus need to be ignored

% sigal - backwards compatibility
if nargin < 3   
   noiseNumAddedPHs = 0; 
end

if noiseNumAddedPHs < 0
    fprintf('>>>> ERROR: CreateNewNodesFromClusters - Invalid noiseNumAddedPHs=%d !!!!\n',noiseNumAddedPHs);
    return;
end

n = size(data,2)-noiseNumAddedPHs; 
m = max(test_clustering);
newNodes = sparse(m,n);

last_known_node = n - size(test_clustering,1);

for i = 1 : size(test_clustering,1)    
    current_cluster = test_clustering(i);
    %   folding all the placeholders rows of the same cluster into one row (by
    %   using "OR" between them)
    newNodes(current_cluster, 1:n) =  newNodes(current_cluster, 1:n) | data(last_known_node + i, 1:n); 
end




end