function obj = update_mergeprobs_comp2comp( obj,database )
warning('this function is not tested');

% calculate merge prob distribution for each label type
gmdist_per_lb = database.m_mergeprobs_per_label;
dblbs = database.m_labels;
compts = obj.m_compts;
complbs = obj.m_complabels;
ncomp = size(compts,2);
mergeprobmat = zeros(ncomp,ncomp);

ulbs = unique(complbs);
for i=1:length(ulbs)
    thislb = ulbs(i);
    gmdist = gmdist_per_lb{dblbs==thislb}; %this label must exist in database
    
%     if isempty(gmdist)
%         %not exist? the mergeprob is 0
%         continue;
%     end
    
    idxuse = find(complbs==thislb);
    thiscompts = compts(:,idxuse);
    
    if length(idxuse) == 1
        continue;
    end
    
    % for each point as pivot
    for k=1:size(thiscompts,2)
        pivot = thiscompts(:,k);
        datapts = thiscompts(:,[1:k-1 k+1:end]);
        datapts(1,:) = datapts(1,:)-pivot(1);
        datapts(2,:) = datapts(2,:)-pivot(2);
        ps = gmdist.pdf(datapts');
        
        idxfrom = idxuse(k);
        idxto = idxuse([1:k-1 k+1:end]);
        mergeprobmat(idxfrom,idxto) = ps;
    end
end

obj.m_mergeprobs_comp2comp = mergeprobmat;

end

