#include <math.h>
#include <time.h>
#include <sparse/SparseMatrix.h>
-#include <sparse/vector.h>
#include <mingle/edge_bundling.h>
#include <mingle/ink.h>
#include <mingle/agglomerative_bundling.h>
#include <mingle/nearest_neighbor_graph.h>
#include <string.h>
+#include <vector>
#if OPENGL
#include <gl.h>
double *inks = grid->inks, *cinks, inki, inkj;
double gain, maxgain, minink, total_gain = 0;
int *ip = NULL, *jp = NULL, ie;
- Vector *cedges;/* a table listing the content of bundled edges in the coarsen grid.
+ std::vector<std::vector<int>> cedges;/* a table listing the content of bundled edges in the coarsen grid.
cedges[i] contain the list of origonal edges that make up the bundle i in the next level */
double ink0, ink1, grand_total_ink = 0, grand_total_gain = 0;
point_t meet1, meet2;
if (Verbose > 1) fprintf(stderr,"level ===================== %d, n = %d\n",grid->level, n);
- cedges = (Vector*)MALLOC(sizeof(Vector)*n);
+ cedges.resize(n);
cinks = (double*)MALLOC(sizeof(double)*n);
- for (i = 0; i < n; i++) cedges[i] = Vector_new(1, sizeof(int), NULL);
if (grid->level > 0){
ip = grid->R0->ia;
} else {
ni = 1; pick[0] = i;
}
- nj = Vector_get_length(cedges[jc]);
+ nj = cedges[jc].size();
npicks = ni;
for (k = 0; k < nj; k++) {
- pick[npicks++] = *((int*) Vector_get(cedges[jc], k));
+ pick[npicks++] = cedges[jc][k];
}
}
if (ip){
for (k = ip[jmax]; k < ip[jmax+1]; k++) {
ie = jp[k];
- Vector_add(cedges[nc], &ie);
+ cedges[nc].push_back(ie);
}
} else {
- Vector_add(cedges[nc], &jmax);
+ cedges[nc].push_back(jmax);
}
jc = nc;
nc++;
if (ip){
for (k = ip[i]; k < ip[i+1]; k++) {
ie = jp[k];
- Vector_add(cedges[jc], &ie);
+ cedges[jc].push_back(ie);
}
} else {
- Vector_add(cedges[jc], &i);
+ cedges[jc].push_back(i);
}
cinks[jc] = minink;
grand_total_ink += minink;
if (Verbose && DEBUG){
fprintf(stderr," coarse edge[%d]={",jc);
- for (k = 0; k < Vector_get_length(cedges[jc]); k++) {
- fprintf(stderr,"%d,", *((int*) Vector_get(cedges[jc], k)));
+ for (const int &cedge : cedges[jc]) {
+ fprintf(stderr,"%d,", cedge);
}
fprintf(stderr,"}, grand_total_gain=%f\n",grand_total_gain);
}
RETURN:
free(matching);
- for (i = 0; i < n; i++) Vector_delete(cedges[i]);
- free(cedges);
free(mask);
return grid;
}