www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/AdjacencyMatrixDigraphConstructionWithNodeNamesExample.m
%% Adjacency Matrix Construction with Node Names % Create an adjacency matrix. % Copyright 2015 The MathWorks, Inc. A = magic(4); A(A>10) = 0 %% % Create a graph with named nodes using the adjacency matrix. Specify % |'OmitSelfLoops'| to ignore the entries on the diagonal of |A|. names = {'alpha' 'beta' 'gamma' 'delta'}; G = digraph(A,names,'OmitSelfLoops') %% % View the edge and node information. G.Edges %% % G.Nodes