function [x,y]=avultradist(nb,ne,res,f1,f2,mode,FontSize,LineWidth);
start=nb;
stop=nb+100;
cr=1;
x=[];
y=[];
col=res.col;
n=res.dnei;
a=res.matr;
str=res.str;
while stop<=ne
logm=zeros(stop-start+1,col);
for j=1:col
    for i=start:stop
            logm(i-start+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);
%ultramatrix
counter=1;
t=[];
clusters=[];
t=dist;
dul=zeros(col,col);
for i=1:col
    clusters(i).col=1;
    clusters(i).list=[];
    clusters(i).list=[clusters(i).list,i];
    clusters(i).pos=inf;
    t(i,i)=inf;
end
for i=1:(col-1)
    imin=0;
    jmin=0;
    minel=inf;
    %poisk min i ego indeksa
    for ii=1:col
        for jj=ii:col
            if t(ii,jj)<=minel
                minel=t(ii,jj);
                imin=ii;
                jmin=jj;
            end
        end
    end
      
    %poisk ego klastera
    f=0;
    cl1=0;
    for iii=1:col
        if clusters(iii).col~=0
            for jjj=1:clusters(iii).col
                if clusters(iii).list(jjj)==imin;
                    cl1=iii;%klaster nachala min rebra
                    f=f+1;
                    break;
                else
                    if clusters(iii).list(jjj)==jmin;
                        cl2=iii;
                        f=f+1;
                        break;
                    end
                end
            end
            if f==2
                break;
            end
        end
    end
    if clusters(cl1).pos>clusters(cl2).pos
        tmp=clusters(cl1);
        clusters(cl1)=clusters(cl2);
        clusters(cl2)=tmp;
    end
    
    
    %pereopredelenie dul-matritsy
     n1=clusters(cl1).col;
     n2=clusters(cl2).col;
      for ii=1:n1
        for jj=1:n2
             dul(clusters(cl1).list(ii),clusters(cl2).list(jj))=minel;
             dul(clusters(cl2).list(jj),clusters(cl1).list(ii))=minel;
         end
     end
     %pereopredelenie matritsy t
     
     for j=1:col
         if t(cl1,j)~=inf & j~=cl2
             if mode=='alca'
                 t(cl1,j)=(n1*t(cl1,j)+n2*t(cl2,j))/(n1+n2);
                 t(j,cl1)=t(cl1,j);
             else   
                if t(cl2,j)<=t(cl1,j)
                    t(cl1,j)=t(cl2,j);             
                    t(j,cl1)=t(cl1,j);
                end
            end
         end
     end
       for ii=1:col
           t(ii,cl2)=inf;
           t(cl2,ii)=t(ii,cl2);
       end
     %pereopredelenie clusters
     if clusters(cl1).col==1 & clusters(cl2).col==1 
         clusters(cl1).pos=counter;
         counter=counter+1;
     end
     clusters(cl1).col=clusters(cl1).col+clusters(cl2).col;
     clusters(cl1).list=[clusters(cl1).list,clusters(cl2).list];
     clusters(cl2).col=0;
     clusters(cl2).list=[];
     clnum=cl1;
 end
 %pf=sum(dul,1);
 %pf=dul(22,4)+dul(22,25)+dul(22,38)+dul(22,50)+dul(22,24)+dul(22,26)+dul(22,28)+dul(22,41);
 %y=[y pf(22)];
 y=[y dul(22,7)];
 start=start+1;
 stop=stop+1;
 x=[x cr];
 cr=cr+1;
end
