フィルターのクリア

How to find out source node and target node of each component of a directed signed graph?

7 ビュー (過去 30 日間)
Mouli Sarkar
Mouli Sarkar 2021 年 8 月 18 日
回答済み: Steven Lord 2021 年 8 月 18 日
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)

回答 (1 件)

Steven Lord
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)
in = 3×1
1 1 1

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by