function P = transition(A,epsilon)
% P = transition(A,epsilon)
%
% A        adjacency matrix
% epsilon  reset probability

if nargin < 2
    epsilon = 0.05;
end

[m,n] = size(A);
if m ~= n
    error('Dimension mismatch.');
end

P = ones(n)/n;
A = A - diag(diag(A));
d = sum(A,2);
i = d > 0;
P(i,:) = (1 - epsilon) * A(i,:)./repmat(d(i),1,n) + epsilon/n;
