Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit 235a206

Browse files
committed
ci: auto code format
1 parent 67d7641 commit 235a206

2 files changed

Lines changed: 31 additions & 14 deletions

File tree

extension/algo/src/function/betweenness_centrality.cpp

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,26 @@ class WeightedFwdTraverse : public EdgeCompute {
153153
auto nbrPathData = fwdData.nodePathData[nbrNodeID.offset].load();
154154
const auto weight = propertyVectors[0]->template getValue<double>(i);
155155
if (weight <= 0) {
156-
throw RuntimeException(stringFormat("Betweenness Centrality does not work on non-positive weights. Got {}", weight));
156+
throw RuntimeException(stringFormat(
157+
"Betweenness Centrality does not work on non-positive weights. Got {}",
158+
weight));
157159
}
158160
// We find a better path.
159-
while(nbrPathData.pathScore > curScore+weight) {
160-
if (fwdData.nodePathData[nbrNodeID.offset].compare_exchange_strong(nbrPathData, BCFwdData::PathData{.numPaths = curPaths, .level = curLevel+1, .pathScore = curScore+weight})) {
161+
while (nbrPathData.pathScore > curScore + weight) {
162+
if (fwdData.nodePathData[nbrNodeID.offset].compare_exchange_strong(nbrPathData,
163+
BCFwdData::PathData{.numPaths = curPaths,
164+
.level = curLevel + 1,
165+
.pathScore = curScore + weight})) {
161166
result.push_back(nbrNodeID);
162167
return;
163168
}
164169
}
165170
// We find an equivalent path.
166171
while (nbrPathData.pathScore == curScore + weight) {
167-
if(fwdData.nodePathData[nbrNodeID.offset].compare_exchange_strong(nbrPathData, BCFwdData::PathData{.numPaths = curPaths+nbrPathData.numPaths, .level = std::max(curLevel+1, nbrPathData.level), .pathScore = curScore+weight})) {
172+
if (fwdData.nodePathData[nbrNodeID.offset].compare_exchange_strong(nbrPathData,
173+
BCFwdData::PathData{.numPaths = curPaths + nbrPathData.numPaths,
174+
.level = std::max(curLevel + 1, nbrPathData.level),
175+
.pathScore = curScore + weight})) {
168176
return;
169177
}
170178
}
@@ -194,13 +202,19 @@ class UnweightedFwdTraverse : public EdgeCompute {
194202
auto nbrNodeID = neighbors[i];
195203
auto nbrPathData = BCFwdData::PathData{};
196204
// We see the node for the first time.
197-
if (fwdData.nodePathData[nbrNodeID.offset].compare_exchange_strong(nbrPathData, BCFwdData::PathData{.numPaths = curPaths, .level = curLevel+1, .pathScore = curScore+1})) {
205+
if (fwdData.nodePathData[nbrNodeID.offset].compare_exchange_strong(nbrPathData,
206+
BCFwdData::PathData{.numPaths = curPaths,
207+
.level = curLevel + 1,
208+
.pathScore = curScore + 1})) {
198209
result.push_back(nbrNodeID);
199210
return;
200211
}
201212
// Reaching here means CAS failed, so nbrPathData is up to date.
202213
while (nbrPathData.pathScore == curScore + 1) {
203-
if(fwdData.nodePathData[nbrNodeID.offset].compare_exchange_strong(nbrPathData, BCFwdData::PathData{.numPaths = curPaths+nbrPathData.numPaths, .level = curLevel+1, .pathScore = curScore+1})) {
214+
if (fwdData.nodePathData[nbrNodeID.offset].compare_exchange_strong(nbrPathData,
215+
BCFwdData::PathData{.numPaths = curPaths + nbrPathData.numPaths,
216+
.level = curLevel + 1,
217+
.pathScore = curScore + 1})) {
204218
return;
205219
}
206220
}
@@ -229,7 +243,8 @@ class BwdTraverse : public EdgeCompute {
229243
chunk.forEach([&](auto neighbors, auto propertyVectors, auto i) {
230244
auto nbrNodeID = neighbors[i];
231245
auto nbrDistance = fwdData.nodePathData[nbrNodeID.offset].load().pathScore;
232-
const auto weight = propertyVectors.empty() ? 1 : propertyVectors[0]->template getValue<double>(i);
246+
const auto weight =
247+
propertyVectors.empty() ? 1 : propertyVectors[0]->template getValue<double>(i);
233248
if (nbrDistance + weight == curDistance) {
234249
auto nbrPaths = fwdData.nodePathData[nbrNodeID.offset].load().numPaths;
235250
auto scoreToAdd = ((double)nbrPaths / curPaths) * (1 + curScore);
@@ -258,7 +273,8 @@ class PopulateLevels : public GDSVertexCompute {
258273
void beginOnTableInternal(table_id_t) override {}
259274
void vertexCompute(offset_t startOffset, offset_t endOffset, table_id_t) override {
260275
for (auto i = startOffset; i < endOffset; ++i) {
261-
fwdData.levels[i] = BCFwdData::LevelData{.node = i, .level = fwdData.nodePathData[i].load().level};
276+
fwdData.levels[i] =
277+
BCFwdData::LevelData{.node = i, .level = fwdData.nodePathData[i].load().level};
262278
}
263279
}
264280
std::unique_ptr<VertexCompute> copy() override {
@@ -391,8 +407,7 @@ static common::offset_t tableFunc(const TableFuncInput& input, TableFuncOutput&)
391407
computeState.frontierPair->addNodeToNextFrontier(i);
392408
if (relProps.empty()) {
393409
computeState.edgeCompute = std::make_unique<UnweightedFwdTraverse>(fwdData);
394-
}
395-
else {
410+
} else {
396411
computeState.edgeCompute = std::make_unique<WeightedFwdTraverse>(fwdData);
397412
}
398413
computeState.frontierPair->setActiveNodesForNextIter();
@@ -401,10 +416,11 @@ static common::offset_t tableFunc(const TableFuncInput& input, TableFuncOutput&)
401416
// Backward Traverse
402417
bwdData.init();
403418

404-
405-
const auto populateLevels = std::make_unique<PopulateLevels>(sharedState->getGraphNodeMaskMap(), fwdData);
419+
const auto populateLevels =
420+
std::make_unique<PopulateLevels>(sharedState->getGraphNodeMaskMap(), fwdData);
406421
GDSUtils::runVertexCompute(input.context, GDSDensityState::DENSE, graph, *populateLevels);
407-
std::sort(fwdData.levels.begin(), fwdData.levels.end(), std::greater<BCFwdData::LevelData>{});
422+
std::sort(fwdData.levels.begin(), fwdData.levels.end(),
423+
std::greater<BCFwdData::LevelData>{});
408424

409425
auto maxLevel = fwdData.levels.front().level;
410426
for (auto j = 0u; j < fwdData.levels.size() && maxLevel > 0;) {

src/function/gds/gds_utils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ static void runOneIteration(ExecutionContext* context, Graph* graph,
8686
}
8787

8888
void GDSUtils::runAlgorithmEdgeCompute(ExecutionContext* context, GDSComputeState& compState,
89-
Graph* graph, ExtendDirection extendDirection, uint64_t maxIteration, const std::vector<std::string>& propertiesToScan) {
89+
Graph* graph, ExtendDirection extendDirection, uint64_t maxIteration,
90+
const std::vector<std::string>& propertiesToScan) {
9091
auto frontierPair = compState.frontierPair.get();
9192
while (frontierPair->continueNextIter(maxIteration)) {
9293
frontierPair->beginNewIteration();

0 commit comments

Comments
 (0)