addedge function not working

1 回表示 (過去 30 日間)
Nicolle Small
Nicolle Small 2021 年 3 月 29 日
コメント済み: Nicolle Small 2021 年 3 月 29 日
Matlab will not allow me to use the 'addedge' function, i am not sure why. my orginal network is huge so i tried to use it with a smaller graph. here is my script,
p = [0 1 0 1; 1 0 0 0; 0 0 0 0; 1 0 0 0];
plot(graph(p));
addedge(p,3,4);
i understand that the three inputs to the function are the graph 'p' and the nodes i would like the edge added between which i have put 3 and 4.
This is the error message i am receiving. 'Check for missing argument or incorrect argument data type in call to function 'addedge'.'
can anyone help me with how i can get it to work.

回答 (1 件)

Steven Lord
Steven Lord 2021 年 3 月 29 日
The addedge function is defined for graph and digraph objects. It is not defined for double arrays. You need to build a graph or digraph object (as you did inside your plot call) and call addedge on that object (with an output argument that will contain the modified graph or digraph.)
  1 件のコメント
Nicolle Small
Nicolle Small 2021 年 3 月 29 日
Thank you. I will give it another try.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by