function tree=tree2lst(a)
% chtreetype converts adjacency matrix of a tree to structure array
% tree(i) with fields ch-arrays of childrens of the i-th node
if nargin~=1
    error('incorrect number of input arguments');
end
if nargout~=1
    error('incorrect number of output arguments');
end    
n=size(a,1);
tree=[];
nl=0;
    for i=1:n
        for j=i:n
            
            if  abs(a(i,j))~=inf
                value=a(i,j);
                tree=[tree;i,j,value];
                
            end
        end
    end
    k=1;
   for i=2:size(tree,1)
       x=tree(i,:);
       j=i-1;flag=false;
       while x(3)<tree(j,3)
           k=k+1;
           flag=true;
           tree(j+1,:)=tree(j,:);
           j=j-1;
           if j<1
               j=0;
               break;
           end
       end
       if flag==true
           tree(j+1,:)=x;
           k=k+1;
       end
   end
   