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!