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

    %% Return Node Indices for Block-Cut Tree
% Create and plot a graph.
s = [1 1 2 2 3 4 4 5 6 6 7 7 8];
t = [2 3 3 4 4 5 7 6 7 10 8 9 9];
G = graph(s,t);
p = plot(G);

%%
% Compute the block-cut tree |tr| of the graph, and specify a second output
% |ix| to return the node indices.
[tr,ix] = bctree(G)

%%
% Each index |ix(j)| indicates the node in the block-cut tree that
% represents node |j| in the input graph. For example, node 4 in |tr|
% represents a component in |G| that contains nodes 1, 2, and 3, so the
% first three entries in |ix| are all 4.