function [H]=H_matrix(A)

% A is voting matrix
% returns:
% row-stochastic (except zero rows) matrix H

s = sum(A')';

% r = row size of A
% c = column size of A

[r,c]=size(A);

for i=1:c;
    if s(i,1)==0;
        H(i,:)=0;
    else
        H(i,:)=A(i,:)/s(i,1);
    end %if
end %for