1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- function [graph] = LoadAsciiGraph2(dataFilePath, dataFileName, numNodes, debug, debugPath)
-
- if nargin >= 3
- if nargin < 4
- debug = 0;
- end
- if nargin < 5
- debugPath = 'debug/';
- end
-
- fullOutPath = strcat(dataFilePath, debugPath);
- if isdir(fullOutPath) == 0 && debug == 1
- mkdir(fullOutPath);
- end
-
- dataFullName = strcat(dataFilePath,dataFileName);
- outFullName = strcat(fullOutPath,dataFileName);
-
- graph = zeros(numNodes,numNodes);
- edges = load(dataFullName);
-
- n = size(edges,1);
- % m = size(edges,2);
-
- for e=1:n
- i = edges(e,1)+1;
- j = edges(e,2)+1;
- graph(i,j) = 1;
- % if (i ~= j)
- % graph(i,j) = 1;
- % graph(j,i) = 1; % sigal: 18.11.12 make sure graph undirected
- % else
- % fprintf('Invalid edge %d (%d,%d)\n',e,i,j);
- % end
- end
-
- if debug == 1
- SaveIntMatrixToFile(strcat(outFullName,'_graph.txt'), graph);
- save(strcat(outFullName,'_graph.mat'), 'graph');
- save(strcat(outFullName,'_loadAsciiGraph.mat'));
- end
- else
- fprintf('Invalid parameters. expecting: dataFilePath, dataFileName, numNodes\n');
- end
|