******************************************/
+#include <assert.h>
#include <common/memory.h>
#include <float.h>
#include <neatogen/bfs.h>
heap h;
int *indices = N_GNEW(graph->n, int);
float *dists = N_GNEW(graph->n, float);
- int i;
- for (i=0; i<graph->n; i++) {
+ for (size_t i= 0; i < graph->n; i++) {
dists[i] = FLT_MAX;
}
dists[source] = 0;
- for (i=graph->sources[source]; i<graph->sources[source+1]; i++) {
+ for (int i = graph->sources[source]; i < graph->sources[source + 1]; i++) {
int target = graph->targets[i];
dists[target] = graph->weights[i];
}
- initHeap_f(&h, source, indices, dists, graph->n);
+ assert(graph->n <= INT_MAX);
+ initHeap_f(&h, source, indices, dists, (int)graph->n);
int closest = 0, offset = 0;
while (extractMax_f(&h, &closest, indices, dists)) {
terms[offset].w = 1 / (d*d);
offset++;
}
- for (i=graph->sources[closest]; i<graph->sources[closest+1]; i++) {
+ for (int i = graph->sources[closest]; i < graph->sources[closest + 1];
+ i++) {
int target = graph->targets[i];
float weight = graph->weights[i];
increaseKey_f(&h, target, d+weight, indices, dists);
+#include <assert.h>
+#include <limits.h>
#include <neatogen/neato.h>
#include <neatogen/sgd.h>
#include <neatogen/dijkstra.h>
static graph_sgd * extract_adjacency(graph_t *G, int model) {
node_t *np;
edge_t *ep;
- int n_nodes = 0, n_edges = 0;
+ size_t n_nodes = 0, n_edges = 0;
for (np = agfstnode(G); np; np = agnxtnode(G,np)) {
assert(ND_id(np) == n_nodes);
n_nodes++;
graph->weights = N_NEW(n_edges, float);
graph->n = n_nodes;
- graph->sources[graph->n] = n_edges; // to make looping nice
+ assert(n_edges <= INT_MAX);
+ graph->sources[graph->n] = (int)n_edges; // to make looping nice
n_nodes = 0, n_edges = 0;
for (np = agfstnode(G); np; np = agnxtnode(G,np)) {
- graph->sources[n_nodes] = n_edges;
+ assert(n_edges <= INT_MAX);
+ graph->sources[n_nodes] = (int)n_edges;
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
n_nodes++;
}
assert(n_nodes == graph->n);
- assert(n_edges == graph->sources[graph->n]);
- graph->sources[n_nodes] = n_edges;
+ assert(n_edges <= INT_MAX);
+ assert((int)n_edges == graph->sources[graph->n]);
+ graph->sources[n_nodes] = (int)n_edges;
if (model == MODEL_SHORTPATH) {
// do nothing
} else if (model == MODEL_SUBSET) {
// i,j,k refer to actual node indices, while x,y refer to edge indices in graph->targets
- int i;
bool *neighbours_i = N_NEW(graph->n, bool);
bool *neighbours_j = N_NEW(graph->n, bool);
- for (i=0; i<graph->n; i++) {
+ for (size_t i = 0; i < graph->n; i++) {
// initialise to no neighbours
neighbours_i[i] = false;
neighbours_j[i] = false;
}
- for (i=0; i<graph->n; i++) {
+ 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++) {