Digraph: for all nodes calculate all successors
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Voss
el 20 de Dic. de 2021
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
Más respuestas (0)
Ver también
Categorías
Más información sobre Graph and Network Algorithms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!