THGreedy.c 698 Bytes
Newer Older
rusty1s's avatar
rusty1s committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef TH_GENERIC_FILE
#define TH_GENERIC_FILE "generic/THGreedy.c"
#else

void THGreedy_(cluster)(THLongTensor *cluster, THLongTensor *row, THLongTensor *col,
                        THLongTensor *deg, THTensor *weight) {
  real *weightData = weight->storage->data + weight->storageOffset;
  real maxWeight = 0, tmpWeight;
  TH_GREEDY_CLUSTER(cluster, row, col, deg,
    for (neighborIdx = rowIdx; neighborIdx < rowIdx + degData[rowValue]; neighborIdx++) {
      tmp = colData[neighborIdx];
      tmpWeight = weightData[neighborIdx];
      if (clusterData[tmp] < 0 && tmpWeight > maxWeight) {
        colValue = tmp;
        maxWeight = tmpWeight;
      }
    }
  )
}

#endif  // TH_GENERIC_FILE