clear;
clc;

name = 'Results4Spss';

dataDir = 'D:/SocialNets/Steam/Exp_March13/Test/Boost_Th20/Iter15_16K_10/';
files = dir(strcat(dataDir, 'res_Steam*.mat')); 
dateNow = clock;
dateNow = strcat(num2str(dateNow(1)),'_',num2str(dateNow(2)),'_', num2str(dateNow(3)),'_', num2str(dateNow(4)), num2str(dateNow(5)),'_', num2str(dateNow(6)));
outFile = sprintf('%sDump%s_%s.txt',dataDir, name, dateNow);
fileID = fopen(outFile,'w');



first = 1;
numAlg = 0;
for f = files'
    data = load(strcat(dataDir,f.name));
    numResults = size(data.purity,2);
    numMissing = size(data.removed_nodes,2);
    line = numResults/numMissing;
    numAlgVars = line/numAlg;
    % print header
    if first == 1
        fprintf(fileID,'file\tinx\titer\tnodes\tedges\tattEdges\tattNodes\tmissInx\tmissNum\tnumPHs\tavgPHs');
        fprintf(fileID,'\tAlgId\tAttr\tScore\tTime1\tTime2\tTotalTime\n');
        first = 0;
    end
    
    %print data
    for i=1:numResults
        r = data.purity(1,i);
        fprintf(fileID,'%s',data.file);
        fprintf(fileID,'\t%d',data.i);
        fprintf(fileID,'\t%d',data.iter);
        fprintf(fileID,'\t%d',r.graph_size);
        fprintf(fileID,'\t%d',r.graph_edges); %12.12.12
        fprintf(fileID,'\t%d',r.graph_attr_edges); % 12.12.12
        fprintf(fileID,'\t%d', data.purity(1,i).num_attr_nodes);
        fprintf(fileID,'\t%d',r.num_missing_nodes_idx); 
        fprintf(fileID,'\t%d',r.num_missing_nodes);
        fprintf(fileID,'\t%d',r.num_placeholders);
        fprintf(fileID,'\t%d',r.num_placeholders/r.num_missing_nodes);
        fprintf(fileID,'\t%d',r.affinity_calculation_type);
        fprintf(fileID,'\t%d',r.withAttr);
        fprintf(fileID,'\t%d',r.score);
        time1 = r.affinity_calc_time+r.reduce_dim_time+r.graph_predict_time; 
        time2 = r.att_affinity_calc_time;
        fprintf(fileID,'\t%d',time1);
        fprintf(fileID,'\t%d',time2);
        fprintf(fileID,'\t%d',time1+time2);
        fprintf(fileID,'\n');
    end
end

fclose(fileID);
LogMsg(sprintf('Completed DumpResults at%s',outFile));
