Mercurial > hg > sfx-subgrouping
annotate code/traverseDownOneStep.m @ 37:d9a9a6b93026 tip
Add README
author | DaveM |
---|---|
date | Sat, 01 Apr 2017 17:03:14 +0100 |
parents | 4bdcab1e821c |
children |
rev | line source |
---|---|
DaveM@8 | 1 function leaf = traverseDownOneStep(linkList,leaf,row) |
DaveM@8 | 2 |
DaveM@8 | 3 %% leaf = traverseDownOneStep(linkList,leaf,row) |
DaveM@8 | 4 % Recursive function which given a linkList, will search a given row, and |
DaveM@8 | 5 % if the row is a leaf, it will append the leaf to the end of the leaf |
DaveM@8 | 6 % list, otherwise, it will recursively call the function to identify the |
DaveM@8 | 7 % two leaves for the branches it has discovered |
DaveM@8 | 8 |
DaveM@8 | 9 listSize = size(linkList,1)+1; |
DaveM@8 | 10 if(row > listSize) |
DaveM@8 | 11 row = row-listSize; |
DaveM@8 | 12 end |
DaveM@8 | 13 |
DaveM@12 | 14 if (row == listSize) |
DaveM@12 | 15 leaf = row; |
DaveM@8 | 16 else |
DaveM@12 | 17 leaf1 = linkList(row,1); |
DaveM@12 | 18 leaf2 = linkList(row,2); |
DaveM@12 | 19 |
DaveM@12 | 20 if(leaf1 > listSize) |
DaveM@12 | 21 leaf = traverseDownOneStep(linkList,leaf,leaf1); |
DaveM@12 | 22 else |
DaveM@12 | 23 leaf = cat(1,leaf,leaf1); |
DaveM@12 | 24 end |
DaveM@12 | 25 |
DaveM@12 | 26 if(leaf2 > listSize) |
DaveM@12 | 27 leaf = traverseDownOneStep(linkList,leaf,leaf2); |
DaveM@12 | 28 else |
DaveM@12 | 29 leaf = cat(1,leaf,leaf2); |
DaveM@12 | 30 end |
DaveM@8 | 31 end |
DaveM@8 | 32 end |