diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/phase2/traverseDownOneStep.m	Fri Feb 10 08:28:22 2017 +0000
@@ -0,0 +1,28 @@
+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
+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
\ No newline at end of file