graphsetnodeproperty.m

来自「复杂网络的一些节点面对攻击的代码」· M 代码 · 共 52 行

M
52
字号
function Graph = GraphSetNodeProperty(Graph,NodeIDs,Values,PropertyName,PropertyDescription)
% Sets node properties.
%
% Receives:
%       Graph      -   Graph Struct           -    the graph loaded with GraphLoad
%       NodeIDs    -   vector of integers     -    list of ids for which property values are provided.
%       Values     -   vector of any type     -    vector of property values.
%       PropertyName-  string                 -    String, whiche identifies the property.
%       PropertyDescription - string          -    Describes the 
%
% Returns:
%      NodeNames   -   cellstring             -    Names of the IDs in the order, identical to NodeIDs, If no IDs exist in the Graph, then empty cell is returen
% See Also:
%       GraphLoad, GraphGetNodeProperty
% 
% Example:
%   [WikiGraph Result]= WikiGraphLoad('DatabaseProperties.mat','hewiki');
%   Degree = GraphCountNodesDegree(WikiGraph);
%   WikiGraph  = GraphSetNodeProperty(WikiGraph ,Degree(:,1),Degree(:,2),'Inncoming Degree','Incoming node''s degree');
%
%Created:																							
%	Lev Muchnik,	11/05/2005
%	lev@topspin.co.il, +972-54-326496			
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


error(nargchk(4,5,nargin));
error(nargoutchk(0,1,nargout));

ObjectIsType(Graph,'Graph','The input must be of the type "Graph". Please use ObjectCreateGraph function');

if ~exist('PropertyDescription','var')
    PropertyDescription = '';
end

Property = [];
Property.PropertyName = PropertyName;
Property.PropertyDescription = PropertyDescription;
Property.NodeIDs    =   NodeIDs;
Property.Values     =   Values;

if isempty(Graph.Index.Properties)
    Graph.Index.Properties = Property;
else
    Index = numel(Graph.Index.Properties)+1;
    for i = 1 : numel(Graph.Index.Properties)
        if strcmp(Graph.Index.Properties(i).PropertyName,PropertyName)
            Index = i;            
        end        
    end
    Graph.Index.Properties(Index) = Property;
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?