www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/StrongAndWeakGraphComponentsExample.m
%% Strong and Weak Graph Components % Create and plot a directed graph, and then compute the strongly connected % components and weakly connected components. Weakly connected components % ignore the direction of connecting edges. % Copyright 2015 The MathWorks, Inc. s = [1 2 2 3 3 3 4 5 5 5 8 8]; t = [2 3 4 1 4 5 5 3 6 7 9 10]; G = digraph(s,t); plot(G,'Layout','layered') %% % str_bins = conncomp(G) %% % weak_bins = conncomp(G,'Type','weak')