function [find,vaf] = atreefnd_root(prox,inperm)

[find,vaf] = atreefnd(prox,inperm);

n = size(prox,1);

for ione = 1:(n-1)
    for jone = (ione+1):n
        
        pairindexes = [ione,jone];
        
        ctmetric = zeros(n,1);
        ulmetric = zeros(n,n);
        
        for i = 1:n
            
            ctmetric(i) = max([find(i,ione),find(i,jone)]);
        end
        
        centroid_metric = ctmetric;
        
        for i = 1:n
            for j = 1:n
                
                if (i ~= j)
                    
                    ulmetric(i,j) = find(i,j) - ctmetric(i) - ctmetric(j);
                                   
                end
            end
        end
        
        ultra_metric = ulmetric;
        
        min_value = min(min(ulmetric));
        
        additive_constant = 0.0;
        
        if (min_value < 0.0)
            
            additive_constant = -min_value;
            
        end
        
        for i = 1:n
            for j = 1:n
                
                if (i ~= j)
                    
                    ulmetric(i,j) = ulmetric(i,j) + additive_constant;
                    
                end
            end
        end
        
        ultra_metric = ulmetric;
        
        for i = 1:n
            
            ctmetric(i) = ctmetric(i) - (1/2)*additive_constant;
            
        end
        
        pairindexes
        
        [orderprox,orderperm] = ultraorder(ulmetric)
        
        centroid_metric = ctmetric(orderperm)'
        
    end
end
        