In the example given for conncomp it has this:
graph([1 1 4],[2 3 5],[1 1 1],6);
I do not understand how this leads to the graph which is displayed. The documentation for graph is not clear about this either. Can anyone explain how graph actually operates in this case in a really simple way?

 採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 9 月 22 日

0 投票

G=graph([1 1 4],[2 3 5],[1 1 1],6);
plot(G);
3456.png

5 件のコメント

Pa342
Pa342 2019 年 9 月 22 日
I know it plots this, I doesn't understand WHY it plots this...
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 9 月 22 日
90.png
Check here more
Pa342
Pa342 2019 年 9 月 22 日
For:
G=graph([1 1 4],[2 3 5],[1 1 1],6)
From the first two inputs, [1 1 4],[2 3 5], I understand that an edge is created from the element of the first input to the element of the second input i.e.:
1 goes to 2; 1 goes to 3 and 4 goes to 5.
What I do not understand is the next two inputs [1,1,1],6 or how they relate to the first two inputs.
Walter Roberson
Walter Roberson 2019 年 9 月 22 日
G = graph(S,T,WEIGHTS,NUM) specifies the number of nodes of the graph
with the numeric scalar NUM. NUM must be greater than or equal to the
largest elements in S and T.
So you are using weights 1, 1, and 1 for the edges, and you are telling it that there are 6 nodes. You want to tell it the number of nodes because your edge specifications do not necessarily include any link to or from all of your nodes.
Pa342
Pa342 2019 年 9 月 23 日
Thanks Walter, I understand it now.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGraph and Network Algorithms についてさらに検索

タグ

質問済み:

2019 年 9 月 22 日

コメント済み:

2019 年 9 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by