Let n = 10; Then, how can we use random nodes (replaces X & Y values) to generate shortest path such as below code:
x= [1 1 2 2 3 4 6 4 5 5 ];
y= [2 5 3 4 4 5 3 1 2 6 ];
% Random weight for shortestpath
weights = randi(52, size(x));
w = randi([1 10], 13, 1);
D = graph(x,y,weights);
p = plot(D,'x','EdgeLabel',D.Edges.Weight );
path = shortestpath(D,1,5);
highlight(p,path,'NodeColor','g','EdgeColor','g')
Thanks.
Aucun commentaire:
Enregistrer un commentaire