diff --git a/cpp/graph_ccm.hpp b/cpp/graph_ccm.hpp index e9844e398e31ed5f4f0b8c75f384c5375239951c..722389df1d432543e97ffd4c026d8af4b2fabd5d 100644 --- a/cpp/graph_ccm.hpp +++ b/cpp/graph_ccm.hpp @@ -69,13 +69,13 @@ bool constrainedConfigurationModel(DegreeSequence &ds, Graph &g, RNG &rng, if (method2) { // Now assign randomly to the remaining vertices // weighted by the number of half-edges they have left - auto vIter = uIter; while (dmax--) { std::uniform_int_distribution<> distr(1, availableEdges); // Go from edge index to number. We should really have a proper // data structure like some cumulative tree unsigned int halfEdge = distr(rng); unsigned int cumulative = 0; + auto vIter = uIter; for (auto iter = available.begin(); iter != available.end(); ++iter) { cumulative += iter->first; @@ -115,11 +115,13 @@ bool constrainedConfigurationModel(DegreeSequence &ds, Graph &g, RNG &rng, break; } } + if (vIter == uIter) + std::cerr << "ERROR 4 in CCM2.\n"; // pair u to v if (vIter->first == 0) - std::cerr << "ERROR 4 in CCM1.\n"; + std::cerr << "ERROR 5 in CCM1.\n"; if (!g.addEdge({u, vIter->second})) - std::cerr << "ERROR 5. Could not add edge in CCM1.\n"; + std::cerr << "ERROR 6. Could not add edge in CCM1.\n"; // Purge anything with degree zero // Be careful with invalidating the other iterator! // Degree of u is always greater or equal to the degree of v