フィルターのクリア

Digraph: for all nodes calculate all successors

5 ビュー (過去 30 日間)
Fabio
Fabio 2021 年 12 月 20 日
コメント済み: Fabio 2021 年 12 月 20 日
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?

採用された回答

Voss
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
  1 件のコメント
Fabio
Fabio 2021 年 12 月 20 日
Ok perfect. Thanks a lot

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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