You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LoadAsciiGraph2.m 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. function [graph] = LoadAsciiGraph2(dataFilePath, dataFileName, numNodes, debug, debugPath)
  2. if nargin >= 3
  3. if nargin < 4
  4. debug = 0;
  5. end
  6. if nargin < 5
  7. debugPath = 'debug/';
  8. end
  9. fullOutPath = strcat(dataFilePath, debugPath);
  10. if isdir(fullOutPath) == 0 && debug == 1
  11. mkdir(fullOutPath);
  12. end
  13. dataFullName = strcat(dataFilePath,dataFileName);
  14. outFullName = strcat(fullOutPath,dataFileName);
  15. graph = zeros(numNodes,numNodes);
  16. edges = load(dataFullName);
  17. n = size(edges,1);
  18. % m = size(edges,2);
  19. for e=1:n
  20. i = edges(e,1)+1;
  21. j = edges(e,2)+1;
  22. graph(i,j) = 1;
  23. % if (i ~= j)
  24. % graph(i,j) = 1;
  25. % graph(j,i) = 1; % sigal: 18.11.12 make sure graph undirected
  26. % else
  27. % fprintf('Invalid edge %d (%d,%d)\n',e,i,j);
  28. % end
  29. end
  30. if debug == 1
  31. SaveIntMatrixToFile(strcat(outFullName,'_graph.txt'), graph);
  32. save(strcat(outFullName,'_graph.mat'), 'graph');
  33. save(strcat(outFullName,'_loadAsciiGraph.mat'));
  34. end
  35. else
  36. fprintf('Invalid parameters. expecting: dataFilePath, dataFileName, numNodes\n');
  37. end