How to find out source node and target node of each component of a directed signed graph?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Steven Lord
le 18 Août 2021
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 commentaires
Voir également
Catégories
En savoir plus sur Graph and Network Algorithms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!