www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/IndegreeOfSubsetOfGraphNodesExample.m
%% In-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 % target. % 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'}'; indeg = indegree(G,nodeID) %% % |indeg(j)| indicates the in-degree of node |nodeID(j)|.