Well, what you generate is not really a graph, it's just a set of randomly generated 3D points, graphically represented connected with a line (the 'O-'
option in the plot3
function). But, being that they are "sequentially" connected, their Adjacency Matrix will just be a n*n
matrix with the upper and lower diagonals filled with ones, and the rest zeros (taking the method from here):
A = full(gallery('tridiag', n, 1, 0, 1))
% A =
% 0 1 0 0 0 0 0 0 0 0
% 1 0 1 0 0 0 0 0 0 0
% 0 1 0 1 0 0 0 0 0 0
% 0 0 1 0 1 0 0 0 0 0
% 0 0 0 1 0 1 0 0 0 0
% 0 0 0 0 1 0 1 0 0 0
% 0 0 0 0 0 1 0 1 0 0
% 0 0 0 0 0 0 1 0 1 0
% 0 0 0 0 0 0 0 1 0 1
% 0 0 0 0 0 0 0 0 1 0