-1

I have generated 3D points in matlab. I need it to be form random graph and display its connectivity such that connected link is 1 and 0 otherwise.. suggestions..

n=10;
PlotSizex=100;
PlotSizey=100;
PlotSizez=-100;
x=PlotSizex*rand(1,n)
y=PlotSizey*rand(1,n)
z=PlotSizez*rand(1,n)
plot3(x(:),y(:),z(:),'O-')

1 Answers1

1

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
Community
  • 1
  • 1
UJIN
  • 1,648
  • 13
  • 28
  • I am sorry but your question is not very clear, and I am not sure if "[connectivity](https://en.wikipedia.org/wiki/Connectivity_(graph_theory))" is really what you are looking for. By the way, have you tried looking at this page? [Graph with undirected edges](https://nl.mathworks.com/help/matlab/ref/graph-object.html). – UJIN Mar 17 '17 at 11:54
  • Exactly graph with undirected edges but should displayed in 3D manner. – Sivakumar V Mar 17 '17 at 11:58