#ifndef NK_COMMUNITY_H #define NK_COMMUNITY_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "rust/cxx.h" namespace NetworKit { using namespace std; // COMMUNITY inline unique_ptr NewAdjustedRandMeasure() { return make_unique(); } inline unique_ptr NewClusteringGenerator() { return make_unique(); } inline unique_ptr CMMakeContinuousBalancedClustering(ClusteringGenerator &gen, const Graph &G, count k) { return make_unique(gen.makeContinuousBalancedClustering(G, k)); } inline unique_ptr CMMakeNoncontinuousBalancedClustering(ClusteringGenerator &gen, const Graph &G, count k) { return make_unique(gen.makeNoncontinuousBalancedClustering(G, k)); } inline unique_ptr CMMakeOneClustering(ClusteringGenerator &gen, const Graph &G) { return make_unique(gen.makeOneClustering(G)); } inline unique_ptr CMMakeRandomClustering(ClusteringGenerator &gen, const Graph &G, count k) { return make_unique(gen.makeRandomClustering(G, k)); } inline unique_ptr CMMakeSingletonClustering(ClusteringGenerator &gen, const Graph &G) { return make_unique(gen.makeSingletonClustering(G)); } inline unique_ptr> CoverF1SimilarityGetValues(const CoverF1Similarity &e) { return make_unique>(e.getValues()); } inline unique_ptr NewCoverF1Similarity(const Graph &G, const Cover &C, const Cover &reference) { return make_unique(CoverF1Similarity(G, C, reference)); } inline unique_ptr> CoverHubDominanceGetValues(const CoverHubDominance &e) { return make_unique>(e.getValues()); } inline unique_ptr NewCoverHubDominance(const Graph &G, const Cover &C) { return make_unique(CoverHubDominance(G, C)); } inline unique_ptr NewCoverage() { return make_unique(); } inline unique_ptr NewCutClustering(const Graph &G, edgeweight alpha) { return make_unique(G, alpha); } inline unique_ptr CutClusteringGetPartition(CutClustering &a) { return make_unique(a.getPartition()); } class HierarchyIter { map data; map::iterator cur; map::iterator end; public: HierarchyIter(map data_) : data(data_) { cur = data.begin(); end = data.end(); } inline bool isAtEnd() const { return cur == end; } inline void advance() { if (cur != end) { cur++; } } inline edgeweight curKey() const { return cur->first; } inline unique_ptr curVal() const { return make_unique(cur->second); } }; // CutClustering::getClusterHierarchy inline unique_ptr CutClusteringGetClusterHierarchy(const Graph &g) { return make_unique(CutClustering::getClusterHierarchy(g)); } inline unique_ptr NewEdgeCut() { return make_unique(); } namespace GraphClusteringTools { inline unique_ptr MakeCommunicationGraph(const Graph &graph, Partition &zeta) { return make_unique(communicationGraph(graph, zeta)); } } inline unique_ptr NewGraphStructuralRandMeasure() { return make_unique(); } inline unique_ptr NewHubDominance() { return make_unique(); } inline unique_ptr NewIntrapartitionDensity(const Graph &G, const Partition &P) { return make_unique(G, P); } inline unique_ptr> IntrapartitionDensityGetValues(const IntrapartitionDensity &e) { return make_unique>(e.getValues()); } inline unique_ptr NewIsolatedInterpartitionConductance(const Graph &G, const Partition &P) { return make_unique(G, P); } inline unique_ptr> IsolatedInterpartitionConductanceGetValues(const IsolatedInterpartitionConductance &e) { return make_unique>(e.getValues()); } inline unique_ptr NewIsolatedInterpartitionExpansion(const Graph &G, const Partition &P) { return make_unique(G, P); } inline unique_ptr> IsolatedInterpartitionExpansionGetValues(const IsolatedInterpartitionExpansion &e) { return make_unique>(e.getValues()); } inline unique_ptr NewJaccardMeasure() { return make_unique(); } inline unique_ptr NewLFM(const Graph &G, SelectiveCommunityDetector &scd) { return make_unique(G, scd); } inline unique_ptr LFMGetCover(const LFM &algo) { return make_unique(algo.getCover()); } inline unique_ptr NewLPDegreeOrdered(const Graph &g) { return make_unique(g); } inline unique_ptr LPDegreeOrderedGetPartition(LPDegreeOrdered &a) { return make_unique(a.getPartition()); } inline unique_ptr NewLouvainMapEquation(const Graph &graph, bool hierarchical, count maxIterations, const rust::Str parallelizationStrategy) { string ps(parallelizationStrategy); return make_unique(graph, hierarchical, maxIterations, ps); } inline unique_ptr LouvainMapEquationGetPartition(LouvainMapEquation &a) { return make_unique(a.getPartition()); } inline unique_ptr NewModularity() { return make_unique(); } inline unique_ptr NewNMIDistance() { return make_unique(); } inline unique_ptr NewNodeStructuralRandMeasure() { return make_unique(); } inline unique_ptr NewOverlappingNMIDistance( uint8_t normalization) { OverlappingNMIDistance::Normalization n; switch (normalization) { case 2: n = OverlappingNMIDistance::Normalization::ARITHMETIC_MEAN; break; case 4: n = OverlappingNMIDistance::Normalization::JOINT_ENTROPY; break; case 1: n = OverlappingNMIDistance::Normalization::GEOMETRIC_MEAN; break; case 3: n = OverlappingNMIDistance::Normalization::MAX; break; case 0: n = OverlappingNMIDistance::Normalization::MIN; break; default: n = OverlappingNMIDistance::Normalization::MIN; break; } return make_unique(n); } inline unique_ptr NewPLM(const Graph &G, bool refine, double gamma, rust::Str par, count maxIter, bool turbo, bool recurse) { return make_unique(G, refine, gamma, string(par), maxIter, turbo, recurse); } inline unique_ptr PLMCoarsen(const Graph &G, const Partition &zeta, rust::Vec &mapping) { auto res = PLM::coarsen(G, zeta); for (auto &&n : res.second) { mapping.push_back(n); } return make_unique(res.first); } inline unique_ptr PLMProlong( const Graph &g, const Partition &zetaCoarse, const Graph &Gfine, rust::Slice nodeToMetaNode) { return make_unique(PLM::prolong(g, zetaCoarse, Gfine, vector(nodeToMetaNode.begin(), nodeToMetaNode.end()))); } inline unique_ptr PLMGetPartition(PLM &a) { return make_unique(a.getPartition()); } inline unique_ptr NewPLP(const Graph &G, count theta = none, count maxIterations = none) { return make_unique(G, theta, maxIterations); } inline unique_ptr PLPGetPartition(PLP &a) { return make_unique(a.getPartition()); } inline unique_ptr NewParallelLeiden(const Graph &graph, count iterations = 3, bool randomize = true, double gamma = 1) { return make_unique(graph, iterations, randomize, gamma); } inline unique_ptr ParallelLeidenGetPartition(ParallelLeiden &a) { return make_unique(a.getPartition()); } inline unique_ptr NewPartitionFragmentation(const Graph &G, const Partition &P) { return make_unique(G, P); } inline unique_ptr> PartitionFragmentationGetValues(const PartitionFragmentation &e) { return make_unique>(e.getValues()); } inline unique_ptr NewPartitionHubDominance(const Graph &G, const Partition &P) { return make_unique(G, P); } inline unique_ptr> PartitionHubDominanceGetValues(const PartitionHubDominance &e) { return make_unique>(e.getValues()); } inline unique_ptr NewPartitionIntersection() { return make_unique(); } inline unique_ptr PartitionIntersectionCalculate(PartitionIntersection &algo, const Partition &zeta, const Partition &eta) { return make_unique(algo.calculate(zeta, eta)); } inline unique_ptr NewStablePartitionNodes(const Graph &G, const Partition &P) { return make_unique(G, P); } inline unique_ptr> StablePartitionNodesGetValues(const StablePartitionNodes &e) { return make_unique>(e.getValues()); } } #endif // NK_COMMUNITY_H