function [graph] = LoadAsciiGraph(dataFilePath, dataFileName, numNodes, debug, debugPath) testing = 0; 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 = sparse(numNodes,numNodes); %% initilaize with zero 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; 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 %save(strcat(outFullName,'_graph.txt'), 'graph', '-ascii'); if testing == 1 graph(1,2) =1; graph(2,3) =1; rows=sum(graph,1); cols=sum(graph,2); diff = rows-cols'; nodes = find(diff); nnzx = nnz(graph); sumx = sum(sum(graph)); end 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