⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graphsaveasdirectedlisttofile.m

📁 复杂网络的一些节点面对攻击的代码
💻 M
字号:
function Success = GraphSaveAsDirectedListToFile(Graph,FileName)
% Effectively Saves the Graph to ASCII file in the format: SOURCE_NODER LIST_OF_DESTINATION_NODES
%
% Receives:
%   Graph       -   Graph Struct                -   the graph loaded with GraphLoad
%   FileName    -   string                      -   the name if the file to store the data to. If the file exists, it is overwritten
%
% Returns:
%   Success     -   boolean                     -   true (1) if succeeded, false (0) - if not
%
% Example:
%   Graph = GraphLoad('E:\Documents\Articles\Data\ColiNet\coliInterFullVec.txt ','E:\Documents\Articles\Data\ColiNet\coliInterFullNames.txt ');
%   Success = GraphSaveAsDirectedListToFile(Graph,'E:\ColiDirectedList.lst');
%
%   or:
%   Graph = GraphLoad('E:\Documents\Articles\Data\Yeast\Barabasi\bo.dat.gz');
%   Success = GraphSaveAsDirectedListToFile(Graph,'E:\bo.lst');
%
% Created:
%   Lev Muchnik    21/08/2005, Tel.: 972-054-4326496, 89 Beacon, Somerville, MA, USA

error(nargchk(2,2,nargin));
error(nargoutchk(0,1,nargout));

ObjectIsType(Graph,'Graph','The operation can only be performed on Graphs');

try
    if exist(FileName,'file')==2
        delete(FileName);
    end
    h = fopen(FileName,'wb+');
    NodeIDs = GraphNodeIDs(Graph);
    for CurrentNodeID = NodeIDs(:).'
        Indeces = find(Graph.Data(:,1)==CurrentNodeID);
        fprintf(h,'%d\t%s\n',CurrentNodeID,num2str(Graph.Data(Indeces,2).'));
    end
    fclose(h);
    Success = 1;
catch
    Success=0;
end

⌨️ 快捷键说明

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