How to add nodes and edges?
3 ビュー (過去 30 日間)
古いコメントを表示
Aswin Sandirakumaran
2018 年 6 月 9 日
コメント済み: Walter Roberson
2018 年 6 月 9 日
p = [3,2,1];
for i = 1:length(p)
last_element = p(end);
G = graph();
H = addnode(G,last_element);
*HOW TO ADD EDGE??? HERE ??*
p(end) = []; % REMOVING THE LAST ELEMENT ONCE ADDED TO THE GRAPH so in 2nd iteration p = [3,2]
end
plot(H);
0 件のコメント
採用された回答
Walter Roberson
2018 年 6 月 9 日
You can use addedge() to add edges.
2 件のコメント
Walter Roberson
2018 年 6 月 9 日
The first parameter would be G.
We do not know what the other parameters would be, as you have not given us any information about which nodes are to be connected by the edge.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graph and Network Algorithms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!