1234567891011121314151617181920212223242526272829303132333435363738394041 |
- function [edges] = SaveAsciiGraph(outFilePath, outFileName, graph, withSize)
-
- if nargin >= 3
-
- if nargin < 4
- withSize = 0;
- end
-
- if isdir(outFilePath) == 0
- mkdir(outFilePath);
- end
-
- outFullName = strcat(outFilePath,outFileName);
-
- numNodes = size(graph,1);
- numEdges = sum(sum(graph,1));
-
- edges = zeros(numEdges,2);
- e = 1;
-
- for i=1:numNodes
- for j=1:numNodes
- if graph(i,j) == 1
- edges(e,1) = i-1;
- edges(e,2) = j-1;
- e = e+1;
- end
- end
- end
-
- % save(strcat(outFullName,'_edges.txt'), 'edges', '-ascii');
- if withSize == 1
- SaveIntMatrixToFile(strcat(outFullName,'_edges.txt'), edges, numNodes);
- else
- SaveIntMatrixToFile(strcat(outFullName,'_edges.txt'), edges);
- end
- % save(strcat(outFullName,'_edges.mat'), 'edges');
- % save(strcat(outFullName,'_saveAsciiGraph.mat'));
- else
- fprintf('Invalid parameters. expecting: outFilePath, outFileName, graph\n');
- end
|