フィルターのクリア

Changing static node to random distribution node.

1 回表示 (過去 30 日間)
Asyran Abdullah
Asyran Abdullah 2018 年 8 月 12 日
回答済み: Steven Lord 2018 年 8 月 12 日
How to change the node into random distributed node as following code.
% code
rand('seed',123456);
x = [1 1 1 1 1 1 2 3 4 5 6 7 7 7 7 8 9 10 11 8 6];
y = [2 3 4 5 6 7 3 4 5 6 2 8 9 10 11 10 10 11 8 1 11];
weights = randi([1 10],1,21);
G = graph(x,y,weights);
h = plot(G,'EdgeLabel',G.Edges.Weight);
title('Finding Shortest Path on Random Node');
path = shortestpath(G,1,9);
highlight(h,path,'NodeColor','g','EdgeColor','g')
end
Can i change the node :
x = [1 1 1 1 1 1 2 3 4 5 6 7 7 7 7 8 9 10 11 8 6];
y = [2 3 4 5 6 7 3 4 5 6 2 8 9 10 11 10 10 11 8 1 11];
Into random distributed node? Thanks :)

採用された回答

Steven Lord
Steven Lord 2018 年 8 月 12 日
So you want to select a random subset of the possible edges to be included in your graph? Consider using the sprandsym function to generate a sparse adjacency matrix and passing that adjacency matrix into the graph function.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by