Files
@ a4477a81d96d
Branch filter:
Location: AENC/switchchain/cpp/graph_ecm.hpp - annotation
a4477a81d96d
808 B
text/x-c++hdr
Add datasets
ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 ca21806f0249 | #include "graph.hpp"
#include <algorithm>
#include <iostream>
#include <random>
#include <vector>
template <typename RNG>
bool erasedConfigurationModel(DegreeSequence &ds, Graph &g, RNG &rng) {
// List of all half-edges
std::vector<unsigned int> 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;
}
|