Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/wheel_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ jobs:
uses: pypa/cibuildwheel@v2.23.3
with:
output-dir: dist/
merge-multiple: true

- name: Upload wheels
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -74,4 +73,3 @@ jobs:
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true


6 changes: 3 additions & 3 deletions cpp_easygraph/functions/community/louvain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,10 @@ double modularity_optimization_parallel_simplified(const Graph_L& G, vector<int>
}

if (best_comm != old_comm) {
#pragma omp atomic update
#pragma omp atomic
comm_weights[old_comm] -= weight_all;

#pragma omp atomic update
#pragma omp atomic
comm_weights[best_comm] += weight_all;

membership[u - 1] = best_comm;
Expand Down Expand Up @@ -541,4 +541,4 @@ py::object cpp_louvain_communities(py::object G, py::object weight, py::object t
}

return final_result;
}
}
11 changes: 8 additions & 3 deletions cpp_easygraph/functions/community/modularity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cstddef>
#ifdef _OPENMP
#include <omp.h>
#else
Expand All @@ -18,8 +19,10 @@ void addVectorsInPlace(std::vector<double>& v1, std::vector<double>& v2) {
throw std::invalid_argument("Vectors must have the same size for element-wise addition.");
}

const std::ptrdiff_t n = static_cast<std::ptrdiff_t>(v1.size());

#pragma omp parallel for
for (size_t i = 0; i < v1.size(); ++i) {
for (std::ptrdiff_t i = 0; i < n; ++i) {
double sum = v1[i] + v2[i];
v1[i] = sum;
v2[i] = sum;
Expand All @@ -32,8 +35,10 @@ double dotProduct(const std::vector<double>& v1, const std::vector<double>& v2)
}

double result = 0.0;
const std::ptrdiff_t n = static_cast<std::ptrdiff_t>(v1.size());

#pragma omp parallel for reduction(+:result)
for (size_t i = 0; i < v1.size(); ++i) {
for (std::ptrdiff_t i = 0; i < n; ++i) {
result += v1[i] * v2[i];
}
return result;
Expand Down Expand Up @@ -205,4 +210,4 @@ py::object cpp_modularity(py::object G, py::object communities, py::object weigh
double Q = e - sum_products;

return py::float_(Q);
}
}
Loading