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

s = [1 1 1 2 3 3 3 4 6];
t = [2 4 5 5 6 7 4 1 4];
G = digraph(s,t);
plot(G)

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

T = bfsearch(G,1,'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 1
% An edge is discovered between node 1 and node 2
% Node 2 is discovered
% and so on...
% Copyright 2015 The MathWorks, Inc.