www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/UniqueTransitiveReductionExample.m
%% Unique Transitive Reduction % Create and plot a directed acyclic graph. % Copyright 2015 The MathWorks, Inc. s = [1 1 1 1 2 3 3 4]; t = [2 3 4 5 4 4 5 5]; G = digraph(s,t); plot(G) %% % Confirm that |G| does not contain any cycles. tf = isdag(G) %% % Find the transitive reduction of the graph. Since the graph does not % contain cycles, the transitive reduction is unique and is a subgraph of % |G|. H = transreduction(G); plot(H)