function PreOrder = PreOrderRecursiveAlg(ChildrenList,PreOrder)
%PreOrder = PreOrderRecursiveAlg(ChildrenList,PreOrder)
%Input: ChildrenList: m + 1 column matrix (of integers) for an m-ary tree
%Output: PreOrder: a vector containing the preorder list of the vertices
if nnz(ChildrenList)>0 %tree is nonempty
PreOrder = [PreOrder ChildrenList(1,1)];
end
if nnz(ChildrenList)> 1 %root has children
ChildChildrenLists = ChildTrees(ChildrenList);
[r c s] = size(ChildChildrenLists); % s = number of children trees
for i = 1:s
PreOrder = PreOrderRecursiveAlg(ChildChildrenLists(:,:,i),PreOrder);
end
end