Also the last line does not make the matrix symmetric. SInce you work on the upper triangle of the matrix, the easiest way to make the matrix symmetric is:
replace
A=A+fliplr((flipud(triu(A))));
with
A=A+A';
it is a good routine, but in the processof reconncetion, it permites a vertex to connect itself. To avoid this, I change the code :
vToRec=nonAdj(ceil(rand*length(nonAdj))); to
vToRec=vDisToRec;
while vToRec==vDisToRec
vToRec=nonAdj(ceil(rand*length(nonAdj)));
end