view phase2/depthCheck.m @ 16:4a8ec6c461a0

adding depth checking for recursive tree - feature search - though has a bug where it sometimes get stuck in an infinite loop and I dont know why
author DaveM
date Thu, 16 Feb 2017 10:07:42 +0000
parents
children 203626c7e0af
line wrap: on
line source
function linkList = depthCheck(linkList)

listSize = size(linkList,1)+1;

linkList = cat(2,linkList, zeros(size(linkList,1),1));
currentRow = size(linkList,1);
r = [0;0];
% depth = 1;

linkList(currentRow,end) = 1;
% depth = depth + 1;
%%
while (~isempty(currentRow))
    row = currentRow(1);
    for i = 1:2
        r(i) = linkList(row,i);
        if(r(i) > listSize)
            r(i) = linkList(row,i) - listSize;
            linkList(r(i),end) = linkList(currentRow(1),end)+1;
            currentRow = [currentRow; r(i)];
        end
    end
    currentRow = currentRow(2:end);
end
end



% linkList = aglomCluster(data);
% listSize = size(data,1);
% 
% % linkList(:,4) = 0;
% featureList = cell(listSize-1,1);
% currentRow = [2*listSize-1];
% 
% %%
% while (~isempty(currentRow))
%     if(currentRow(1) > listSize) 
%         row = currentRow(1) - listSize
%         classList = traceLinkageToBinary(linkList, row);
%         featureList{row} = rfFeatureSelection(data(classList>0,:), classList(classList>0));
%         currentRow = [currentRow(2:end); linkList(row,1); linkList(row,2)];
%     else
%         currentRow = currentRow(2:end);
%     end
% end
% 
% end