graph and conncomp examples

조회 수: 3 (최근 30일)
Pa342
Pa342 2019년 9월 22일
댓글: Pa342 2019년 9월 23일
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일
G=graph([1 1 4],[2 3 5],[1 1 1],6);
plot(G);
3456.png
  댓글 수: 5
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개)

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by