function minimaltree=min_tree(nb,ne,res,f1,f2,FontSize,LineWidth);
n=res.dnei;
col=res.col;
a=res.matr;
str=res.str;
logm=zeros(ne-nb+1,col);
for j=1:col
    for i=nb:ne
        logm(i-nb+1,j)=log(a(i,j))-log(a(i-1,j));
    end
end
%for j=1:col
 %   for i=nb:ne-1
 %       logm(i-nb+1,j)=-log(a(i,j))+log(a(i+1,j));
 %   end
 %end
 R=[];
R=corrcoef(logm);
dist=[];
dist=sqrt(2*(1-R));
dist=real(dist);
R1=[];
R1=prim2(dist);
hold on;
%axis off;
d=zeros(1,col);%Array of degrees in a graph.
%max=0;
for i=1:col
    d(i)=0;
    for j=1:col
        if i~=j & R1(i,j)~=inf
        d(i)=d(i)+1;
        end
    end
end
max=0;
nmax=1;
for i=1:col		%Determining the max degree
    if (d(i)>max)
        max=d(i);
        nmax=i;
    end
end		
p=[];
mn=[];
%[mn,x,xx]=pplot(R1,str,0,0,0,nmax,0,0,pi*2,f1,f2,1,mn);
%[mn,x,xx]=pplot(R1,str,0,0,0,nmax,0,0,pi*2,f1,f2,1,mn);
%x=length(mn);
%minimaltree=mn;
%treeplot(R1,pi);


R2=[];
R2=R1;
temp=R2(1,:);
R2(1,:)=R2(nmax,:);
R2(nmax,:)=temp;
temp=R2(:,1);
R2(:,1)=R2(:,nmax);
R2(:,nmax)=temp;
clear temp;
temp=str(1);
str(1)=str(nmax);
str(nmax)=temp;
clear temp;
E=tree2lst_nosort(R2);
count=[];
count=[count,1];
level=zeros(1,col);
level(1,1)=1;
z=1;
while z~=0;
    clear temp;
    temp=zeros(1,col);
    k=1;
    for i=1:count(z)
        for j=1:col
            if level(z,i)~=j & R2(level(z,i),j)~=inf
                temp(1,k)=j;
                R2(j,level(z,i))=inf;
                k=k+1;
            end
        end
    end
    if k==1
       z=0;
   else
       level=[level;temp];
       count=[count,k-1];
       z=z+1;
   end
end
cords=zeros(col,2);
b=[];
for i=1:size(count,2)
    for j=1:count(i)
        cords(level(i,j),1)=j/(count(i)+1);
        cords(level(i,j),2)=-i;
        xx=plot(j/(count(i)+1),-i,'ko');
        b(level(i,j))=xx;
        %if level(i,j)==2 disp(i); disp(j); end
        %set(xx,'MarkerFaceColor',str(level(i,j)).color);
    end
end
clear R2;

for i=1:size(E,1)
    xx=plot([cords(E(i,1),1),cords(E(i,2),1)],[cords(E(i,1),2),cords(E(i,2),2)],'k-','LineWidth',LineWidth);
    a=get(b(E(i,1)),'Userdata');
    z=get(b(E(i,2)),'Userdata');
    a=[a,xx];
    z=[z,xx];
    set(b(E(i,1)),'Userdata',a);
    set(b(E(i,2)),'Userdata',z);
end
for i=1:col;
    xx=plot(cords(i,1),cords(i,2),'ko');
    set(xx,'MarkerFaceColor',str(i).color);
    a=[];
    a.color=str(i).color;
    yy=text(cords(i,1),cords(i,2)-0.25,str(i).name,'fontsize',FontSize);
    a.text=yy;
    a.links=get(b(i),'UserData');
    set(xx,'UserData',a);
    set(xx,'ButtonDownFcn','mvv');
    mn=[mn,xx];
    %delete(b(i));
end
minimaltree=mn;