How to add nodes and edges?

1 次查看(过去 30 天)
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);

采纳的回答

Walter Roberson
Walter Roberson 2018-6-9
You can use addedge() to add edges.
  2 个评论
Aswin Sandirakumaran
I know that, what wil be the parameters??
Walter Roberson
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 CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by