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

    %% Find Graph Components
% Create and plot an undirected graph with three connected components. Use
% |conncomp| to determine which component each node belongs to.

% Copyright 2015 The MathWorks, Inc.

G = graph([1 1 4],[2 3 5],[1 1 1],6);
plot(G)

%%
% 
bins = conncomp(G)