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

    %% Add Nodes to Graph
% Add two nodes to a graph that does not have node names.

% Copyright 2015 The MathWorks, Inc.

G = graph([1 2 3],[2 3 4])

%%
%
G = addnode(G,2)

%%
% Add node names to the graph, and then add five additional new nodes. The
% auto-generated names for the new nodes indicate their placement in
% |G.Nodes.Name|.
G.Nodes.Name = {'A' 'B' 'C' 'D' 'E' 'F'}'

%%
%
G = addnode(G,5);
G.Nodes