From: Matthew Fernandez Date: Mon, 2 Jan 2023 17:40:33 +0000 (-0800) Subject: lib/mingle: fix: rename 'DEBUG' to 'MINGLE_DEBUG' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8e1e692801afadf3958fbefdcb5836acd71cbde6;p=graphviz lib/mingle: fix: rename 'DEBUG' to 'MINGLE_DEBUG' When compiling Graphviz in debug mode (`-DDEBUG`) with libANN, this code causes syntactic errors due to it using `DEBUG` itself. --- diff --git a/lib/mingle/agglomerative_bundling.cpp b/lib/mingle/agglomerative_bundling.cpp index 692a4e153..4448250a2 100644 --- a/lib/mingle/agglomerative_bundling.cpp +++ b/lib/mingle/agglomerative_bundling.cpp @@ -21,7 +21,7 @@ #include #include -enum {DEBUG=0}; +enum {MINGLE_DEBUG=0}; static Agglomerative_Ink_Bundling Agglomerative_Ink_Bundling_init(SparseMatrix A, pedge *edges, int level){ Agglomerative_Ink_Bundling grid; @@ -123,11 +123,11 @@ static Agglomerative_Ink_Bundling Agglomerative_Ink_Bundling_establish(Agglomera pick[0] = i; pick[1] = jj; ni = nj = 1; } - if (DEBUG) if (Verbose) fprintf(stderr, "ink(%d)=%f, ink(%d)=%f", i, inki, jj, inkj); + if (MINGLE_DEBUG) if (Verbose) fprintf(stderr, "ink(%d)=%f, ink(%d)=%f", i, inki, jj, inkj); } else { /* j is already matched. Its content is on cedges[jc] */ inki = inks[i]; inkj = cinks[jc]; - if (DEBUG) if (Verbose) fprintf(stderr, "ink(%d)=%f, ink(%d->%d)=%f", i, inki, jj, jc, inkj); + if (MINGLE_DEBUG) if (Verbose) fprintf(stderr, "ink(%d)=%f, ink(%d->%d)=%f", i, inki, jj, jc, inkj); if (ip) { ni = (ip[i+1] - ip[i]);/* number of edges represented by i */ memcpy(pick, &(jp[ip[i]]), sizeof(int)*ni); @@ -143,7 +143,7 @@ static Agglomerative_Ink_Bundling Agglomerative_Ink_Bundling_establish(Agglomera npicks = ni + nj; ink1 = ink(edges, npicks, pick, &ink0, &meet1, &meet2, angle_param, angle); - if (DEBUG) { + if (MINGLE_DEBUG) { if (Verbose) { fprintf(stderr,", if merging {"); for (k = 0; k < npicks; k++) fprintf(stderr,"%d,", pick[k]); @@ -153,14 +153,14 @@ static Agglomerative_Ink_Bundling Agglomerative_Ink_Bundling_establish(Agglomera } gain = inki + inkj - ink1; - if (DEBUG) if (Verbose) fprintf(stderr, " gain=%f", gain); + if (MINGLE_DEBUG) if (Verbose) fprintf(stderr, " gain=%f", gain); if (gain > maxgain){ maxgain = gain; minink = ink1; jmax = jj; - if (DEBUG) if (Verbose) fprintf(stderr, "maxgain=%f", maxgain); + if (MINGLE_DEBUG) if (Verbose) fprintf(stderr, "maxgain=%f", maxgain); } - if (DEBUG) if (Verbose) fprintf(stderr, "\n"); + if (MINGLE_DEBUG) if (Verbose) fprintf(stderr, "\n"); @@ -173,7 +173,7 @@ static Agglomerative_Ink_Bundling Agglomerative_Ink_Bundling_establish(Agglomera total_gain += maxgain; jc = matching[jmax]; if (jc == UNMATCHED){/* i and j both unmatched. Add j in the table first */ - if (DEBUG) if (Verbose) printf("maxgain=%f, merge %d with best edge: %d to form coarsen edge %d. Ink=%f\n",maxgain, i, jmax, nc, minink); + if (MINGLE_DEBUG) if (Verbose) printf("maxgain=%f, merge %d with best edge: %d to form coarsen edge %d. Ink=%f\n",maxgain, i, jmax, nc, minink); matching[i] = matching[jmax] = nc; if (ip){ for (k = ip[jmax]; k < ip[jmax+1]; k++) { @@ -186,12 +186,12 @@ static Agglomerative_Ink_Bundling Agglomerative_Ink_Bundling_establish(Agglomera jc = nc; nc++; } else {/*j is already matched */ - if (DEBUG) if (Verbose) printf("maxgain=%f, merge %d with existing cluster %d\n",maxgain, i, jc); + if (MINGLE_DEBUG) if (Verbose) printf("maxgain=%f, merge %d with existing cluster %d\n",maxgain, i, jc); matching[i] = jc; grand_total_ink -= cinks[jc];/* ink of cluster jc was already added, and will be added again as part of a larger cluster with i, so dicount */ } } else {/*i can not match/bundle successfully */ - if (DEBUG) if (Verbose) fprintf(stderr, "no gain in bundling node %d\n",i); + if (MINGLE_DEBUG) if (Verbose) fprintf(stderr, "no gain in bundling node %d\n",i); assert(maxgain <= 0); matching[i] = nc; jc = nc; @@ -213,7 +213,7 @@ static Agglomerative_Ink_Bundling Agglomerative_Ink_Bundling_establish(Agglomera grand_total_ink += minink; grand_total_gain += maxgain; - if (DEBUG){ + if (MINGLE_DEBUG){ if (Verbose) { fprintf(stderr," coarse edge[%d]={",jc); for (const int &cedge : cedges[jc]) { @@ -351,9 +351,9 @@ static pedge* agglomerative_ink_bundling_internal(int dim, SparseMatrix A, pedge for (i = 0; i < R->m; i++){ pick = &(ja[ia[i]]); - if (DEBUG) if (Verbose) fprintf(stderr,"calling ink2...\n"); + if (MINGLE_DEBUG) if (Verbose) fprintf(stderr,"calling ink2...\n"); ink1 = ink(edges, ia[i+1]-ia[i], pick, &ink0, &meet1, &meet2, angle_param, angle); - if (DEBUG) if (Verbose) fprintf(stderr,"finish calling ink2...\n"); + if (MINGLE_DEBUG) if (Verbose) fprintf(stderr,"finish calling ink2...\n"); assert(fabs(ink1 - cgrid->inks[i])<=MAX(TOL, TOL*ink1) && ink1 - ink0 <= TOL); assert(ink1 < 1000 * ink0); /* assert that points were found */ wgt_all = 0.; @@ -409,9 +409,9 @@ static pedge* agglomerative_ink_bundling_internal(int dim, SparseMatrix A, pedge pick = &(ja[ia[i]]); wgt = 0.; for (j = ia[i]; j < ia[i+1]; j++) wgt += edges[j]->wgt; - if (DEBUG) if (Verbose) fprintf(stderr,"calling ink3...\n"); + if (MINGLE_DEBUG) if (Verbose) fprintf(stderr,"calling ink3...\n"); ink1 = ink(edges, ia[i+1]-ia[i], pick, &ink0, &meet1, &meet2, angle_param, angle); - if (DEBUG) if (Verbose) fprintf(stderr,"done calling ink3...\n"); + if (MINGLE_DEBUG) if (Verbose) fprintf(stderr,"done calling ink3...\n"); assert(fabs(ink1 - cgrid->inks[i])<=MAX(TOL, TOL*ink1) && ink1 - ink0 <= TOL); assert(ink1 < 1000 * ink0); /* assert that points were found */ xx[i*4 + 0] = meet1.x;