Mercurial > hg > sfx-subgrouping
view code/traverseDownOneStep.m @ 37:d9a9a6b93026 tip
Add README
author | DaveM |
---|---|
date | Sat, 01 Apr 2017 17:03:14 +0100 |
parents | 4bdcab1e821c |
children |
line wrap: on
line source
function leaf = traverseDownOneStep(linkList,leaf,row) %% leaf = traverseDownOneStep(linkList,leaf,row) % Recursive function which given a linkList, will search a given row, and % if the row is a leaf, it will append the leaf to the end of the leaf % list, otherwise, it will recursively call the function to identify the % two leaves for the branches it has discovered listSize = size(linkList,1)+1; if(row > listSize) row = row-listSize; end if (row == listSize) leaf = row; else leaf1 = linkList(row,1); leaf2 = linkList(row,2); if(leaf1 > listSize) leaf = traverseDownOneStep(linkList,leaf,leaf1); else leaf = cat(1,leaf,leaf1); end if(leaf2 > listSize) leaf = traverseDownOneStep(linkList,leaf,leaf2); else leaf = cat(1,leaf,leaf2); end end end