function [S]=S_matrix(H)

%% Fixes the dangling nodes of the matrix H

[p, q]=size(H);

t=sum(H')';
S=H;
for i=1:p;
    if t(i,1)==0;
        S(i,:)=1/q;
    end %if
end %for