int int_vectors(int vector1[], int vector2[], int size) { for (int i = 0; i < size; i++){ if (vector1[i] != vector2[i]){ print_int_vector(vector1, size); print_int_vector(vector2, size); printf("%d != %d\n", vector1[i], vector2[i]); return(0); } } return(1); }
std::string JSON_printer::print_int_vec_vector(std::vector<std::vector<int>> vec) { std::string out_string = "["; for (int i = 0; i < vec.size(); i++) { out_string = out_string + print_int_vector(vec[i]); if (i != vec.size() - 1) { out_string = out_string + ","; } } out_string.append("]"); return out_string; }
EXPORT void rect_grid_center( const RECT_GRID *rect_grid, const int *icoords, double *fcoords) { int i, dim = rect_grid->dim; for (i = 0; i < dim; ++i) { if ((icoords[i] < 0) || (icoords[i] >= rect_grid->gmax[i])) { screen("ERROR in rect_grid_center(), " "center for icoords not on rect_grid:\n"); print_int_vector("icoords = ",icoords,dim,"\n"); print_RECT_GRID_structure(rect_grid); clean_up(ERROR); } fcoords[i] = cell_center(icoords[i],i,rect_grid); } } /* end rect_grid_center */
std::string JSON_printer::print_labeled_counts(std::string graph_name, int num_nodes, int num_edges, std::unordered_map<std::string, std::vector<int>> map) { std::string out_str = "{ \"Graphname\" : \"" + graph_name + "\", \"Number of vertices\" : " + std::to_string(num_nodes) + ", "; out_str = out_str + "\"Number of edges\" : " + std::to_string(num_edges) + ", "; out_str += "\"Labeled Counts\" : { "; for (auto k : map) { out_str += "\"" + k.first + "\" : "; out_str += print_int_vector(k.second); out_str += ", "; } out_str.erase(out_str.size() - 3, 3); out_str += "]}}"; return out_str; }
std::string JSON_printer::print_vectors_with_info(std::string graph_name, int num_nodes, int num_edges, std::vector<std::vector<float>> rel_counts, std::vector<std::vector<int> > abs_counts) { std::vector<int> two_graphletsABS = abs_counts[0]; std::vector<int> three_graphletsABS = abs_counts[1]; std::vector<int> four_graphletsABS = abs_counts[2]; std::vector<int> five_graphletsABS = abs_counts[3]; std::vector<float> two_graphletsNORM = rel_counts[0]; std::vector<float> three_graphletsNORM = rel_counts[1]; std::vector<float> four_graphletsNORM = rel_counts[2]; std::vector<float> five_graphletsNORM = rel_counts[3]; std::string quot_marks = "\""; std::string out_str = "{ \"Graphname\" : " + quot_marks + graph_name + quot_marks + ", \"Number of vertices\" : " + std::to_string(num_nodes) + ", "; out_str = out_str + "\"Number of edges\" : " + std::to_string(num_edges) + ", "; std::string abs_str = "\"Absolute Counts\" : { "; std::string norm_str = "\"Normalized Counts\" : { "; if (two_graphletsABS.empty()) { abs_str += "\"2-graphlets\" : null, "; } else { abs_str += "\"2-graphlets\" : " + print_int_vector(two_graphletsABS) + ", "; } if (three_graphletsABS.empty()) { abs_str += "\"3-graphlets\" : null, "; } else { abs_str += "\"3-graphlets\" : " + print_int_vector(three_graphletsABS) + ", "; } if (four_graphletsABS.empty()) { abs_str += "\"4-graphlets\" : null, "; } else { abs_str += "\"4-graphlets\" : " + print_int_vector(four_graphletsABS) + ", "; } if (five_graphletsABS.empty()) { abs_str += "\"5-graphlets\" : null}"; } else { abs_str += "\"5-graphlets\" : " + print_int_vector(five_graphletsABS) + "}, "; } out_str += abs_str; if (two_graphletsNORM.empty()) { norm_str += "\"2-graphlets\" : null, "; } else { norm_str += "\"2-graphlets\" : " + print_float_vector(two_graphletsNORM) + ", "; } if (three_graphletsNORM.empty()) { norm_str += "\"3-graphlets\" : null, "; } else { norm_str += "\"3-graphlets\" : " + print_float_vector(three_graphletsNORM) + ", "; } if (four_graphletsNORM.empty()) { norm_str += "\"4-graphlets\" : null, "; } else { norm_str += "\"4-graphlets\" : " + print_float_vector(four_graphletsNORM) + ", "; } if (two_graphletsNORM.empty()) { norm_str += "\"5-graphlets\" : null}"; } else { norm_str += "\"5-graphlets\" : " + print_float_vector(five_graphletsNORM) + "}"; } out_str += norm_str + "}"; return out_str; }