diff --git a/cpp/switchchain_successrates.cpp b/cpp/switchchain_successrates.cpp index 38df1c97466f53f30cfcfd77d6e32d51b769d325..44465ab360e2d02379af8f1fb9a5c4b6ed0f8c30 100644 --- a/cpp/switchchain_successrates.cpp +++ b/cpp/switchchain_successrates.cpp @@ -1,6 +1,6 @@ #include "exports.hpp" #include "graph.hpp" -#include "powerlaw.hpp" +#include "graph_powerlaw.hpp" #include "switchchain.hpp" #include #include @@ -41,37 +41,11 @@ int main(int argc, char* argv[]) { for (int numVertices = 1000; numVertices <= 1000; numVertices += 1000) { 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 < 2000; ++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); SwitchChain chain; if (!chain.initialize(g)) {