www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/DetermineIfDirectedGraphIsAcyclicExample.m

    %% Determine if Directed Graph is Acyclic
% Create and plot a directed graph, and then test the graph to determine if
% it is acyclic.

% Copyright 2015 The MathWorks, Inc.

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

%%
plot(G)

%%
tf = isdag(G)