annotate phase2/traverseDownOneStep.m @ 8:b177d57ac0bd

adding function to traverse down linkages file and provide classification for each part of the tree
author DaveM
date Fri, 10 Feb 2017 08:28:22 +0000
parents
children d0bd98e7b6c9
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 leaf1 = linkList(row,1);
DaveM@8 14 leaf2 = linkList(row,2);
DaveM@8 15
DaveM@8 16 if(leaf1 > listSize)
DaveM@8 17 leaf = traverseDownOneStep(linkList,leaf,leaf1);
DaveM@8 18 else
DaveM@8 19 leaf = cat(1,leaf,leaf1);
DaveM@8 20 end
DaveM@8 21
DaveM@8 22 if(leaf2 > listSize)
DaveM@8 23 leaf = traverseDownOneStep(linkList,leaf,leaf2);
DaveM@8 24 else
DaveM@8 25 leaf = cat(1,leaf,leaf2);
DaveM@8 26 end
DaveM@8 27
DaveM@8 28 end