function [p, alpha, beta, A] = p1testgen(n)
% Generate the tree data structures (p, alpha, and beta)
% and the dense representation for an n-by-n symmetric positive
% definite matrix as described in problem 1.

% Generate a tree by randomly adding leaves
p = zeros(n,1);
for k = 2:n
  p(k) = floor(rand*(k-1))+1;
end

% Construct a diagonally dominant test case
beta  = randn(n,1);
alpha = ones(n,1);
for k = 2:n
  alpha(k)    = alpha(k)    + abs( beta(k) );
  alpha(p(k)) = alpha(p(k)) + abs( beta(k) );
end

% Convert A to dense form
A = p1todense(p, alpha, beta);
