%% Depth-First Graph Search with All Events
% Create and plot a directed graph.

A = [0 1 0 1 1 0 0; 
     0 0 0 0 0 0 0; 
     0 0 0 1 0 1 1;
     0 0 0 0 0 1 0; 
     0 0 0 0 0 0 0; 
     0 0 0 0 0 0 0; 
     0 0 0 0 0 0 0];
G = digraph(A);
plot(G)

%
% Perform a depth-first search on the graph starting at node 3. Specify 'allevents' to return a table containing all of the events in the algorithm.

T = dfsearch(G,3,'allevents')

% To follow the steps in the algorithm, read the events in the table from top to bottom. For example:
% The algorithm begins at node 3
% An edge is discovered between node 3 and node 4
% Node 4 is discovered
% and so on...
% Copyright 2015 The MathWorks, Inc.