Hi, i want to make all point has a connection to other with the following code.
x = [6 3 5 4 7 8];
idx = randperm(length(x));
y = x(idx);
start = x(:,2);
last = x(:,(length(x)));
w=randi(100, size(x));
G = digraph(x,y,w);
G = rmedge(G, 1:numnodes(G), 1:numnodes(G));
plot(G,'EdgeLabel',G.Edges.Weight) ;
path = shortestpath(G, start, last);
disp(['spf = ' num2str(path)]);
The result:
Is that possible to all point include no1 & 2 connect to each other?
Thanks.
6 Comments
Walter Roberson (view profile)
Direct link to this comment:
https://www.mathworks.com/matlabcentral/answers/423747-make-all-point-connected-to-other-points#comment_621691
Asyran Abdullah (view profile)
Direct link to this comment:
https://www.mathworks.com/matlabcentral/answers/423747-make-all-point-connected-to-other-points#comment_621694
Walter Roberson (view profile)
Direct link to this comment:
https://www.mathworks.com/matlabcentral/answers/423747-make-all-point-connected-to-other-points#comment_621699
Asyran Abdullah (view profile)
Direct link to this comment:
https://www.mathworks.com/matlabcentral/answers/423747-make-all-point-connected-to-other-points#comment_622077
Asyran Abdullah (view profile)
Direct link to this comment:
https://www.mathworks.com/matlabcentral/answers/423747-make-all-point-connected-to-other-points#comment_622082
Walter Roberson (view profile)
Direct link to this comment:
https://www.mathworks.com/matlabcentral/answers/423747-make-all-point-connected-to-other-points#comment_622087
Sign in to comment.