#include #include #include #include #include #include "pcg-cpp/include/pcg_random.hpp" #include "randutils/randutils.hpp" #include #include using Rng = randutils::random_generator; typedef boost::adjacency_list Graph; int main(int argc, char* argv[]) { unsigned N = 10; unsigned T = 1000; double δ = 1.0 / 8; int opt; while ((opt = getopt(argc, argv, "N:T:d:")) != -1) { switch (opt) { case 'N': N = (unsigned)atof(optarg); break; case 'T': T = (unsigned)atof(optarg); break; case 'd': δ = atof(optarg); break; default: exit(1); } } Rng rng; std::uniform_real_distribution dr(0.0, 1.0); std::vector ns(T); std::vector nS(T); for (unsigned i = 0; i < N; i++) { Graph G(T); for (unsigned t = 0; t < T; t++) { if (rng.uniform(0.0, 1.0) < δ) { boost::add_edge(rng.uniform((unsigned)0, t), rng.uniform((unsigned)0, t), G); } } std::vector components(T); unsigned nc = boost::connected_components(G, &components[0]); std::vector s(nc); for (unsigned j : components) { s[j]++; } unsigned j_max = 0; for (unsigned j : s) { ns[j - 1]++; if (j > j_max) { j_max = j; } } nS[j_max - 1]++; } std::string filename = "ns_" + std::to_string(δ) + "_" + std::to_string(T) + ".dat"; std::ifstream outfile(filename); std::vector ns_old(T, 0); if (outfile.is_open()) { for (unsigned i = 0; i < T; i++) { uint64_t num; outfile >> num; ns_old[i] = num; } outfile.close(); } std::ofstream file_out(filename); for (unsigned i = 0; i < T; i++) { file_out < nS_old(T, 0); if (outfile_S.is_open()) { for (unsigned i = 0; i < T; i++) { uint64_t num; outfile_S >> num; nS_old[i] = num; } outfile_S.close(); } std::ofstream file_out_S(filename_S); for (unsigned i = 0; i < T; i++) { file_out_S <