From dc000c770029b50ce9e79d3efccbc18c41537380 Mon Sep 17 00:00:00 2001 From: Arun Sharma Date: Mon, 29 Jun 2026 18:49:50 -0700 Subject: [PATCH] NETWORKIT_OVERRIDE_CLANG_FORMAT=clang-format-18 ./check_code.sh --- .../IncrementalUniformRandomSelector.hpp | 2 +- include/networkit/auxiliary/Vector2Arrow.hpp | 6 +- .../ParallelLeidenScoringExtension.hpp | 25 ++--- .../community/ParallelLeidenView.hpp | 2 +- .../generators/ErdosRenyiEnumerator.hpp | 8 +- include/networkit/graph/Attributes.hpp | 2 +- include/networkit/graph/EdgeIterators.hpp | 2 +- include/networkit/graph/Graph.hpp | 12 +-- include/networkit/graph/GraphBuilder.hpp | 4 +- include/networkit/graph/GraphW.hpp | 4 +- include/networkit/graph/NodeIterators.hpp | 2 +- .../graph/RandomMaximumSpanningForest.hpp | 2 +- .../graph/UnionMaximumSpanningForest.hpp | 2 +- .../networkit/io/NetworkitBinaryReader.hpp | 2 +- include/networkit/layout/LayoutAlgorithm.hpp | 4 +- .../structures/LeastCommonAncestor.hpp | 2 +- .../networkit/structures/LocalCommunity.hpp | 8 +- .../centrality/GroupClosenessGrowShrink.cpp | 21 ++-- .../cpp/coarsening/CoarsenedGraphView.cpp | 1 - networkit/cpp/community/ParallelLeiden.cpp | 4 +- .../ParallelLeidenCPMScoringExtension.cpp | 44 +++----- ...rallelLeidenModularityScoringExtension.cpp | 36 +++---- .../cpp/community/ParallelLeidenView.cpp | 100 +++++++++--------- .../NeighborhoodFunctionHeuristic.cpp | 4 +- networkit/cpp/distance/test/DistanceGTest.cpp | 27 ++--- .../cpp/edgescores/PrefixJaccardScore.cpp | 2 +- .../cpp/generators/test/GeneratorsGTest.cpp | 5 +- networkit/cpp/matching/test/MatcherGTest.cpp | 5 +- .../cpp/scd/LocalDegreeDirectedGraph.hpp | 3 +- networkit/cpp/scd/LocalTightnessExpansion.cpp | 2 +- networkit/cpp/viz/MaxentStress.cpp | 5 +- networkit/cpp/viz/test/VizGTest.cpp | 5 +- 32 files changed, 163 insertions(+), 190 deletions(-) diff --git a/include/networkit/auxiliary/IncrementalUniformRandomSelector.hpp b/include/networkit/auxiliary/IncrementalUniformRandomSelector.hpp index cff2ccc51..f37b3d141 100644 --- a/include/networkit/auxiliary/IncrementalUniformRandomSelector.hpp +++ b/include/networkit/auxiliary/IncrementalUniformRandomSelector.hpp @@ -24,7 +24,7 @@ class IncrementalUniformRandomSelector { /** * Initialize the random select for one element. */ - IncrementalUniformRandomSelector() : counter(1){}; + IncrementalUniformRandomSelector() : counter(1) {}; /** * Add the next element. diff --git a/include/networkit/auxiliary/Vector2Arrow.hpp b/include/networkit/auxiliary/Vector2Arrow.hpp index a1d22f158..7ea467b94 100644 --- a/include/networkit/auxiliary/Vector2Arrow.hpp +++ b/include/networkit/auxiliary/Vector2Arrow.hpp @@ -5,8 +5,8 @@ * Author: Ian Chen (ianchen3) */ -#ifndef NETWORKIT_AUXILIARY_VECTOR2ARROW_HPP_ -#define NETWORKIT_AUXILIARY_VECTOR2ARROW_HPP_ +#ifndef NETWORKIT_AUXILIARY_VECTOR2_ARROW_HPP_ +#define NETWORKIT_AUXILIARY_VECTOR2_ARROW_HPP_ #include #include @@ -35,4 +35,4 @@ std::shared_ptr vectorToArrow(std::vector vec) { } // namespace Aux -#endif +#endif // NETWORKIT_AUXILIARY_VECTOR2_ARROW_HPP_ diff --git a/include/networkit/community/ParallelLeidenScoringExtension.hpp b/include/networkit/community/ParallelLeidenScoringExtension.hpp index 5c07db948..56f1602d7 100644 --- a/include/networkit/community/ParallelLeidenScoringExtension.hpp +++ b/include/networkit/community/ParallelLeidenScoringExtension.hpp @@ -11,14 +11,16 @@ namespace NetworKit { -using ParallelLeidenCommunityScoreFunction = - double (*)(double cutWeight, double degree, double communityVolume, count subsetSize, - count communitySize, double gamma, double inverseGraphVolume); +using ParallelLeidenCommunityScoreFunction = double (*)(double cutWeight, double degree, + double communityVolume, count subsetSize, + count communitySize, double gamma, + double inverseGraphVolume); -using ParallelLeidenRefineSetConditionFunction = - bool (*)(double cutWeight, double subsetVolume, count subsetSize, double targetVolume, - count targetSize, double sourceVolume, count sourceSize, double gamma, - double inverseGraphVolume); +using ParallelLeidenRefineSetConditionFunction = bool (*)(double cutWeight, double subsetVolume, + count subsetSize, double targetVolume, + count targetSize, double sourceVolume, + count sourceSize, double gamma, + double inverseGraphVolume); } // namespace NetworKit @@ -27,8 +29,8 @@ extern "C" { /** * Required: score a candidate community during the move phase. */ -double networkitParallelLeidenCommunityScore(double cutWeight, double degree, double communityVolume, - NetworKit::count subsetSize, +double networkitParallelLeidenCommunityScore(double cutWeight, double degree, + double communityVolume, NetworKit::count subsetSize, NetworKit::count communitySize, double gamma, double inverseGraphVolume); @@ -40,8 +42,7 @@ double networkitParallelLeidenCurrentCommunityThreshold(double cutWeight, double double communityVolume, NetworKit::count subsetSize, NetworKit::count communitySize, - double gamma, - double inverseGraphVolume); + double gamma, double inverseGraphVolume); /** * Optional: override the refine-phase R-set condition. @@ -61,7 +62,7 @@ bool networkitParallelLeidenRefineTSetCondition(double cutWeight, double subsetV NetworKit::count subsetSize, double targetVolume, NetworKit::count targetSize, double sourceVolume, NetworKit::count sourceSize, double gamma, - double inverseGraphVolume); + double inverseGraphVolume); } // extern "C" diff --git a/include/networkit/community/ParallelLeidenView.hpp b/include/networkit/community/ParallelLeidenView.hpp index 7db614c15..5fb6dbcca 100644 --- a/include/networkit/community/ParallelLeidenView.hpp +++ b/include/networkit/community/ParallelLeidenView.hpp @@ -14,8 +14,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/include/networkit/generators/ErdosRenyiEnumerator.hpp b/include/networkit/generators/ErdosRenyiEnumerator.hpp index 4862f7e17..0580920c6 100644 --- a/include/networkit/generators/ErdosRenyiEnumerator.hpp +++ b/include/networkit/generators/ErdosRenyiEnumerator.hpp @@ -299,14 +299,14 @@ class ErdosRenyiEnumerator final { // SFINAE to allow using functors with and without thread id as parameter template - auto callHandle(Handle h, unsigned tid, node u, node v) const - -> decltype(h(0u, node{0}, node{0})) { + auto callHandle(Handle h, unsigned tid, node u, + node v) const -> decltype(h(0u, node{0}, node{0})) { return h(tid, u, v); } template - auto callHandle(Handle h, unsigned /*tid*/, node u, node v) const - -> decltype(h(node{0}, node{0})) { + auto callHandle(Handle h, unsigned /*tid*/, node u, + node v) const -> decltype(h(node{0}, node{0})) { return h(u, v); } }; diff --git a/include/networkit/graph/Attributes.hpp b/include/networkit/graph/Attributes.hpp index 9ada4869f..e9518046a 100644 --- a/include/networkit/graph/Attributes.hpp +++ b/include/networkit/graph/Attributes.hpp @@ -155,7 +155,7 @@ class AttributeStorage final : public Base { private: std::vector values; // the real attribute storage -}; // class AttributeStorage +}; // class AttributeStorage template class Attribute { diff --git a/include/networkit/graph/EdgeIterators.hpp b/include/networkit/graph/EdgeIterators.hpp index 2340b58f8..1e469f114 100644 --- a/include/networkit/graph/EdgeIterators.hpp +++ b/include/networkit/graph/EdgeIterators.hpp @@ -151,7 +151,7 @@ class EdgeTypeRange { public: EdgeTypeRange(const GraphType &G) : G(&G) {} - EdgeTypeRange() : G(nullptr){}; + EdgeTypeRange() : G(nullptr) {}; ~EdgeTypeRange() = default; diff --git a/include/networkit/graph/Graph.hpp b/include/networkit/graph/Graph.hpp index c34dd99d7..5b113a163 100644 --- a/include/networkit/graph/Graph.hpp +++ b/include/networkit/graph/Graph.hpp @@ -527,8 +527,8 @@ class Graph { typename Aux::FunctionTraits::template arg<2>::type>::value && std::is_same::template arg<3>::type>:: value>::type * = (void *)0> - auto edgeLambda(F &f, node u, node v, edgeweight ew, edgeid id) const - -> decltype(f(u, v, ew, id)) { + auto edgeLambda(F &f, node u, node v, edgeweight ew, + edgeid id) const -> decltype(f(u, v, ew, id)) { return f(u, v, ew, id); } @@ -560,8 +560,8 @@ class Graph { (Aux::FunctionTraits::arity >= 2) && std::is_same::template arg< 2>::type>::value>::type * = (void *)0> - auto edgeLambda(F &f, node u, node v, edgeweight ew, edgeid /*id*/) const - -> decltype(f(u, v, ew)) { + auto edgeLambda(F &f, node u, node v, edgeweight ew, + edgeid /*id*/) const -> decltype(f(u, v, ew)) { return f(u, v, ew); } @@ -574,8 +574,8 @@ class Graph { (Aux::FunctionTraits::arity >= 1) && std::is_same::template arg< 1>::type>::value>::type * = (void *)0> - auto edgeLambda(F &f, node u, node v, edgeweight /*ew*/, edgeid /*id*/) const - -> decltype(f(u, v)) { + auto edgeLambda(F &f, node u, node v, edgeweight /*ew*/, + edgeid /*id*/) const -> decltype(f(u, v)) { return f(u, v); } diff --git a/include/networkit/graph/GraphBuilder.hpp b/include/networkit/graph/GraphBuilder.hpp index 43639c111..070f1fc2f 100644 --- a/include/networkit/graph/GraphBuilder.hpp +++ b/include/networkit/graph/GraphBuilder.hpp @@ -59,8 +59,8 @@ class GraphBuilder { node source; node destination; // HalfEdge(node source, node destination); - HalfEdge(){}; - HalfEdge(node source, node destination) : source(source), destination(destination){}; + HalfEdge() {}; + HalfEdge(node source, node destination) : source(source), destination(destination) {}; }; std::vector>> diff --git a/include/networkit/graph/GraphW.hpp b/include/networkit/graph/GraphW.hpp index f0f514377..9e88a3bb5 100644 --- a/include/networkit/graph/GraphW.hpp +++ b/include/networkit/graph/GraphW.hpp @@ -999,7 +999,7 @@ class GraphW final : public Graph { public: NeighborRange(const GraphW &G, node u) : G(&G), u(u) { assert(G.hasNode(u)); }; - NeighborRange() : G(nullptr){}; + NeighborRange() : G(nullptr) {}; NeighborIterator begin() const { assert(G); @@ -1037,7 +1037,7 @@ class GraphW final : public Graph { public: NeighborWeightRange(const GraphW &G, node u) : G(&G), u(u) { assert(G.hasNode(u)); }; - NeighborWeightRange() : G(nullptr){}; + NeighborWeightRange() : G(nullptr) {}; NeighborWeightIterator begin() const { assert(G); diff --git a/include/networkit/graph/NodeIterators.hpp b/include/networkit/graph/NodeIterators.hpp index b50dffb7d..97cca72f2 100644 --- a/include/networkit/graph/NodeIterators.hpp +++ b/include/networkit/graph/NodeIterators.hpp @@ -107,7 +107,7 @@ class NodeRangeBase { public: NodeRangeBase(const GraphType &G) : G(&G) {} - NodeRangeBase() : G(nullptr){}; + NodeRangeBase() : G(nullptr) {}; ~NodeRangeBase() = default; diff --git a/include/networkit/graph/RandomMaximumSpanningForest.hpp b/include/networkit/graph/RandomMaximumSpanningForest.hpp index b86bfbed3..536952784 100644 --- a/include/networkit/graph/RandomMaximumSpanningForest.hpp +++ b/include/networkit/graph/RandomMaximumSpanningForest.hpp @@ -96,7 +96,7 @@ class RandomMaximumSpanningForest : public Algorithm { && (u > other.u || (u == other.u && v > other.v))))); }; weightedEdge(node u, node v, double attribute, edgeid eid = 0) - : attribute(attribute), u(u), v(v), eid(eid), rand(Aux::Random::integer()){}; + : attribute(attribute), u(u), v(v), eid(eid), rand(Aux::Random::integer()) {}; }; const Graph &G; diff --git a/include/networkit/graph/UnionMaximumSpanningForest.hpp b/include/networkit/graph/UnionMaximumSpanningForest.hpp index 248f81af4..988832d9e 100644 --- a/include/networkit/graph/UnionMaximumSpanningForest.hpp +++ b/include/networkit/graph/UnionMaximumSpanningForest.hpp @@ -89,7 +89,7 @@ class UnionMaximumSpanningForest final : public Algorithm { && (u > other.u || (u == other.u && v > other.v))); }; weightedEdge(node u, node v, edgeweight attribute, edgeid eid = 0) - : attribute(attribute), u(u), v(v), eid(eid){}; + : attribute(attribute), u(u), v(v), eid(eid) {}; }; const Graph *G; diff --git a/include/networkit/io/NetworkitBinaryReader.hpp b/include/networkit/io/NetworkitBinaryReader.hpp index 112d62b1f..a0e106929 100644 --- a/include/networkit/io/NetworkitBinaryReader.hpp +++ b/include/networkit/io/NetworkitBinaryReader.hpp @@ -29,7 +29,7 @@ namespace NetworKit { class NetworkitBinaryReader final : public GraphReader { public: - NetworkitBinaryReader(){}; + NetworkitBinaryReader() {}; GraphW read(std::string_view path) override; GraphW readFromBuffer(const std::vector &data); diff --git a/include/networkit/layout/LayoutAlgorithm.hpp b/include/networkit/layout/LayoutAlgorithm.hpp index b11245942..96cde87fd 100644 --- a/include/networkit/layout/LayoutAlgorithm.hpp +++ b/include/networkit/layout/LayoutAlgorithm.hpp @@ -22,9 +22,9 @@ class LayoutAlgorithm { public: LayoutAlgorithm(const Graph &G) - : G(G){ + : G(G) { - }; + }; virtual void run() = 0; diff --git a/include/networkit/structures/LeastCommonAncestor.hpp b/include/networkit/structures/LeastCommonAncestor.hpp index 1dc46b107..6ee2fb66a 100644 --- a/include/networkit/structures/LeastCommonAncestor.hpp +++ b/include/networkit/structures/LeastCommonAncestor.hpp @@ -8,8 +8,8 @@ #ifndef NETWORKIT_STRUCTURES_LEAST_COMMON_ANCESTOR_HPP_ #define NETWORKIT_STRUCTURES_LEAST_COMMON_ANCESTOR_HPP_ -#include #include +#include #include "networkit/auxiliary/RangeMinimumQuery.hpp" #include #include diff --git a/include/networkit/structures/LocalCommunity.hpp b/include/networkit/structures/LocalCommunity.hpp index 90e142b59..c970b3681 100644 --- a/include/networkit/structures/LocalCommunity.hpp +++ b/include/networkit/structures/LocalCommunity.hpp @@ -54,9 +54,9 @@ class LocalCommunity { throw std::runtime_error("Decreasing value that is missing"); } - OptionalValue(const ValueType &){}; + OptionalValue(const ValueType &) {}; - OptionalValue(){}; + OptionalValue() {}; }; template @@ -89,9 +89,9 @@ class LocalCommunity { return *this; } - OptionalValue(const ValueType &v) : value(v){}; + OptionalValue(const ValueType &v) : value(v) {}; - OptionalValue() : value(){}; + OptionalValue() : value() {}; ValueType value; }; diff --git a/networkit/cpp/centrality/GroupClosenessGrowShrink.cpp b/networkit/cpp/centrality/GroupClosenessGrowShrink.cpp index 1d4607d3e..c6cdf0137 100644 --- a/networkit/cpp/centrality/GroupClosenessGrowShrink.cpp +++ b/networkit/cpp/centrality/GroupClosenessGrowShrink.cpp @@ -15,15 +15,18 @@ GroupClosenessGrowShrink::GroupClosenessGrowShrink(const Graph &G, const std::ve bool extended, count insertions, count maxIterations) : G(&G), - weightedImpl{G.isWeighted() ? std::make_unique< - GroupClosenessGrowShrinkDetails::GroupClosenessGrowShrinkImpl>( - G, group, extended, insertions, maxIterations) - : nullptr}, - unweightedImpl{G.isWeighted() - ? nullptr - : std::make_unique< - GroupClosenessGrowShrinkDetails::GroupClosenessGrowShrinkImpl>( - G, group, extended, insertions, maxIterations)} {} + weightedImpl{ + G.isWeighted() + ? std::make_unique< + GroupClosenessGrowShrinkDetails::GroupClosenessGrowShrinkImpl>( + G, group, extended, insertions, maxIterations) + : nullptr}, + unweightedImpl{ + G.isWeighted() + ? nullptr + : std::make_unique< + GroupClosenessGrowShrinkDetails::GroupClosenessGrowShrinkImpl>( + G, group, extended, insertions, maxIterations)} {} GroupClosenessGrowShrink::~GroupClosenessGrowShrink() = default; diff --git a/networkit/cpp/coarsening/CoarsenedGraphView.cpp b/networkit/cpp/coarsening/CoarsenedGraphView.cpp index 5e8dbe4af..b84ce8010 100644 --- a/networkit/cpp/coarsening/CoarsenedGraphView.cpp +++ b/networkit/cpp/coarsening/CoarsenedGraphView.cpp @@ -156,5 +156,4 @@ CoarsenedGraphView::computeNeighbors(node supernode) const { return neighbors; } - } /* namespace NetworKit */ diff --git a/networkit/cpp/community/ParallelLeiden.cpp b/networkit/cpp/community/ParallelLeiden.cpp index 88f534e8d..194c9d9a2 100644 --- a/networkit/cpp/community/ParallelLeiden.cpp +++ b/networkit/cpp/community/ParallelLeiden.cpp @@ -1,5 +1,5 @@ -#include #include +#include namespace NetworKit { ParallelLeiden::ParallelLeiden(const Graph &graph, int iterations, bool randomize, double gamma) @@ -588,4 +588,4 @@ Partition ParallelLeiden::parallelRefine(const Graph &graph) { DEBUG("Ending refinement with ", refined.numberOfSubsets(), " partitions"); return refined; } -} // namespace NetworKit \ No newline at end of file +} // namespace NetworKit diff --git a/networkit/cpp/community/ParallelLeidenCPMScoringExtension.cpp b/networkit/cpp/community/ParallelLeidenCPMScoringExtension.cpp index d434fb834..1099f9bf1 100644 --- a/networkit/cpp/community/ParallelLeidenCPMScoringExtension.cpp +++ b/networkit/cpp/community/ParallelLeidenCPMScoringExtension.cpp @@ -10,36 +10,28 @@ extern "C" double networkitParallelLeidenCommunityScore(double cutWeight, double double communityVolume, NetworKit::count subsetSize, NetworKit::count communitySize, - double gamma, - double inverseGraphVolume) { + double gamma, double inverseGraphVolume) { (void)degree; (void)communityVolume; (void)inverseGraphVolume; - return cutWeight - - gamma * static_cast(subsetSize) * static_cast(communitySize); + return cutWeight - gamma * static_cast(subsetSize) * static_cast(communitySize); } -extern "C" double networkitParallelLeidenCurrentCommunityThreshold(double cutWeight, double degree, - double communityVolume, - NetworKit::count subsetSize, - NetworKit::count communitySize, - double gamma, - double inverseGraphVolume) { +extern "C" double networkitParallelLeidenCurrentCommunityThreshold( + double cutWeight, double degree, double communityVolume, NetworKit::count subsetSize, + NetworKit::count communitySize, double gamma, double inverseGraphVolume) { (void)degree; (void)communityVolume; (void)inverseGraphVolume; - return cutWeight - gamma * static_cast(subsetSize) - * static_cast(communitySize - subsetSize); + return cutWeight + - gamma * static_cast(subsetSize) + * static_cast(communitySize - subsetSize); } -extern "C" bool networkitParallelLeidenRefineRSetCondition(double cutWeight, double subsetVolume, - NetworKit::count subsetSize, - double targetVolume, - NetworKit::count targetSize, - double sourceVolume, - NetworKit::count sourceSize, - double gamma, - double inverseGraphVolume) { +extern "C" bool networkitParallelLeidenRefineRSetCondition( + double cutWeight, double subsetVolume, NetworKit::count subsetSize, double targetVolume, + NetworKit::count targetSize, double sourceVolume, NetworKit::count sourceSize, double gamma, + double inverseGraphVolume) { (void)subsetVolume; (void)targetVolume; (void)sourceVolume; @@ -48,14 +40,10 @@ extern "C" bool networkitParallelLeidenRefineRSetCondition(double cutWeight, dou return cutWeight >= gamma * static_cast(subsetSize) * static_cast(targetSize); } -extern "C" bool networkitParallelLeidenRefineTSetCondition(double cutWeight, double subsetVolume, - NetworKit::count subsetSize, - double targetVolume, - NetworKit::count targetSize, - double sourceVolume, - NetworKit::count sourceSize, - double gamma, - double inverseGraphVolume) { +extern "C" bool networkitParallelLeidenRefineTSetCondition( + double cutWeight, double subsetVolume, NetworKit::count subsetSize, double targetVolume, + NetworKit::count targetSize, double sourceVolume, NetworKit::count sourceSize, double gamma, + double inverseGraphVolume) { (void)subsetVolume; (void)targetVolume; (void)sourceVolume; diff --git a/networkit/cpp/community/ParallelLeidenModularityScoringExtension.cpp b/networkit/cpp/community/ParallelLeidenModularityScoringExtension.cpp index adf78fbb5..54f3f2f28 100644 --- a/networkit/cpp/community/ParallelLeidenModularityScoringExtension.cpp +++ b/networkit/cpp/community/ParallelLeidenModularityScoringExtension.cpp @@ -10,32 +10,24 @@ extern "C" double networkitParallelLeidenCommunityScore(double cutWeight, double double communityVolume, NetworKit::count subsetSize, NetworKit::count communitySize, - double gamma, - double inverseGraphVolume) { + double gamma, double inverseGraphVolume) { (void)subsetSize; (void)communitySize; return cutWeight - gamma * degree * communityVolume * inverseGraphVolume; } -extern "C" double networkitParallelLeidenCurrentCommunityThreshold(double cutWeight, double degree, - double communityVolume, - NetworKit::count subsetSize, - NetworKit::count communitySize, - double gamma, - double inverseGraphVolume) { +extern "C" double networkitParallelLeidenCurrentCommunityThreshold( + double cutWeight, double degree, double communityVolume, NetworKit::count subsetSize, + NetworKit::count communitySize, double gamma, double inverseGraphVolume) { (void)subsetSize; (void)communitySize; return cutWeight - gamma * (communityVolume - degree) * degree * inverseGraphVolume; } -extern "C" bool networkitParallelLeidenRefineRSetCondition(double cutWeight, double subsetVolume, - NetworKit::count subsetSize, - double targetVolume, - NetworKit::count targetSize, - double sourceVolume, - NetworKit::count sourceSize, - double gamma, - double inverseGraphVolume) { +extern "C" bool networkitParallelLeidenRefineRSetCondition( + double cutWeight, double subsetVolume, NetworKit::count subsetSize, double targetVolume, + NetworKit::count targetSize, double sourceVolume, NetworKit::count sourceSize, double gamma, + double inverseGraphVolume) { (void)subsetSize; (void)targetSize; (void)sourceVolume; @@ -43,14 +35,10 @@ extern "C" bool networkitParallelLeidenRefineRSetCondition(double cutWeight, dou return cutWeight >= gamma * subsetVolume * targetVolume * inverseGraphVolume; } -extern "C" bool networkitParallelLeidenRefineTSetCondition(double cutWeight, double subsetVolume, - NetworKit::count subsetSize, - double targetVolume, - NetworKit::count targetSize, - double sourceVolume, - NetworKit::count sourceSize, - double gamma, - double inverseGraphVolume) { +extern "C" bool networkitParallelLeidenRefineTSetCondition( + double cutWeight, double subsetVolume, NetworKit::count subsetSize, double targetVolume, + NetworKit::count targetSize, double sourceVolume, NetworKit::count sourceSize, double gamma, + double inverseGraphVolume) { (void)subsetSize; (void)targetSize; (void)sourceVolume; diff --git a/networkit/cpp/community/ParallelLeidenView.cpp b/networkit/cpp/community/ParallelLeidenView.cpp index 715724397..35cd1ac9f 100644 --- a/networkit/cpp/community/ParallelLeidenView.cpp +++ b/networkit/cpp/community/ParallelLeidenView.cpp @@ -4,9 +4,9 @@ * Memory-efficient implementation of ParallelLeiden using CoarsenedGraphView */ -#include #include #include +#include #ifndef _WIN32 #include #endif @@ -101,8 +101,8 @@ void ParallelLeidenView::loadMoveScoringExtension(const std::string &sharedLibra #else void *handle = dlopen(sharedLibraryPath.c_str(), RTLD_NOW | RTLD_LOCAL); if (handle == nullptr) { - throw std::runtime_error("Failed to load ParallelLeidenView scoring extension '" + - sharedLibraryPath + "': " + dlerror()); + throw std::runtime_error("Failed to load ParallelLeidenView scoring extension '" + + sharedLibraryPath + "': " + dlerror()); } dlerror(); @@ -127,23 +127,23 @@ void ParallelLeidenView::loadMoveScoringExtension(const std::string &sharedLibra unloadMoveScoringExtension(); scoringExtensionHandle_ = handle; communityScoreFunction_ = communityScore; - currentCommunityThresholdFunction_ = thresholdScore != nullptr ? thresholdScore - : &modularityThresholdScore; + currentCommunityThresholdFunction_ = + thresholdScore != nullptr ? thresholdScore : &modularityThresholdScore; dlerror(); auto *refineRSet = reinterpret_cast( dlsym(handle, "networkitParallelLeidenRefineRSetCondition")); const char *refineRSetError = dlerror(); - refineRSetConditionFunction_ = - refineRSetError == nullptr && refineRSet != nullptr ? refineRSet - : &modularityRefineRSetCondition; + refineRSetConditionFunction_ = refineRSetError == nullptr && refineRSet != nullptr + ? refineRSet + : &modularityRefineRSetCondition; dlerror(); auto *refineTSet = reinterpret_cast( dlsym(handle, "networkitParallelLeidenRefineTSetCondition")); const char *refineTSetError = dlerror(); - refineTSetConditionFunction_ = - refineTSetError == nullptr && refineTSet != nullptr ? refineTSet - : &modularityRefineTSetCondition; + refineTSetConditionFunction_ = refineTSetError == nullptr && refineTSet != nullptr + ? refineTSet + : &modularityRefineTSetCondition; scoringExtensionPath_ = sharedLibraryPath; #endif } @@ -218,15 +218,14 @@ void ParallelLeidenView::run() { const double minGainMargin = moveStats.moved ? moveStats.gainMarginMin : 0.0; const double maxGainMargin = moveStats.moved ? moveStats.gainMarginMax : 0.0; const count candidateMoves = moveStats.moved + moveStats.marginalMovesRejected; - const double rejectedPct = candidateMoves - ? (100.0 * moveStats.marginalMovesRejected - / static_cast(candidateMoves)) - : 0.0; + const double rejectedPct = candidateMoves ? (100.0 * moveStats.marginalMovesRejected + / static_cast(candidateMoves)) + : 0.0; INFO("Inner iter ", innerIterations, ": moved ", moveStats.moved, " nodes, ", result.numberOfSubsets(), " communities", " | singleton moves=", moveStats.movedToSingleton, - " | marginal rejected=", moveStats.marginalMovesRejected, - " (", std::setprecision(4), rejectedPct, "%)", + " | marginal rejected=", moveStats.marginalMovesRejected, " (", + std::setprecision(4), rejectedPct, "%)", " | avg gain margin=", std::setprecision(6), avgGainMargin, " | min/max gain margin=", minGainMargin, "/", maxGainMargin); @@ -247,11 +246,12 @@ void ParallelLeidenView::run() { refined = parallelRefine(*currentGraph, refineMadeChanges); } - const bool zeroMoveAndRefinementMadeNoChanges = moveStats.moved == 0 && !refineMadeChanges; + const bool zeroMoveAndRefinementMadeNoChanges = + moveStats.moved == 0 && !refineMadeChanges; if (zeroMoveAndRefinementMadeNoChanges) { INFO("Stopping inner loop at inner iteration ", innerIterations, - ": local moving made zero moves and refinement made no changes."); + ": local moving made zero moves and refinement made no changes."); break; } @@ -268,9 +268,8 @@ void ParallelLeidenView::run() { Partition p(newCoarsenedView->numberOfNodes()); p.setUpperBound(result.upperBound()); - currentCoarsenedView->parallelForNodes([&compactRefined, &p, this](node u) { - p[compactRefined[u]] = result[u]; - }); + currentCoarsenedView->parallelForNodes( + [&compactRefined, &p, this](node u) { p[compactRefined[u]] = result[u]; }); result = std::move(p); currentCoarsenedView = newCoarsenedView; @@ -449,10 +448,7 @@ ParallelLeidenView::MoveStats ParallelLeidenView::parallelMove(const GraphType & } if (requeuesPerNode[candidate].compare_exchange_weak( - used, - used + 1, - std::memory_order_relaxed, - std::memory_order_relaxed)) { + used, used + 1, std::memory_order_relaxed, std::memory_order_relaxed)) { return true; } @@ -486,7 +482,8 @@ ParallelLeidenView::MoveStats ParallelLeidenView::parallelMove(const GraphType & pushNewNode(queuedNode); } else { std::uint8_t rollbackExpected = Queued; - const bool resetToIdle = nodeState[queuedNode].compare_exchange_strong(rollbackExpected, Idle); + const bool resetToIdle = nodeState[queuedNode].compare_exchange_strong( + rollbackExpected, Idle); assert(resetToIdle); tlx::unused(resetToIdle); } @@ -514,14 +511,16 @@ ParallelLeidenView::MoveStats ParallelLeidenView::parallelMove(const GraphType & if (!admitNodeRequeue(processedNode)) { expected = Reprocess; - const bool resetToIdle = nodeState[processedNode].compare_exchange_strong(expected, Idle); + const bool resetToIdle = + nodeState[processedNode].compare_exchange_strong(expected, Idle); assert(resetToIdle); tlx::unused(resetToIdle); return; } expected = Reprocess; - const bool markedQueued = nodeState[processedNode].compare_exchange_strong(expected, Queued); + const bool markedQueued = + nodeState[processedNode].compare_exchange_strong(expected, Queued); assert(markedQueued); tlx::unused(markedQueued); pushNewNode(processedNode); @@ -552,7 +551,8 @@ ParallelLeidenView::MoveStats ParallelLeidenView::parallelMove(const GraphType & } std::uint8_t expectedState = Queued; - const bool startedProcessing = nodeState[u].compare_exchange_strong(expectedState, Processing); + const bool startedProcessing = + nodeState[u].compare_exchange_strong(expectedState, Processing); assert(startedProcessing); tlx::unused(startedProcessing); @@ -665,7 +665,7 @@ ParallelLeidenView::MoveStats ParallelLeidenView::parallelMove(const GraphType & #pragma omp atomic communitySizes[currentCommunity] -= nodeMass; changed = true; - + graph.forNeighborsOf(u, [&](node neighbor, edgeweight) { if (neighbor != u) { scheduleNode(neighbor); @@ -718,16 +718,14 @@ ParallelLeidenView::MoveStats ParallelLeidenView::parallelMove(const GraphType & assert(waitingForNodes == tcount); const count totalMoved = std::accumulate(moved.begin(), moved.end(), (count)0); - - const count totalWorked = - std::accumulate(totalNodesPerThread.begin(), totalNodesPerThread.end(), - static_cast(0)); - + + const count totalWorked = std::accumulate(totalNodesPerThread.begin(), + totalNodesPerThread.end(), static_cast(0)); + const count totalRequeuesBlockedByNodeLimit = - std::accumulate(requeuesBlockedByNodeLimit.begin(), - requeuesBlockedByNodeLimit.end(), static_cast(0)); + std::accumulate(requeuesBlockedByNodeLimit.begin(), requeuesBlockedByNodeLimit.end(), + static_cast(0)); - if (Aux::Log::isLogLevelEnabled(Aux::Log::LogLevel::DEBUG)) { tlx::unused(totalWorked); DEBUG("Total worked: ", totalWorked, " Total moved: ", totalMoved, @@ -738,9 +736,8 @@ ParallelLeidenView::MoveStats ParallelLeidenView::parallelMove(const GraphType & stats.moved = totalMoved; stats.movedToSingleton = std::accumulate(movedToSingleton.begin(), movedToSingleton.end(), static_cast(0)); - stats.marginalMovesRejected = std::accumulate(marginalMovesRejected.begin(), - marginalMovesRejected.end(), - static_cast(0)); + stats.marginalMovesRejected = std::accumulate( + marginalMovesRejected.begin(), marginalMovesRejected.end(), static_cast(0)); stats.gainMarginSum = std::accumulate(gainMarginSum.begin(), gainMarginSum.end(), 0.0); if (totalMoved > 0) { for (int i = 0; i < omp_get_max_threads(); ++i) { @@ -888,10 +885,9 @@ Partition ParallelLeidenView::parallelRefine(const GraphType &graph, bool &refin auto volC = refinedVolumes[C]; auto sizeC = refinedSizes[C]; if (delta > bestDelta - && refineTSetCondition(cutCtoSminusC[C], volC, sizeC, - communityVolumes[S] - volC, - communitySizes[S] - sizeC, communityVolumes[S], - communitySizes[S])) { + && refineTSetCondition( + cutCtoSminusC[C], volC, sizeC, communityVolumes[S] - volC, + communitySizes[S] - sizeC, communityVolumes[S], communitySizes[S])) { bestDelta = delta; bestC = C; idx = j; @@ -912,10 +908,9 @@ Partition ParallelLeidenView::parallelRefine(const GraphType &graph, bool &refin // cutWeights[Neighbor] is the weight of the edge between Node and // Neighbor, since Neighbor was a singleton const auto neighborCutWeightIt = cutWeights.find(neighbor); - const double neighborCutWeight = - neighborCutWeightIt == cutWeights.end() - ? 0.0 - : neighborCutWeightIt->second; + const double neighborCutWeight = neighborCutWeightIt == cutWeights.end() + ? 0.0 + : neighborCutWeightIt->second; cutWeights[neighborCommunity] += neighborCutWeight; // Clear cutWeights entry beforehand, so we can "erase" bestC // from the pointers vector by replacing it with "none" @@ -1000,6 +995,7 @@ template Partition ParallelLeidenView::parallelRefine(const Graph &graph) template Partition ParallelLeidenView::parallelRefine(const CoarsenedGraphView &graph); template Partition -ParallelLeidenView::parallelRefine(const CoarsenedGraphView &graph, bool &refineMadeChanges); +ParallelLeidenView::parallelRefine(const CoarsenedGraphView &graph, + bool &refineMadeChanges); -} // namespace NetworKit \ No newline at end of file +} // namespace NetworKit diff --git a/networkit/cpp/distance/NeighborhoodFunctionHeuristic.cpp b/networkit/cpp/distance/NeighborhoodFunctionHeuristic.cpp index fa61290be..a64920437 100644 --- a/networkit/cpp/distance/NeighborhoodFunctionHeuristic.cpp +++ b/networkit/cpp/distance/NeighborhoodFunctionHeuristic.cpp @@ -21,8 +21,8 @@ namespace NetworKit { NeighborhoodFunctionHeuristic::NeighborhoodFunctionHeuristic(const Graph &G, count nSamples, SelectionStrategy strategy) : Algorithm(), G(&G), - nSamples(!nSamples ? (count)std::ceil( - std::max((double)0.15f * G.numberOfNodes(), std::sqrt(G.numberOfEdges()))) + nSamples(!nSamples ? (count)std::ceil(std::max((double)0.15f * G.numberOfNodes(), + std::sqrt(G.numberOfEdges()))) : nSamples), strategy(strategy) { diff --git a/networkit/cpp/distance/test/DistanceGTest.cpp b/networkit/cpp/distance/test/DistanceGTest.cpp index f0719c616..e9720a33f 100644 --- a/networkit/cpp/distance/test/DistanceGTest.cpp +++ b/networkit/cpp/distance/test/DistanceGTest.cpp @@ -97,24 +97,24 @@ TEST_F(DistanceGTest, testAStarInvalidSourceNode) { GraphW G(5); std::vector distanceHeu = {1.0, 2.0, 3.0, 4.0, 5.0}; - EXPECT_THROW({ AStar astar(G, distanceHeu, /*invalid_source*/ 6, /*target*/ 0); }, - std::runtime_error); + EXPECT_THROW( + { AStar astar(G, distanceHeu, /*invalid_source*/ 6, /*target*/ 0); }, std::runtime_error); } TEST_F(DistanceGTest, testAStarInvalidTargetNode) { GraphW G(5); std::vector distanceHeu = {1.0, 2.0, 3.0, 4.0, 5.0}; - EXPECT_THROW({ AStar astar(G, distanceHeu, /*source*/ 0, /*invalid_target*/ 6); }, - std::runtime_error); + EXPECT_THROW( + { AStar astar(G, distanceHeu, /*source*/ 0, /*invalid_target*/ 6); }, std::runtime_error); } TEST_F(DistanceGTest, testAStarConstructorThrowsMismatchHeuristicAndNodeCount) { GraphW G(5); std::vector distanceHeu = {1.0, 2.0}; // size mismatch (2 instead of 5) - EXPECT_THROW({ AStar astar_bad(G, distanceHeu, /*source*/ 0, /*target*/ 1); }, - std::runtime_error); + EXPECT_THROW( + { AStar astar_bad(G, distanceHeu, /*source*/ 0, /*target*/ 1); }, std::runtime_error); } TEST_F(DistanceGTest, testAStar) { @@ -189,10 +189,12 @@ TEST_F(DistanceGTest, testAStar) { TEST_F(DistanceGTest, testAlgebraicDistanceContructorThrowsForInvalidOmegaValues) { GraphW G(5, true, true); - EXPECT_THROW({ AlgebraicDistance AGD(G, 10UL, 30UL, /* invalid_omega*/ 1.1, 0UL, true); }, - std::invalid_argument); - EXPECT_THROW({ AlgebraicDistance AGD(G, 10UL, 30UL, /* invalid_omega*/ -0.3, 0UL, true); }, - std::invalid_argument); + EXPECT_THROW( + { AlgebraicDistance AGD(G, 10UL, 30UL, /* invalid_omega*/ 1.1, 0UL, true); }, + std::invalid_argument); + EXPECT_THROW( + { AlgebraicDistance AGD(G, 10UL, 30UL, /* invalid_omega*/ -0.3, 0UL, true); }, + std::invalid_argument); } TEST_F(DistanceGTest, testAlgebraicDistanceContructorThrowsForEdgecoresWithoutEdgeIds) { @@ -751,8 +753,9 @@ TEST_P(DistanceGTest, testSPSPWithUnreachableTarget) { TEST_F(DistanceGTest, testMultiTargetBFSThrowsInvalidSourceWithTargetRange) { GraphW G(5); std::vector targets = {0, 1, 2, 3}; - EXPECT_THROW({ MultiTargetBFS astar(G, /*invalid_source*/ 6, targets.begin(), targets.end()); }, - std::runtime_error); + EXPECT_THROW( + { MultiTargetBFS astar(G, /*invalid_source*/ 6, targets.begin(), targets.end()); }, + std::runtime_error); } TEST_F(DistanceGTest, testMultiTargetBFSThrowsWithOneInvalidTargetInTargetRange) { diff --git a/networkit/cpp/edgescores/PrefixJaccardScore.cpp b/networkit/cpp/edgescores/PrefixJaccardScore.cpp index e01e14499..3437e44bc 100644 --- a/networkit/cpp/edgescores/PrefixJaccardScore.cpp +++ b/networkit/cpp/edgescores/PrefixJaccardScore.cpp @@ -30,7 +30,7 @@ void PrefixJaccardScore::run() { AttributeT att; count rank; - RankedEdge(node u, AttributeT att, count rank) : u(u), att(att), rank(rank){}; + RankedEdge(node u, AttributeT att, count rank) : u(u), att(att), rank(rank) {}; bool operator<(const RankedEdge &other) const { return std::tie(rank, att, u) < std::tie(other.rank, other.att, other.u); diff --git a/networkit/cpp/generators/test/GeneratorsGTest.cpp b/networkit/cpp/generators/test/GeneratorsGTest.cpp index 800686f81..71b31bf19 100644 --- a/networkit/cpp/generators/test/GeneratorsGTest.cpp +++ b/networkit/cpp/generators/test/GeneratorsGTest.cpp @@ -1114,9 +1114,8 @@ TEST_F(GeneratorsGTest, testStaticDegreeSequenceGenerator) { for (int iter = 0; iter < 100; ++iter) { const auto n = distr_num_nodes(prng); std::vector seq(n); - std::generate(seq.begin(), seq.end(), [&] { - return std::uniform_int_distribution{0, n - 1}(prng); - }); + std::generate(seq.begin(), seq.end(), + [&] { return std::uniform_int_distribution{0, n - 1}(prng); }); HavelHakimiGenerator gen(seq, true); const auto isRealizable = gen.isRealizable(); diff --git a/networkit/cpp/matching/test/MatcherGTest.cpp b/networkit/cpp/matching/test/MatcherGTest.cpp index 10d3e529a..f20efbd12 100644 --- a/networkit/cpp/matching/test/MatcherGTest.cpp +++ b/networkit/cpp/matching/test/MatcherGTest.cpp @@ -331,9 +331,8 @@ TEST_F(MatcherGTest, testDynBSuitorRemoveEdges) { dbsm.run(); std::vector events; - G.forEdges([&](node u, node v) { - events.emplace_back(GraphEvent{GraphEvent::EDGE_REMOVAL, u, v}); - }); + G.forEdges( + [&](node u, node v) { events.emplace_back(GraphEvent{GraphEvent::EDGE_REMOVAL, u, v}); }); for (auto &e : events) { G.removeEdge(e.u, e.v); diff --git a/networkit/cpp/scd/LocalDegreeDirectedGraph.hpp b/networkit/cpp/scd/LocalDegreeDirectedGraph.hpp index c499cb834..bf6e34cfc 100644 --- a/networkit/cpp/scd/LocalDegreeDirectedGraph.hpp +++ b/networkit/cpp/scd/LocalDegreeDirectedGraph.hpp @@ -211,8 +211,7 @@ class LocalDegreeDirectedGraph { */ template void forTrianglesOf(node u, F callback) { - forTrianglesOf( - u, [](node, edgeweight) {}, callback); + forTrianglesOf(u, [](node, edgeweight) {}, callback); } /** diff --git a/networkit/cpp/scd/LocalTightnessExpansion.cpp b/networkit/cpp/scd/LocalTightnessExpansion.cpp index 7fecbda4e..77717f7ee 100644 --- a/networkit/cpp/scd/LocalTightnessExpansion.cpp +++ b/networkit/cpp/scd/LocalTightnessExpansion.cpp @@ -66,7 +66,7 @@ class LocalGraph public: LocalGraph(const Graph &g, NodeAddedCallbackType nodeAddedCallback) : LocalDegreeDirectedGraph>( - g, InnerNodeAddedCallback{nodeAddedCallback, triangleSum}) { + g, InnerNodeAddedCallback{nodeAddedCallback, triangleSum}) { if (g.isWeighted() != is_weighted) { throw std::runtime_error("Error, weighted/unweighted status of input graph does not " "match is_weighted template parameter"); diff --git a/networkit/cpp/viz/MaxentStress.cpp b/networkit/cpp/viz/MaxentStress.cpp index 2ca6ea725..eaf775b15 100644 --- a/networkit/cpp/viz/MaxentStress.cpp +++ b/networkit/cpp/viz/MaxentStress.cpp @@ -505,9 +505,8 @@ void MaxentStress::computeKnownDistances(const count k, const GraphDistance grap case EDGE_WEIGHT: // add edges to known distances G->parallelForNodes([&](node u) { - G->forNeighborsOf(u, [&](node v, edgeweight w) { - knownDistances[u].push_back({v, w}); - }); + G->forNeighborsOf(u, + [&](node v, edgeweight w) { knownDistances[u].push_back({v, w}); }); // add k-neighborhood if (k > 1) { // 1-neighborhood are adjacent vertices that are already added above addKNeighborhoodOfVertex(u, k); diff --git a/networkit/cpp/viz/test/VizGTest.cpp b/networkit/cpp/viz/test/VizGTest.cpp index 8371ceacb..11c03bf1d 100644 --- a/networkit/cpp/viz/test/VizGTest.cpp +++ b/networkit/cpp/viz/test/VizGTest.cpp @@ -33,9 +33,8 @@ TEST_F(VizGTest, testPostscriptWriterOnRandomGraph) { std::vector coordinates(G.upperNodeIdBound()); // create coordinates - G.forNodes([&](node u) { - coordinates[u] = {Aux::Random::probability(), Aux::Random::probability()}; - }); + G.forNodes( + [&](node u) { coordinates[u] = {Aux::Random::probability(), Aux::Random::probability()}; }); // write graph to file std::string path = "output/testGraph.eps";