]> granicus.if.org Git - graphviz/commitdiff
Refine the verbose printing mode, allowing multiple levels;
authorEmden R. Gansner <erg@research.att.com>
Fri, 16 Aug 2013 21:25:43 +0000 (17:25 -0400)
committerEmden R. Gansner <erg@research.att.com>
Fri, 16 Aug 2013 21:25:43 +0000 (17:25 -0400)
print parameters.

cmd/mingle/minglemain.c
lib/mingle/agglomerative_bundling.c
lib/mingle/edge_bundling.c

index e701497e94fbb6aab5104eb8a757ede4fbe22a5b..40174f23e5fbcf4108f639a20995c44a8f68736b 100644 (file)
@@ -132,12 +132,12 @@ static void init(int argc, char *argv[], opts_t* opts)
        opts->nneighbors = 10;
        opts->max_recursion = 100;
        opts->angle_param = -1;
-       opts->angle = 40/180*M_PI;
+       opts->angle = 40.0/180.0*M_PI;
 
-       while ((c = getopt(argc, argv, ":a:c:i:k:K:m:o:p:r:T:v")) != -1) {
+       while ((c = getopt(argc, argv, ":a:c:i:k:K:m:o:p:r:T:v:")) != -1) {
                switch (c) {
                case 'a':
-            if ((sscanf(optarg,"%lf",&s) > 0) && (s > 0))
+            if ((sscanf(optarg,"%lf",&s) > 0) && (s >= 0))
                                opts->angle =  M_PI*s/180;
                        else 
                                fprintf (stderr, "-a arg %s must be positive real - ignored\n", optarg); 
@@ -201,10 +201,18 @@ static void init(int argc, char *argv[], opts_t* opts)
                        break;
                case 'v':
                        Verbose = 1;
+            if ((sscanf(optarg,"%d",&i) > 0) && (i >= 0))
+                               Verbose =  i;
+                       else 
+                               fprintf (stderr, "-v arg %s must be a non-negative integer - ignored\n", optarg); 
                        break;
                case ':':
-                       fprintf(stderr, "%s: option -%c missing argument\n", CmdName, optopt);
-                       usage(1);
+                       if (optopt == 'v')
+                               Verbose = 1;
+                       else {
+                               fprintf(stderr, "%s: option -%c missing argument\n", CmdName, optopt);
+                               usage(1);
+                       }
                        break;
                case '?':
                        if (optopt == '?')
@@ -220,6 +228,18 @@ static void init(int argc, char *argv[], opts_t* opts)
     if (argc > 0)
                Files = argv;
     if (!outfile) outfile = stdout;
+    if (Verbose) {
+       fprintf (stderr, "Mingle params:\n");
+       fprintf (stderr, "  outer_iter = %d\n", opts->outer_iter);
+       fprintf (stderr, "  method = %d\n", opts->method);
+       fprintf (stderr, "  compatibility_method = %d\n", opts->compatibility_method);
+       fprintf (stderr, "  K = %.02f\n", opts->K);
+       fprintf (stderr, "  fmt = %s\n", (opts->fmt?"simple":"gv"));
+       fprintf (stderr, "  nneighbors = %d\n", opts->nneighbors);
+       fprintf (stderr, "  max_recursion = %d\n", opts->max_recursion);
+       fprintf (stderr, "  angle_param = %.02f\n", opts->angle_param);
+       fprintf (stderr, "  angle = %.02f\n", 180*opts->angle/M_PI);
+    }
 }
 
 static int
index 61de39f3a06f3fd1d54353af59e930d9e7125c63..d0175436789fc6ae6beee9dcd2e92b056df40012 100644 (file)
@@ -96,7 +96,7 @@ static Agglomerative_Ink_Bundling Agglomerative_Ink_Bundling_establish(Agglomera
   real ink0, ink1, grand_total_ink = 0, grand_total_gain = 0;
   point_t meet1, meet2;
 
-  if (Verbose) fprintf(stderr,"level ===================== %d, n = %d\n",grid->level, n);
+  if (Verbose > 1) fprintf(stderr,"level ===================== %d, n = %d\n",grid->level, n);
   cedges = MALLOC(sizeof(Vector)*n);
   cinks = MALLOC(sizeof(real)*n);
   for (i = 0; i < n; i++) cedges[i] = Vector_new(1, sizeof(int), NULL);
@@ -273,7 +273,7 @@ static Agglomerative_Ink_Bundling Agglomerative_Ink_Bundling_establish(Agglomera
     cgrid->inks = cinks;
     cgrid->total_ink = grand_total_ink;
 
-    if (Verbose) fprintf(stderr,"level %d->%d, edges %d -> %d, ink %f->%f , gain = %f, or %f\n", grid->level, cgrid->level, grid->n, 
+    if (Verbose > 1) fprintf(stderr,"level %d->%d, edges %d -> %d, ink %f->%f , gain = %f, or %f\n", grid->level, cgrid->level, grid->n, 
                         cgrid->n, grid->total_ink, grand_total_ink, grid->total_ink - grand_total_ink, grand_total_gain);       
     assert(ABS(grid->total_ink - cgrid->total_ink - grand_total_gain) <= 0.0001*grid->total_ink);
 
@@ -282,7 +282,7 @@ static Agglomerative_Ink_Bundling Agglomerative_Ink_Bundling_establish(Agglomera
     cgrid->prev = grid;
 
   } else {
-    if (Verbose) fprintf(stderr,"no more improvement, orig ink = %f, gain = %f, stop and final bundling found\n", grand_total_ink, grand_total_gain);
+    if (Verbose > 1) fprintf(stderr,"no more improvement, orig ink = %f, gain = %f, stop and final bundling found\n", grand_total_ink, grand_total_gain);
     /* no more improvement, stop and final bundling found */
     for (i = 0; i < n; i++) matching[i] = i;
   }
@@ -320,7 +320,7 @@ static Agglomerative_Ink_Bundling Agglomerative_Ink_Bundling_aggressive_establis
   real ink0, ink1, grand_total_ink = 0, grand_total_gain = 0;
   point_t meet1, meet2;
 
-  if (Verbose) fprintf(stderr,"level ===================== %d, n = %d\n",grid->level, n);
+  if (Verbose > 1) fprintf(stderr,"level ===================== %d, n = %d\n",grid->level, n);
   cedges = MALLOC(sizeof(Vector)*n);
   cinks = MALLOC(sizeof(real)*n);
   for (i = 0; i < n; i++) cedges[i] = Vector_new(1, sizeof(int), NULL);
@@ -521,7 +521,7 @@ static Agglomerative_Ink_Bundling Agglomerative_Ink_Bundling_aggressive_establis
     cgrid->inks = cinks;
     cgrid->total_ink = grand_total_ink;
 
-    if (Verbose) fprintf(stderr,"level %d->%d, edges %d -> %d, ink %f->%f , gain = %f, or %f\n", grid->level, cgrid->level, grid->n, 
+    if (Verbose > 1) fprintf(stderr,"level %d->%d, edges %d -> %d, ink %f->%f , gain = %f, or %f\n", grid->level, cgrid->level, grid->n, 
                         cgrid->n, grid->total_ink, grand_total_ink, grid->total_ink - grand_total_ink, grand_total_gain);       
     assert(ABS(grid->total_ink - cgrid->total_ink - grand_total_gain) <= 0.0001*grid->total_ink);
 
@@ -530,7 +530,7 @@ static Agglomerative_Ink_Bundling Agglomerative_Ink_Bundling_aggressive_establis
     cgrid->prev = grid;
 
   } else {
-    if (Verbose) fprintf(stderr,"no more improvement, orig ink = %f, gain = %f, stop and final bundling found\n", grand_total_ink, grand_total_gain);
+    if (Verbose > 1) fprintf(stderr,"no more improvement, orig ink = %f, gain = %f, stop and final bundling found\n", grand_total_ink, grand_total_gain);
     /* no more improvement, stop and final bundling found */
     for (i = 0; i < n; i++) matching[i] = i;
   }
@@ -578,7 +578,7 @@ static pedge* agglomerative_ink_bundling_internal(int dim, SparseMatrix A, pedge
   clock_t start;
   
   (*recurse_level)++;
-  if (Verbose) fprintf(stderr, "agglomerative_ink_bundling_internal, recurse level ------- %d\n",*recurse_level);
+  if (Verbose > 1) fprintf(stderr, "agglomerative_ink_bundling_internal, recurse level ------- %d\n",*recurse_level);
 
   assert(A->m == A->n);
 
@@ -586,7 +586,7 @@ static pedge* agglomerative_ink_bundling_internal(int dim, SparseMatrix A, pedge
 
   start = clock();
   grid = Agglomerative_Ink_Bundling_new(A, edges, angle_param, angle);
-  if (Verbose)
+  if (Verbose > 1)
     fprintf(stderr, "CPU for agglomerative bundling %f\n", ((real) (clock() - start))/CLOCKS_PER_SEC);
   ink0 = grid->total_ink;
 
@@ -599,14 +599,14 @@ static pedge* agglomerative_ink_bundling_internal(int dim, SparseMatrix A, pedge
 
   if (*current_ink < 0){
     *current_ink = *ink00 = ink0;
-    if (Verbose)
+    if (Verbose > 1)
       fprintf(stderr,"initial total ink = %f\n",*current_ink);
   } 
   if (ink1 < ink0){
     *current_ink -= ink0 - ink1;
   }
 
-  if (Verbose) fprintf(stderr,"ink: %f->%f, edges: %d->%d, current ink = %f, percentage gain over original = %f\n", ink0, ink1, grid->n, cgrid->n, *current_ink, (ink0-ink1)/(*ink00));
+  if (Verbose > 1) fprintf(stderr,"ink: %f->%f, edges: %d->%d, current ink = %f, percentage gain over original = %f\n", ink0, ink1, grid->n, cgrid->n, *current_ink, (ink0-ink1)/(*ink00));
 
   /* if no meaningful improvement (0.0001%), out, else rebundle the middle section */
   if ((ink0-ink1)/(*ink00) < 0.000001 || *recurse_level > MAX_RECURSE_LEVEL) {
@@ -766,7 +766,7 @@ pedge* agglomerative_ink_bundling(int dim, SparseMatrix A, pedge* edges, int nne
   edges2 = agglomerative_ink_bundling_internal(dim, A, edges, nneighbor, &recurse_level, MAX_RECURSE_LEVEL, angle_param, angle, open_gl, &current_ink, &ink0, flag);
 
   
-  if (Verbose)
+  if (Verbose > 1)
     fprintf(stderr,"initial total ink = %f, final total ink = %f, inksaving = %f percent, total ink_calc = %f, avg ink_calc per edge = %f\n", ink0, current_ink, (ink0-current_ink)/ink0, ink_count,  ink_count/(real) A->m);
   return edges2;
 }
index 256ffd09630339eae9252e258ae71b8c93a51e69..8f1447f6886151139272f3fc74a0dbad5172adc8 100644 (file)
@@ -570,7 +570,7 @@ static pedge* force_directed_edge_bundling(SparseMatrix A, pedge* edges, int max
   real step = step0;
   real fnorm_a, fnorm_t, edge_length, start;
   
-  if (Verbose)
+  if (Verbose > 1)
     fprintf(stderr, "total interaction pairs = %d out of %d, avg neighbors per edge = %f\n",A->nz, A->m*A->m, A->nz/(real) A->m);
 
   force_t = MALLOC(sizeof(real)*dim*(np));
@@ -618,7 +618,7 @@ static pedge* force_directed_edge_bundling(SparseMatrix A, pedge* edges, int max
       
     }
     step = step*0.9;
-  if (Verbose)
+  if (Verbose > 1)
     fprintf(stderr, "iter ==== %d cpu = %f npoints = %d\n",iter, ((real) (clock() - start))/CLOCKS_PER_SEC, np - 2);
 
 #ifdef OPENGL
@@ -668,7 +668,7 @@ static pedge* modularity_ink_bundling(int dim, int ne, SparseMatrix B, pedge* ed
 #endif
 
   assert(!flag);
-  if (Verbose) fprintf(stderr, "there are %d clusters, modularity = %f\n",nclusters, modularity);
+  if (Verbose > 1) fprintf(stderr, "there are %d clusters, modularity = %f\n",nclusters, modularity);
   
   C = SparseMatrix_new(1, 1, 1, MATRIX_TYPE_PATTERN, FORMAT_COORD);
   
@@ -683,7 +683,7 @@ static pedge* modularity_ink_bundling(int dim, int ne, SparseMatrix B, pedge* ed
   clusters = D->ja;
   for (i = 0; i < nclusters; i++){
     ink1 = ink(edges, clusterp[i+1] - clusterp[i], &(clusters[clusterp[i]]), &ink0, &meet1, &meet2, angle_param, angle);
-    if (Verbose)
+    if (Verbose > 1)
       fprintf(stderr,"nedges = %d ink0 = %f, ink1 = %f\n",clusterp[i+1] - clusterp[i], ink0, ink1);
     if (ink1 < ink0){
       for (j = clusterp[i]; j < clusterp[i+1]; j++){
@@ -746,7 +746,7 @@ static SparseMatrix check_compatibility(SparseMatrix A, int ne, pedge *edges, in
   //SparseMatrix_print("C",C);
   SparseMatrix_delete(B);
   B = C;
-  if (Verbose)
+  if (Verbose > 1)
     fprintf(stderr, "edge compatibilitu time = %f\n",((real) (clock() - start))/CLOCKS_PER_SEC);
   return B;
 }
@@ -789,9 +789,6 @@ pedge* edge_bundling(SparseMatrix A0, int dim, real *x, int maxit_outer, real K,
 
 
   if (Verbose) start = clock();
-#ifndef HAVE_ANN
-  method = METHOD_INK; 
-#endif
   if (method == METHOD_INK){
 
     /* go through the links and make sure edges are compatable */