DaveM@16: function linkList = depthCheck(linkList) DaveM@19: %% linkList = depthCheck(linkList) DaveM@19: % depthCheck will extend a linkList, created by the linkages algorithm, and DaveM@19: % append an extra column on the end which indicated the depth of the DaveM@19: % linkage, so the top level is 1, and each following level is the number of DaveM@19: % links needed to get to the top level - which could be considered the DaveM@19: % number of rules that exist. DaveM@19: % DaveM@19: % The other method for measuring depth would be DaveM@19: % to look at the value of the linkage distance - thresholding and grouping DaveM@19: % the linkage distances could be beneficial for some analysis. DaveM@16: DaveM@16: listSize = size(linkList,1)+1; DaveM@16: DaveM@16: linkList = cat(2,linkList, zeros(size(linkList,1),1)); DaveM@16: currentRow = size(linkList,1); DaveM@16: r = [0;0]; DaveM@16: % depth = 1; DaveM@16: DaveM@16: linkList(currentRow,end) = 1; DaveM@16: % depth = depth + 1; DaveM@16: %% DaveM@16: while (~isempty(currentRow)) DaveM@16: row = currentRow(1); DaveM@16: for i = 1:2 DaveM@16: r(i) = linkList(row,i); DaveM@16: if(r(i) > listSize) DaveM@16: r(i) = linkList(row,i) - listSize; DaveM@16: linkList(r(i),end) = linkList(currentRow(1),end)+1; DaveM@16: currentRow = [currentRow; r(i)]; DaveM@16: end DaveM@16: end DaveM@16: currentRow = currentRow(2:end); DaveM@16: end DaveM@16: end DaveM@16: