How to find out source node and target node of each component of a directed signed graph?
조회 수: 4 (최근 30일)
이전 댓글 표시
I have a directed signed graph. I found out it has 3 components. I want to find number of source node, target node( having zero out degree), mean in degree of source node, mean out degree of a target node. If I make adjacency matrix it is not giving me the weights. How can I get my answer.
This is the code which I am using:
s = [1 1 1 2 2 2 8 8 8 8];
t = [2 3 4 5 6 7 9 10 11 12];
weight= [1 -1 1 -1 1 -1 -1 1 -1 1];
G = digraph(s,t,weight);
plot(G,'Layout','force','EdgeLabel',G.Edges.Weight)
weak_bins1 = conncomp(G,'Type','weak')
component= max(weak_bins1)
[weak_bins1, compNumNodes] = conncomp(G,'Type','weak')
comnumadj1= adjacency(subgraph(G,find(weak_bins1 == 1)))
C= full(comnumadj1)
comnumadj2= adjacency(subgraph(G,find(weak_bins1 == 2)))
D= full(comnumadj1)
댓글 수: 0
답변 (1개)
Steven Lord
2021년 8월 18일
I want to find number of source node, target node( having zero out degree)
What guarantee do you have that those types of nodes exist?
d = digraph([0 1 0; 0 0 1; 1 0 0]);
plot(d)
In this simple 3 node directed graph, which node(s) is/are the source node(s) and which is/are the target node(s)?
As for the other parts of your question, see the indegree and outdegree functions as well as the mean function.
in = indegree(d)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!