www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/DegreeOfSubsetOfNodesExample.m
%% Degree of Subset of Graph Nodes % Create and plot a graph, and then find the degree of the first, third, % and fifth nodes. % Copyright 2015 The MathWorks, Inc. s = {'a' 'a' 'a' 'd' 'd' 'f' 'f' 'f'}; t = {'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i'}; G = graph(s,t); plot(G) %% % nodeIDs = {'a' 'c' 'e'}'; deg = degree(G,nodeIDs) %% % |deg(j)| indicates the degree of node |nodeIDs(j)|.