function [p]=method0(r,maxiter)
k = size(r,1);

% p = sum(r,2)*2/k/(k-1);

p = p / sum(p);
mu=zeros(k,k);
for i =1:k
  mu(i,i+1:k) = p(i) ./ (p(i)+p(i+1:k)') ;
  mu(i+1:k,i) = 1 - mu(i,i+1:k)';
end

for t=1:maxiter,
  for i = 1:k,
    alpha =  sum(r(i,:)) / sum(mu(i,:)) ;      
    p(i) = p(i)*alpha;
    noti=[1:i-1,i+1:k];
    mu(i,noti) = alpha*mu(i,noti) ./ (alpha*mu(i,noti)+ mu(noti,i)'); 
    mu(noti,i) = 1 - mu(i,noti)'; 
  end
  p = p ./ sum(p);
  if norm(sum(r,2)./sum(mu,2)-1) < 0.001,
    return;
  end
end
fprintf(1, 'max iteration\b');

