5 #include "ExaTrkXUtils.hpp"
11 std::vector<float>& embedFeatures,
12 std::vector<int64_t>& edgeList,
13 int64_t numSpacepoints,
26 std::vector<float> dists;
27 dists.reserve(numSpacepoints);
28 std::vector<int>
idx(numSpacepoints);
29 std::vector<int64_t> senders;
30 std::vector<int64_t> receivers;
31 for (int64_t
i = 0;
i < numSpacepoints;
i++) {
33 for (int64_t j = 0; j < numSpacepoints; j++) {
39 for (
int k = 0;
k < embeddingDim;
k++) {
40 float dist_k = embedFeatures[
i * embeddingDim +
k] - embedFeatures[j * embeddingDim +
k];
41 dist += dist_k * dist_k;
43 dists.push_back(sqrt(dist));
45 std::iota(
idx.begin(),
idx.end(), 0);
46 std::sort(
idx.begin(),
idx.end(), [&dists](
int i1,
int i2) {return dists[i1] < dists[i2];});
48 for (
int j = 0; j < numSpacepoints; j++) {
50 if (dists[
idx[j]] >
rVal)
break;
53 receivers.push_back(
idx[j]);
54 if (numFilled >= kVal)
break;
57 edgeList.resize(2 * senders.size());
58 std::copy(senders.begin(), senders.end(), edgeList.begin());
59 std::copy(receivers.begin(), receivers.end(), edgeList.begin() + senders.size());