diff --git a/cpp/switchchain_initialtris.cpp b/cpp/switchchain_initialtris.cpp index 3acda57dd7e8e959c1c51deb9c4a02f6151e8dc0..158e26550a13b9db01e08a9cb6d917f7be2afed4 100644 --- a/cpp/switchchain_initialtris.cpp +++ b/cpp/switchchain_initialtris.cpp @@ -1,7 +1,7 @@ #include "exports.hpp" #include "graph.hpp" #include "graph_gcm.hpp" -#include "powerlaw.hpp" +#include "graph_powerlaw.hpp" #include "switchchain.hpp" #include #include @@ -29,37 +29,11 @@ int main() { for (int numVertices = 200; numVertices <= 2000; numVertices += 400) { for (float tau : tauValues) { - - DegreeSequence ds(numVertices); - powerlaw_distribution degDist(tau, 1, numVertices); - //std::poisson_distribution<> degDist(12); - // For a single n,tau take samples over several instances of // the degree distribution. - // 500 samples seems to give reasonable results for (int degreeSample = 0; degreeSample < 200; ++degreeSample) { - // Generate a graph - // might require multiple tries - for (int i = 1; ; ++i) { - std::generate(ds.begin(), ds.end(), - [°Dist, &rng] { return degDist(rng); }); - // First make the sum even - unsigned int sum = std::accumulate(ds.begin(), ds.end(), 0); - if (sum % 2) { - continue; - // Can we do this: ?? - ds.back()++; - } - - if (g.createFromDegreeSequence(ds)) - break; - - // When 10 tries have not worked, output a warning - if (i % 10 == 0) { - std::cerr << "Warning: could not create graph from " - "degree sequence. Trying again...\n"; - } - } + DegreeSequence ds; + generatePowerlawGraph(numVertices, tau, g, ds, rng); std::cout << "Running n = " << numVertices << ", tau = " << tau << "." << std::flush;