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);

 Réponse acceptée

Walter Roberson
Walter Roberson le 9 Juin 2018

0 votes

You can use addedge() to add edges.

2 commentaires

Aswin Sandirakumaran
Aswin Sandirakumaran le 9 Juin 2018
I know that, what wil be the parameters??
Walter Roberson
Walter Roberson le 9 Juin 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graph and Network Algorithms dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by