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!