www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/PerformBreadthFirstGraphSearchExample.m
%% Perform Breadth-First Graph Search % Create and plot a graph. % Copyright 2015 The MathWorks, Inc. s = [1 1 1 1 2 2 2 2 2 2 2 2 2 2 15 15 15 15 15]; t = [3 5 4 2 14 6 11 12 13 10 7 9 8 15 16 17 19 18 20]; G = graph(s,t); plot(G) %% % Perform a breadth-first search of the graph starting at node 2. The % result indicates the order of node discovery. v = bfsearch(G,2)