function G = RandomConnectivity(n,low,high)
% Generates a random n-by-n connectivity matrix with the
% property that the number of outlinks per webpage is between
% low and high

G = zeros(n,n);
for j=1:n
% Set up the j-th column of G based on the outlinks on webpage j

% The length n vector k is a random ordering of the first n integers
[x,k] = sort(rand(n,1));

% Use the first m values of vector k (random ordering of integers 1:n)
m = low + floor(rand*(high-low));
for q=1:m
% Assume there is an outlink to web page i where
i = k(q);
G(i,j) = 1;
end
end