diff --git a/cpp/switchchain.cpp b/cpp/switchchain.cpp index 36b2c464badc33cb3a262ab9d03504fe4be0f5ec..930fedebbcfacbe96e1f3c7406b4f1238297b37e 100644 --- a/cpp/switchchain.cpp +++ b/cpp/switchchain.cpp @@ -2,8 +2,8 @@ #include "exports.hpp" #include "graph.hpp" #include "graph_gcm.hpp" +#include "graph_powerlaw.hpp" #include "graph_spectrum.hpp" -#include "powerlaw.hpp" #include #include #include @@ -65,37 +65,11 @@ int main(int argc, char* argv[]) { for (int numVertices = 500; numVertices <= 500; 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 < 5; ++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); #if 0 //