Digraph: for all nodes calculate all successors
2 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
Considering digraph “G”, I would like to implement a code that for every node “i” in “G” it allows me to calculate a list of all successors of node “i”. How can I do this?
s = [1 1 1 2 2 3 3 4 4];
t = [2 3 4 5 6 7 8 9 10];
names = {'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'l'};
G = digraph (s,t,[],names);
S=successors(G,'a') %how to do this for all nodes?
0 个评论
采纳的回答
Voss
2021-12-20
Here is one way:
all_S = cell(G.numnodes,1);
for i = 1:G.numnodes
all_S{i} = successors(G,G.Nodes{i,1});
end
更多回答(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!