#include "exports.hpp" #include "graph.hpp" #include "graph_powerlaw.hpp" #include "graph_spectrum.hpp" #include "histogram.hpp" #include "switchchain.hpp" #include #include #include #include #include #include int main(int argc, char* argv[]) { // Simulation parameters const int numVerticesMin = 1000; const int numVerticesMax = 1000; const int numVerticesStep = 1000; float tauValues[] = {2.1f, 2.3f, 2.5f, 2.7f, 2.9f}; auto getMeasurements = [](int n, float tau) { (void)n; (void)tau; return 50000; }; // Output file std::ofstream outfile; if (argc >= 2) outfile.open(argv[1]); else outfile.open("graphdata_canonical_timeevol.m"); if (!outfile.is_open()) { std::cout << "ERROR: Could not open output file.\n"; return 1; } // Output Mathematica-style comment to indicate file contents outfile << "(*\n"; outfile << "n from " << numVerticesMin << " to " << numVerticesMax << " step " << numVerticesStep << std::endl; outfile << "tauValues: " << tauValues << std::endl; outfile << "Canonical degree sequence.\n"; outfile << "10 runs per starting point.\n"; outfile << "Measurements: 50000\n"; outfile << "data:\n"; outfile << "1: {n,tau}\n"; outfile << "2: {triangles}\n"; outfile << "*)" << std::endl; // Mathematica does not accept normal scientific notation outfile << std::fixed; outfile << '{' << '\n'; bool outputComma = false; SwitchChain chain; Graph g; for (int numVertices = numVerticesMin; numVertices <= numVerticesMax; numVertices += numVerticesStep) { for (float tau : tauValues) { DegreeSequence ds; generateCanonicalPowerlawGraph(numVertices, tau, g, ds); std::cout << "Running (n,tau) = (" << numVertices << ',' << tau << "). " << std::flush; for (int j = 0; j < 10; ++j) { std::vector triangles; chain.initialize(g, true); int measurements = getMeasurements(numVertices, tau); for (int i = 0; i < measurements; ++i) { chain.doMove(true); triangles.push_back(chain.g.getTrackedTriangles()); } if (outputComma) outfile << ',' << '\n'; outputComma = true; outfile << '{' << '{' << numVertices << ',' << tau << '}'; outfile << ',' << triangles; outfile << '}' << std::flush; } std::cout << std::endl; } } outfile << '\n' << '}'; return 0; }