How to add nodes and edges?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Aswin Sandirakumaran
am 9 Jun. 2018
Kommentiert: Walter Roberson
am 9 Jun. 2018
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 9 Jun. 2018
You can use addedge() to add edges.
2 Kommentare
Walter Roberson
am 9 Jun. 2018
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graph and Network Algorithms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!