Reputation: 135
I have the following code that generate a graph from a matrix adj
and a set of nodes stored in nodeNames
. I have two types of nodes : i
node of type S and j
node of type O . in nodeNames
the nodes of type O are stored first , so from nodeNames{1}
to nodeNames{j}
are allocated to nodes O .
G = digraph(adj,nodeNames);
for x=1:j
v = dfsearch(G,nodeNames{x});
end
the following code allows me to search for all the dfsearch
results for nodes of type O, but in this way I only get the last result in the display , I want to get all the intermidiate itterations of the for loop . What is the best way to do that ? Thanks
Upvotes: 0
Views: 56
Reputation: 16801
In generally the lengths of the vectors returned by dfsearch
are not going to all be the same length, so v
should be store in a cell array using x
as the index:
G = digraph(adj,nodeNames);
for x=1:j
v{x} = dfsearch(G,nodeNames{x});
end
Upvotes: 1