#ifndef NK_GENERATORS_H #define NK_GENERATORS_H #include "rust/cxx.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace NetworKit { using namespace std; inline unique_ptr NewBarabasiAlbertGenerator(count k, count nMax, count n0 = 0, bool batagelj = true) { return make_unique(k, nMax, n0, batagelj); } inline unique_ptr BarabasiAlbertGeneratorGenerate(BarabasiAlbertGenerator &algo) { return make_unique(algo.generate()); } inline unique_ptr NewChungLuGenerator(const std::vector °reeSequence) { return make_unique(degreeSequence); } inline unique_ptr ChungLuGeneratorGenerate(ChungLuGenerator &algo) { return make_unique(algo.generate()); } inline unique_ptr NewClusteredRandomGraphGenerator(count n, count k, double pIntra, double pInter) { return make_unique(n, k, pIntra, pInter); } inline unique_ptr ClusteredRandomGraphGeneratorGenerate(ClusteredRandomGraphGenerator &algo) { return make_unique(algo.generate()); } inline unique_ptr ClusteredRandomGraphGeneratorGetCommunities(ClusteredRandomGraphGenerator &algo) { return make_unique(algo.getCommunities()); } inline unique_ptr NewDorogovtsevMendesGenerator(count nNodes) { return make_unique(nNodes); } inline unique_ptr DorogovtsevMendesGeneratorGenerate(DorogovtsevMendesGenerator &algo) { return make_unique(algo.generate()); } inline uint8_t convertEventType(GraphEvent::Type t) { switch (t) { case GraphEvent::Type::NODE_ADDITION: return 0; break; case GraphEvent::Type::NODE_REMOVAL: return 1; break; case GraphEvent::Type::NODE_RESTORATION: return 2; break; case GraphEvent::Type::EDGE_ADDITION: return 3; break; case GraphEvent::Type::EDGE_REMOVAL: return 4; break; case GraphEvent::Type::EDGE_WEIGHT_UPDATE: return 5; break; case GraphEvent::Type::EDGE_WEIGHT_INCREMENT: return 6; break; case GraphEvent::Type::TIME_STEP: return 7; break; default: return 255; break; } } inline unique_ptr NewDynamicDorogovtsevMendesGenerator() { return make_unique(); } inline void DynamicDorogovtsevMendesGeneratorGenerate(DynamicDorogovtsevMendesGenerator &algo, count nSteps, rust::Vec &tps, rust::Vec &us, rust::Vec &vs, rust::Vec &ws) { for (auto &&evt : algo.generate(nSteps)) { tps.push_back(convertEventType(evt.type)); us.push_back(evt.u); vs.push_back(evt.v); ws.push_back(evt.w); } } inline unique_ptr NewDynamicForestFireGenerator(double p, bool directed, double r = 1.0) { return make_unique(p, directed, r); } inline void DynamicForestFireGeneratorGenerate(DynamicForestFireGenerator &algo, count nSteps, rust::Vec &tps, rust::Vec &us, rust::Vec &vs, rust::Vec &ws) { for (auto &&evt : algo.generate(nSteps)) { tps.push_back(convertEventType(evt.type)); us.push_back(evt.u); vs.push_back(evt.v); ws.push_back(evt.w); } } inline unique_ptr NewDynamicHyperbolicGenerator(count n = 1000, double avgDegree = 6, double exp = 3, double T = 0, double moveEachStep = 0, double moveDistance = 0) { return make_unique(n, avgDegree, exp, T, moveEachStep, moveDistance); } inline void DynamicHyperbolicGeneratorGenerate(DynamicHyperbolicGenerator &algo, count nSteps, rust::Vec &tps, rust::Vec &us, rust::Vec &vs, rust::Vec &ws) { for (auto &&evt : algo.generate(nSteps)) { tps.push_back(convertEventType(evt.type)); us.push_back(evt.u); vs.push_back(evt.v); ws.push_back(evt.w); } } inline unique_ptr DynamicHyperbolicGeneratorGetGraph(const DynamicHyperbolicGenerator &algo) { return make_unique(algo.getGraph()); } inline void DynamicHyperbolicGeneratorGetCoordinates(const DynamicHyperbolicGenerator &algo, rust::Vec &xs, rust::Vec &ys) { for (auto &&pair : algo.getCoordinates()) { xs.push_back(pair[0]); ys.push_back(pair[1]); } } inline unique_ptr NewDynamicPathGenerator() { return make_unique(); } inline void DynamicPathGeneratorGenerate(DynamicPathGenerator &algo, count nSteps, rust::Vec &tps, rust::Vec &us, rust::Vec &vs, rust::Vec &ws) { for (auto &&evt : algo.generate(nSteps)) { tps.push_back(convertEventType(evt.type)); us.push_back(evt.u); vs.push_back(evt.v); ws.push_back(evt.w); } } inline unique_ptr NewDynamicPubWebGenerator(count numNodes, count numberOfDenseAreas, coordinate neighborhoodRadius, count maxNumberOfNeighbors, bool writeInitialGraphToStream = true) { return make_unique(numNodes, numberOfDenseAreas, neighborhoodRadius, maxNumberOfNeighbors, writeInitialGraphToStream); } inline void DynamicPubWebGeneratorGenerate(DynamicPubWebGenerator &algo, count nSteps, rust::Vec &tps, rust::Vec &us, rust::Vec &vs, rust::Vec &ws) { for (auto &&evt : algo.generate(nSteps)) { tps.push_back(convertEventType(evt.type)); us.push_back(evt.u); vs.push_back(evt.v); ws.push_back(evt.w); } } inline unique_ptr DynamicPubWebGeneratorGetGraph(const DynamicPubWebGenerator &algo) { return make_unique(algo.getGraph()); } inline void DynamicPubWebGeneratorGetCoordinates(const DynamicPubWebGenerator &algo, rust::Vec &xs, rust::Vec &ys) { for (auto &&pair : algo.getCoordinates()) { xs.push_back(pair[0]); ys.push_back(pair[1]); } } inline void DynamicPubWebGeneratorGetNewCoordinates(const DynamicPubWebGenerator &algo, rust::Vec &ns, rust::Vec &xs, rust::Vec &ys) { for (auto &&pair : algo.getNewCoordinates()) { ns.push_back(pair.first); xs.push_back(pair.second[0]); ys.push_back(pair.second[1]); } } inline unique_ptr NewEdgeSwitchingMarkovChainGenerator(const std::vector &sequence, bool ignoreIfNotRealizable = false, count numSwitchesPerEdge = 10) { return make_unique(sequence, ignoreIfNotRealizable, numSwitchesPerEdge); } inline unique_ptr EdgeSwitchingMarkovChainGeneratorGenerate(EdgeSwitchingMarkovChainGenerator &algo) { return make_unique(algo.generate()); } inline unique_ptr NewErdosRenyiGenerator(count nNodes, double prob, bool directed = false, bool self_loops = false) { return make_unique(nNodes, prob, directed, self_loops); } inline unique_ptr ErdosRenyiGeneratorGenerate(ErdosRenyiGenerator &algo) { return make_unique(algo.generate()); } inline unique_ptr NewHavelHakimiGenerator(const std::vector &sequence, bool ignoreIfRealizable = false) { return make_unique(sequence, ignoreIfRealizable); } inline unique_ptr HavelHakimiGeneratorGenerate(HavelHakimiGenerator &algo) { return make_unique(algo.generate()); } inline unique_ptr NewHyperbolicGenerator(count n = 10000, double avgDegree = 6, double exp = 3, double T = 0) { return make_unique(n, avgDegree, exp, T); } inline unique_ptr HyperbolicGeneratorGenerate(HyperbolicGenerator &algo) { return make_unique(algo.generate()); } inline unique_ptr HyperbolicGeneratorGenerate(HyperbolicGenerator &algo, rust::Slice angles, rust::Slice radii, double R, double T = 0) { vector as{angles.begin(), angles.end()}; vector rs{radii.begin(), radii.end()}; return make_unique(algo.generate(as, rs, R, T)); } inline unique_ptr NewLFRGenerator(count n) { return make_unique(n); } inline unique_ptr LFRGeneratorGenerate(LFRGenerator &algo) { return make_unique(algo.generate()); } inline void LFRGeneratorSetDegreeSequence(LFRGenerator &algo, rust::Slice seq) { vector s{seq.begin(), seq.end()}; algo.setDegreeSequence(s); } inline void LFRGeneratorSetCommunitySizeSequence(LFRGenerator &algo, rust::Slice seq) { vector s{seq.begin(), seq.end()}; algo.setCommunitySizeSequence(s); } inline void LFRGeneratorSetPartition(LFRGenerator &algo, unique_ptr p) { algo.setPartition(*p); } inline unique_ptr LFRGeneratorGetGraph(const LFRGenerator &algo) { return make_unique(algo.getGraph()); } inline unique_ptr LFRGeneratorGetPartition(const LFRGenerator &algo) { return make_unique(algo.getPartition()); } inline unique_ptr NewMocnikGenerator(count dim, count n, double k, bool weighted = false) { return make_unique(dim, n, k, weighted); } inline unique_ptr MocnikGeneratorGenerate(MocnikGenerator &algo) { return make_unique(algo.generate()); } inline unique_ptr NewMocnikGeneratorBasic(count dim, count n, double k) { return make_unique(dim, n, k); } inline unique_ptr MocnikGeneratorBasicGenerate(MocnikGeneratorBasic &algo) { return make_unique(algo.generate()); } inline unique_ptr NewPowerlawDegreeSequence(count minDeg, count maxDeg, double gamma) { return make_unique(minDeg, maxDeg, gamma); } inline unique_ptr> PowerlawDegreeSequenceGetDegreeSequence(const PowerlawDegreeSequence &algo, count numNodes) { return make_unique>(algo.getDegreeSequence(numNodes)); } inline unique_ptr NewPubWebGenerator(count numNodes, count numberOfDenseAreas, coordinate neighborhoodRadius, count maxNumberOfNeighbors) { return make_unique(numNodes, numberOfDenseAreas, neighborhoodRadius, maxNumberOfNeighbors); } inline unique_ptr PubWebGeneratorGenerate(PubWebGenerator &algo) { return make_unique(algo.generate()); } inline void PubWebGeneratorGetCoordinates(const PubWebGenerator &algo, rust::Vec &xs, rust::Vec &ys) { for (auto &&pair : algo.getCoordinates()) { xs.push_back(pair[0]); ys.push_back(pair[1]); } } inline unique_ptr NewRegularRingLatticeGenerator(count nNodes, count nNeighbors) { return make_unique(nNodes, nNeighbors); } inline unique_ptr RegularRingLatticeGeneratorGenerate(RegularRingLatticeGenerator &algo) { return make_unique(algo.generate()); } inline unique_ptr NewRmatGenerator(count scale, count edgeFactor, double a, double b, double c, double d, bool weighted = false, count reduceNodes = 0) { return make_unique(scale, edgeFactor, a, b, c, d, weighted, reduceNodes); } inline unique_ptr RmatGeneratorGenerate(RmatGenerator &algo) { return make_unique(algo.generate()); } inline unique_ptr NewWattsStrogatzGenerator(count nNodes, count nNeighbors, double p) { return make_unique(nNodes, nNeighbors, p); } inline unique_ptr WattsStrogatzGeneratorGenerate(WattsStrogatzGenerator &algo) { return make_unique(algo.generate()); } } #endif // NK_GENERATORS_H