function [L] = Trees(n,m)
%The inputs are two scalars: n and m, and the output L is the Laplacian matrix
%of a random tree with n vertices, each vertex having at most m children.
%The variable k counts the number of vertices already put into the graph.
%We start with one vertex, hence we initially let k=1.
k=1;
%This block of code deals with the first vertex.
for j=1
%This if, else loop generates a number t corresponding the number of children
%the first vertex will have, taking into account the limit m. If the number t will
%make k greater than n, t is simply set to n-k, the number of remaining vertices.
s=randi(m,1);
if s0
x=find(V==0);
r=x(:,1);
for i=r:r+t-1
M(j,i)=1;
M(i,j)=1;
end
else
end
end
%This block of code creates the Laplacian Matrix L out of the adjacency
%matrix M.
N=M+zeros(n);
S=diag(sum(N));
L=S-N;
end