dists[i] = FLT_MAX;
}
dists[source] = 0;
- for (int i = graph->sources[source]; i < graph->sources[source + 1]; i++) {
- int target = graph->targets[i];
+ for (size_t i = graph->sources[source]; i < graph->sources[source + 1];
+ i++) {
+ size_t target = graph->targets[i];
dists[target] = graph->weights[i];
}
assert(graph->n <= INT_MAX);
terms[offset].w = 1 / (d*d);
offset++;
}
- for (int i = graph->sources[closest]; i < graph->sources[closest + 1];
+ for (size_t i = graph->sources[closest]; i < graph->sources[closest + 1];
i++) {
- int target = graph->targets[i];
+ size_t target = graph->targets[i];
float weight = graph->weights[i];
- increaseKey_f(&h, target, d+weight, indices, dists);
+ assert(target <= (size_t)INT_MAX);
+ increaseKey_f(&h, (int)target, d+weight, indices, dists);
}
}
freeHeap(&h);
}
}
graph_sgd *graph = N_NEW(1, graph_sgd);
- graph->sources = N_NEW(n_nodes+1, int);
+ graph->sources = N_NEW(n_nodes + 1, size_t);
bitarray_resize_or_exit(&graph->pinneds, n_nodes);
- graph->targets = N_NEW(n_edges, int);
+ graph->targets = N_NEW(n_edges, size_t);
graph->weights = N_NEW(n_edges, float);
graph->n = n_nodes;
assert(n_edges <= INT_MAX);
- graph->sources[graph->n] = (int)n_edges; // to make looping nice
+ graph->sources[graph->n] = n_edges; // to make looping nice
n_nodes = 0, n_edges = 0;
for (np = agfstnode(G); np; np = agnxtnode(G,np)) {
assert(n_edges <= INT_MAX);
- graph->sources[n_nodes] = (int)n_edges;
+ graph->sources[n_nodes] = n_edges;
bitarray_set(graph->pinneds, n_nodes, isFixed(np));
for (ep = agfstedge(G, np); ep; ep = agnxtedge(G, ep, np)) {
if (agtail(ep) == aghead(ep)) { // ignore self-loops and double edges
continue;
}
node_t *target = (agtail(ep) == np) ? aghead(ep) : agtail(ep); // in case edge is reversed
- graph->targets[n_edges] = ND_id(target);
+ graph->targets[n_edges] = (size_t)ND_id(target);
graph->weights[n_edges] = ED_dist(ep);
assert(graph->weights[n_edges] > 0);
n_edges++;
}
assert(n_nodes == graph->n);
assert(n_edges <= INT_MAX);
- assert((int)n_edges == graph->sources[graph->n]);
- graph->sources[n_nodes] = (int)n_edges;
+ assert(n_edges == graph->sources[graph->n]);
+ graph->sources[n_nodes] = n_edges;
if (model == MODEL_SHORTPATH) {
// do nothing
neighbours_j[i] = false;
}
for (size_t i = 0; i < graph->n; i++) {
- int x;
int deg_i = 0;
- for (x=graph->sources[i]; x<graph->sources[i+1]; x++) {
- int j = graph->targets[x];
+ for (size_t x = graph->sources[i]; x < graph->sources[i + 1]; x++) {
+ size_t j = graph->targets[x];
if (neighbours_i[j] == false) { // ignore multiedges
neighbours_i[j] = true; // set up sort of hashset
deg_i++;
}
}
- for (x=graph->sources[i]; x<graph->sources[i+1]; x++) {
- int j = graph->targets[x];
- int y, intersect = 0;
+ for (size_t x = graph->sources[i]; x < graph->sources[i + 1]; x++) {
+ size_t j = graph->targets[x];
+ int intersect = 0;
int deg_j = 0;
- for (y=graph->sources[j]; y<graph->sources[j+1]; y++) {
- int k = graph->targets[y];
+ for (size_t y = graph->sources[j]; y < graph->sources[j + 1];
+ y++) {
+ size_t k = graph->targets[y];
if (neighbours_j[k] == false) { // ignore multiedges
neighbours_j[k] = true; // set up sort of hashset
deg_j++;
}
graph->weights[x] = deg_i + deg_j - (2*intersect);
assert(graph->weights[x] > 0);
- for (y=graph->sources[j]; y<graph->sources[j+1]; y++) {
- int k = graph->targets[y];
+ for (size_t y = graph->sources[j]; y < graph->sources[j + 1];
+ y++) {
+ size_t k = graph->targets[y];
neighbours_j[k] = false; // reset sort of hashset
}
}
- for (x=graph->sources[i]; x<graph->sources[i+1]; x++) {
- int j = graph->targets[x];
+ for (size_t x = graph->sources[i]; x < graph->sources[i + 1]; x++) {
+ size_t j = graph->targets[x];
neighbours_i[j] = false; // reset sort of hashset
}
}