www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/CondenseStronglyConnectedComponentsIntoSingleNodesExample.m
%% Condense Strongly Connected Components into Single Nodes % Create and plot a graph that contains several strongly connected % components. Highlight the strongly connected components. s = [1 1 2 3 3 4 4 4 4 5 5 6 6 6 7 8 8 9 9 10 10 10 11 11 12 13 13 14 15]; t = [1 3 1 2 5 1 2 12 13 6 8 7 8 10 10 9 10 5 11 9 11 14 12 14 13 11 15 13 14]; G = digraph(s,t); p = plot(G); %% bins = conncomp(G); p.MarkerSize = 7; p.NodeCData = bins; colormap(hsv(4)) %% % Use |condensation| to represent each component as a single node. Color % the nodes based on the components they represent. C = condensation(G); p2 = plot(C); p2.MarkerSize = 7; p2.NodeCData = 1:4; colormap(hsv(4))