필터 지우기
필터 지우기

How to determine number of edges ?

조회 수: 2 (최근 30일)
Asyran Abdullah
Asyran Abdullah 2018년 9월 2일
댓글: Asyran Abdullah 2018년 9월 4일
Hi, below is the code for shortestpath:
%code
A = randi(1,8) ;
D = graph(A);
D.Edges.W3 = randi(13, numedges(D), 1);
D.Edges.Weight = D.Edges.W3;
p = plot(D,'o','EdgeLabel',D.Edges.Weight );
axis square;
grid on
path = shortestpath(D, 2, 5);
highlight(p,path,'NodeColor','g','EdgeColor','g')
end
The Result:
As the result shown that each of the point will generate 8 edges based on the "A = randi(1,8)" input. How can i determine the edges number manually?
Thanks.
  댓글 수: 6
Walter Roberson
Walter Roberson 2018년 9월 4일
But I am not certain what your question is? Are you trying to control the number of total edges that are created? Are you trying to control the minimum "degree" of each node? Are you trying to control the maximum degree? Are you trying to determine the degree of each node on the path between nodes 2 and 5 ?
Asyran Abdullah
Asyran Abdullah 2018년 9월 4일
yes, based on your code. i try to determine the degree of each node, but nevermind i already get it. Thanks sir.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2018년 9월 2일
Since every node seems to go to every node (even including itself), wouldn't it just be simply N*N/2 = 8*8/2 = 32?
  댓글 수: 4
Asyran Abdullah
Asyran Abdullah 2018년 9월 3일
I found this to prevent self loop
%
G = rmedge(G, 1:numnodes(G), 1:numnodes(G));
Walter Roberson
Walter Roberson 2018년 9월 4일
The line I showed,
A = A - diag(diag(A));
prevents edges between a node and itself, provided that A is a square adjacency matrix.

댓글을 달려면 로그인하십시오.

추가 답변 (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