From 81b8738230ffe185917a2ccfb28acb22ab4f209c Mon Sep 17 00:00:00 2001 From: Arthur Peters Date: Thu, 22 Apr 2021 18:04:09 -0500 Subject: [PATCH] Clean up naming conventions in algorithms. --- .../local_clustering_coefficient.h | 20 ++++----- .../louvain_clustering/louvain_clustering.h | 44 +++++++++---------- .../louvain_clustering/louvain_clustering.cpp | 4 +- .../local_clustering_coefficient_cli.cpp | 7 ++- 4 files changed, 37 insertions(+), 38 deletions(-) diff --git a/libgalois/include/katana/analytics/local_clustering_coefficient/local_clustering_coefficient.h b/libgalois/include/katana/analytics/local_clustering_coefficient/local_clustering_coefficient.h index be719b2ba5..d54e600291 100644 --- a/libgalois/include/katana/analytics/local_clustering_coefficient/local_clustering_coefficient.h +++ b/libgalois/include/katana/analytics/local_clustering_coefficient/local_clustering_coefficient.h @@ -23,31 +23,31 @@ class LocalClusteringCoefficientPlan : public Plan { }; static const Relabeling kDefaultRelabeling = kAutoRelabel; - static const bool kDefaultEdgeSorted = false; + static const bool kDefaultEdgesSorted = false; private: Algorithm algorithm_; - Relabeling relabeling_; bool edges_sorted_; + Relabeling relabeling_; LocalClusteringCoefficientPlan( Architecture architecture, Algorithm algorithm, bool edges_sorted, Relabeling relabeling) : Plan(architecture), algorithm_(algorithm), - relabeling_(relabeling), - edges_sorted_(edges_sorted) {} + edges_sorted_(edges_sorted), + relabeling_(relabeling) {} public: LocalClusteringCoefficientPlan() : LocalClusteringCoefficientPlan{ - kCPU, kOrderedCountPerThread, kDefaultEdgeSorted, + kCPU, kOrderedCountPerThread, kDefaultEdgesSorted, kDefaultRelabeling} {} Algorithm algorithm() const { return algorithm_; } // TODO(amp): These parameters should be documented. - Relabeling relabeling() const { return relabeling_; } bool edges_sorted() const { return edges_sorted_; } + Relabeling relabeling() const { return relabeling_; } /** * An ordered count algorithm that sorts the nodes by degree before @@ -58,14 +58,14 @@ class LocalClusteringCoefficientPlan : public Plan { * @param edges_sorted Are the edges of the graph already sorted. * @param relabeling Should the algorithm relabel the nodes. */ - static LocalClusteringCoefficientPlan LocalClusteringCoefficientAtomics( - bool edges_sorted = kDefaultEdgeSorted, + static LocalClusteringCoefficientPlan OrderedCountAtomics( + bool edges_sorted = kDefaultEdgesSorted, Relabeling relabeling = kDefaultRelabeling) { return {kCPU, kOrderedCountAtomics, edges_sorted, relabeling}; } - static LocalClusteringCoefficientPlan LocalClusteringCoefficientPerThread( - bool edges_sorted = kDefaultEdgeSorted, + static LocalClusteringCoefficientPlan OrderedCountPerThread( + bool edges_sorted = kDefaultEdgesSorted, Relabeling relabeling = kDefaultRelabeling) { return {kCPU, kOrderedCountPerThread, edges_sorted, relabeling}; } diff --git a/libgalois/include/katana/analytics/louvain_clustering/louvain_clustering.h b/libgalois/include/katana/analytics/louvain_clustering/louvain_clustering.h index cca8cf0d64..4254af348b 100644 --- a/libgalois/include/katana/analytics/louvain_clustering/louvain_clustering.h +++ b/libgalois/include/katana/analytics/louvain_clustering/louvain_clustering.h @@ -17,25 +17,20 @@ class LouvainClusteringPlan : public Plan { kDoAll, }; - static const bool kEnableVF = false; - static constexpr double kModularityThresholdPerRound = 0.01; - static constexpr double kModularityThresholdTotal = 0.01; - static const uint32_t kMaxIterations = 10; - static const uint32_t kMinGraphSize = 100; + static const bool kDefaultEnableVF = false; + static constexpr double kDefaultModularityThresholdPerRound = 0.01; + static constexpr double kDefaultModularityThresholdTotal = 0.01; + static const uint32_t kDefaultMaxIterations = 10; + static const uint32_t kDefaultMinGraphSize = 100; // Don't allow people to directly construct these, so as to have only one // consistent way to configure. private: Algorithm algorithm_; - //Flag to enable vertex following optimization. bool enable_vf_; - //Threshold for modularity gain per round. double modularity_threshold_per_round_; - //Threshold for overall modularity gain. double modularity_threshold_total_; - //Maximum number of iterations to execute. uint32_t max_iterations_; - //Minimum coarsened graph size uint32_t min_graph_size_; LouvainClusteringPlan( @@ -55,30 +50,35 @@ class LouvainClusteringPlan : public Plan { : LouvainClusteringPlan{ kCPU, kDoAll, - kEnableVF, - kModularityThresholdPerRound, - kModularityThresholdTotal, - kMaxIterations, - kMinGraphSize} {} + kDefaultEnableVF, + kDefaultModularityThresholdPerRound, + kDefaultModularityThresholdTotal, + kDefaultMaxIterations, + kDefaultMinGraphSize} {} Algorithm algorithm() const { return algorithm_; } - // TODO(amp): These parameters should be documented. - bool is_enable_vf() const { return enable_vf_; } + /// Enable vertex following optimization + bool enable_vf() const { return enable_vf_; } + /// Threshold for modularity gain per round. double modularity_threshold_per_round() const { return modularity_threshold_per_round_; } + /// Threshold for overall modularity gain. double modularity_threshold_total() const { return modularity_threshold_total_; } + /// Maximum number of iterations to execute. uint32_t max_iterations() const { return max_iterations_; } + /// Minimum coarsened graph size uint32_t min_graph_size() const { return min_graph_size_; } static LouvainClusteringPlan DoAll( - bool enable_vf = kEnableVF, - double modularity_threshold_per_round = kModularityThresholdPerRound, - double modularity_threshold_total = kModularityThresholdTotal, - uint32_t max_iterations = kMaxIterations, - uint32_t min_graph_size = kMinGraphSize) { + bool enable_vf = kDefaultEnableVF, + double modularity_threshold_per_round = + kDefaultModularityThresholdPerRound, + double modularity_threshold_total = kDefaultModularityThresholdTotal, + uint32_t max_iterations = kDefaultMaxIterations, + uint32_t min_graph_size = kDefaultMinGraphSize) { return { kCPU, kDoAll, diff --git a/libgalois/src/analytics/louvain_clustering/louvain_clustering.cpp b/libgalois/src/analytics/louvain_clustering/louvain_clustering.cpp index 2b043263eb..fe1d62315d 100644 --- a/libgalois/src/analytics/louvain_clustering/louvain_clustering.cpp +++ b/libgalois/src/analytics/louvain_clustering/louvain_clustering.cpp @@ -229,7 +229,7 @@ struct LouvainClusteringImplementation /* * Vertex following optimization */ - if (plan.is_enable_vf()) { + if (plan.enable_vf()) { Base::VertexFollowing(&graph_curr); // Find nodes that follow other nodes uint64_t num_unique_clusters = @@ -314,7 +314,7 @@ struct LouvainClusteringImplementation if (iter < plan.max_iterations() && (curr_mod - prev_mod) > plan.modularity_threshold_total()) { - if (!plan.is_enable_vf() && phase == 1) { + if (!plan.enable_vf() && phase == 1) { KATANA_LOG_DEBUG_ASSERT(num_nodes_orig == graph_curr.num_nodes()); katana::do_all(katana::iterate(graph_curr), [&](GNode n) { clusters_orig[n] = diff --git a/lonestar/analytics/cpu/local_clustering_coefficient/local_clustering_coefficient_cli.cpp b/lonestar/analytics/cpu/local_clustering_coefficient/local_clustering_coefficient_cli.cpp index 5a408071c8..5461c434d8 100644 --- a/lonestar/analytics/cpu/local_clustering_coefficient/local_clustering_coefficient_cli.cpp +++ b/lonestar/analytics/cpu/local_clustering_coefficient/local_clustering_coefficient_cli.cpp @@ -74,12 +74,11 @@ main(int argc, char** argv) { switch (algo) { case LocalClusteringCoefficientPlan::kOrderedCountAtomics: - plan = LocalClusteringCoefficientPlan::LocalClusteringCoefficientAtomics( - relabeling_flag); + plan = LocalClusteringCoefficientPlan::OrderedCountAtomics(relabeling_flag); break; case LocalClusteringCoefficientPlan::kOrderedCountPerThread: - plan = LocalClusteringCoefficientPlan::LocalClusteringCoefficientPerThread( - relabeling_flag); + plan = + LocalClusteringCoefficientPlan::OrderedCountPerThread(relabeling_flag); break; default: std::cerr << "Unknown algo: " << algo << "\n";