int main(int argc, char *argv[]) { FILE *input = NULL; FILE *output = NULL; Edges edges = {0, NULL} ; double *shapley = NULL; long kernel_time = 0; long summary_time = 0; int n; Adjacency *adjacency; input = safeFopen(argv[1], "r"); output = safeFopen(argv[2], "w"); read_input(input, &edges); n = number_of_vertices(&edges); shapley = (double *) safeMalloc(n * sizeof(double)); adjacency = createAdjacency(n, &edges, n); compute_shapley(adjacency, n, shapley, function, &kernel_time, &summary_time); write_output(n, shapley, output); print_time("kernel", kernel_time); print_time("summary", summary_time); releaseAdjacency(adjacency); free(shapley); free(edges.list); fclose(input); fclose(output); return 0; }
TrecReader::TrecReader(const std::string& index_path, const std::string& inf_path, const std::string& doclength_path, const std::string& word_file, int _docn){ findex = safeFopen(index_path); // open 8_1.dat file finf = safeFopen( inf_path); // open 8_1.inf file flex = safeFopen(word_file.c_str()); // open word_file fdoclength = safeFopen(doclength_path.c_str()); // open doc_len file int infn; fread( &infn, sizeof(int), 1, finf); // first int contains the # of terms in the entire collection COUT1<<"Totally there are "<<infn<<" terms"<<Log::endl; inf_buffer = new unsigned int[ 4 * infn]; // read fread( inf_buffer, sizeof(int), 4 * infn, finf); //now we have all our sizes in an inf_buffer. Let's partial sum them inf_prefix_sum = new size_t[infn+1]; inf_prefix_sum[0] = 0; for(size_t i=0; i<4 * infn; i+=4) inf_prefix_sum[i/4 + 1] = (2*inf_buffer[i+1]*sizeof(unsigned int))+inf_prefix_sum[i/4]; // inf_buffer[0] = term_id and inf_buffer[1] == padded postings docn = _docn; // CONSTS::MAXD Total # of documents in collection doclen = new unsigned int[docn + 256]; hold_buffer = new unsigned int[docn * 2]; load_doclength(); COUT2<<"doclength is loaded"<<Log::endl; }