#include "graph.hpp" #include #include #include #include template bool erasedConfigurationModel(DegreeSequence &ds, Graph &g, RNG &rng) { // List of all half-edges std::vector halfEdges; for (unsigned int i = 0; i < ds.size(); ++i) halfEdges.insert(halfEdges.end(), ds[i], i); // Clear the graph g.reset(ds.size()); if (halfEdges.size() % 2 != 0) return false; std::shuffle(halfEdges.begin(), halfEdges.end(), rng); // pair halfEdges[2*i] with halfEdges[2*i+1] for (auto iter = halfEdges.begin(); iter != halfEdges.end();) { auto u = *iter++; auto v = *iter++; if (u != v) g.addEdge({u, v}); // checks for double edges } return true; }