distinguish between paths starting from different nodes

Viewed 65

I have the foolowing graph pf size (i,j) with two types of nodes : i is the number of nodes of type S and j is the number of nodes of type O

  i=input('i:');
    j=input('j');

    B=randi([0 1], i*2,j);    
    nNodeCol = size(B,2);                            % nodes of type O
    nNodeLine = size(B,1)/2;                         % nodes of type S
    % First the 'O' nodes, then the 'S' nodes:
    nodeNames = [cellstr(strcat('O',num2str((1:size(B,2))'))) ; cellstr(strcat('S',num2str((1:size(B,1)/2)')))];
    nodeNames{end+1} = 'X';
    % Adjacency matrix adj, adj(i,j)=1 means there is an edge from node#i to node#j:
    adj = zeros(nNodeCol+nNodeLine);                 % square matrix which size is the number of nodes
    adj(1:nNodeCol, nNodeCol+1:end) = B(1:2:end,:)'; % edge from a 'O'node to 'S' node is added for all the 1 in the first line of the node in the matrix
    adj(nNodeCol+1:end, 1:nNodeCol) = B(2:2:end,:);  % edge from the 'S' node to 'O' node is added for all the 1 in the second line of the node in the matrix
    adj(end+1,end+1) = 0;  % add 1 row and 1 column to adj
    adj(end, 1:nNodeCol) = 1;  % only outgoing edges from X to O*
    % Creation of the graph:
    G = digraph(adj,nodeNames);
    v = dfsearch(G,'X');

Now, this code will allow me to get dfsearch results starting from all nodes of type 'O' simultaneously . My question is the following : Is there any way to distinguish between the results , I mean to distinguish between the results of 'O1' and those of 'O2' and goes on ?

1 Answers
Related