www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/OutdegreeOfSubsetOfGraphNodesExample.m
%% Out-degree of Subset of Graph Nodes % Create and plot a directed graph with named nodes. Then compute the % number of edges that have the |'a'|, |'b'|, and |'f'| nodes as their % source. % Copyright 2015 The MathWorks, Inc. s = {'a' 'c' 'b' 'b' 'd' 'e' 'a' 'b'}; t = {'b' 'b' 'd' 'e' 'f' 'f' 'f' 'f'}; G = digraph(s,t); plot(G) %% % nodeID = {'a' 'b' 'f'}'; outdeg = outdegree(G,nodeID) %% % |outdeg(j)| indicates the out-degree of node |nodeID(j)|.