How to add nodes and edges?
조회 수: 3 (최근 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);
댓글 수: 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!