function [attAffinity] = CalcAttributesAffinity_S2(data, attData, last_known_node, addMissingAtt, threshold)
    n = size(attData,1);
    numAtt = size(attData,2);
    
    if addMissingAtt> 0 && last_known_node < n
        attData = AddMissingNodesAttrFromNeighborsNeighbors(data, attData, last_known_node, addMissingAtt);
    end
    
    count = sum(attData,2);
    nnz_n = nnz(count);
%    fprintf('calculating attribtes affinity matrix - common start\n');
    common = attData*attData';
    [r,c,v] = find(common);
    clear('common');
    x=size(r,1);
    perc_x = x/(n*n);
    LogMsg(sprintf('attAffinity common (%d, %.3f) - nnz=%d, %7.5f%%, max %d, min %d, mean %7.5f',numAtt,threshold,x,100*perc_x,max(v),min(v),mean(v)));
    LogMsg(sprintf('attAffinity count  (%d, %.3f) - nnz=%d, %7.5f%%, max %d, min %d, mean %7.5f',numAtt,threshold,nnz_n, 100*nnz_n/n, max(count),min(count),mean(count)));
    % Sigal 22.3.13 - TODO use sparse if x < 40%
    if perc_x<0.4
        attAffinity = sparse(n,n); 
    else
        attAffinity = zero(n,n);
        LogMsg(sprintf('*** attAffinity - using full matrix'));
    end
    for i=1:x
        total = count(r(i))+count(c(i))-v(i);
        if total > 0
            val = v(i)/total;
            if  val > threshold
                attAffinity(r(i),c(i)) = val;
%             else
%                 filter = filteer+1;
            end
        end
    end
    nnz_n = nnz(attAffinity);
    LogMsg(sprintf('attAffinity total  (%d, %.3f) - nnz=%d, %7.5f%%',numAtt,threshold,nnz_n,100*nnz_n/(n*n)));

end %function
