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

    %% Adjacency Matrix Construction with Node Names
% Create an upper triangular adjacency matrix.

% Copyright 2015 The MathWorks, Inc.

A = triu(magic(4))

%%
% Create a graph with named nodes using the adjacency matrix. Specify
% |'OmitSelfLoops'| to ignore the entries on the diagonal of |A|, and
% specify |type| as |'upper'| to indicate that |A| is upper-triangular.
names = {'alpha' 'beta' 'gamma' 'delta'};
G = graph(A,names,'upper','OmitSelfLoops')

%%
% View the edge and node information.
G.Edges

%%
%
G.Nodes