From e4db68ecffba3351288d74d1b26ccc2758a177e5 Mon Sep 17 00:00:00 2001 From: "Emden R. Gansner" Date: Tue, 24 Feb 2015 13:19:38 -0500 Subject: [PATCH] Clean up text messages; add more verbose information --- cmd/gvmap/country_graph_coloring.c | 4 ++-- cmd/gvmap/gvmap.c | 7 +++--- cmd/gvmap/make_map.c | 34 +++++++++++++++++++++--------- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/cmd/gvmap/country_graph_coloring.c b/cmd/gvmap/country_graph_coloring.c index 38bb8844b..3255b3c40 100644 --- a/cmd/gvmap/country_graph_coloring.c +++ b/cmd/gvmap/country_graph_coloring.c @@ -226,7 +226,7 @@ void improve_antibandwidth_by_swapping_cheap(SparseMatrix A, int *p){ void improve_antibandwidth_by_swapping(SparseMatrix A, int *p){ int improved = TRUE; - int n = A->m, i, j, *ia = A->ia, *ja = A->ja; + int cnt = 1, n = A->m, i, j, *ia = A->ia, *ja = A->ja; real norm = n, norm1[3], norm2[3], norm11[3], norm22[3]; real pi, pj; real start = clock(); @@ -268,7 +268,7 @@ void improve_antibandwidth_by_swapping(SparseMatrix A, int *p){ } if (Verbose) { get_12_norm(n, ia, ja, p, norm1); - fprintf(stderr, "aband = %f, aband_avg = %f\n", norm1[0], norm1[2]); + fprintf(stderr, "[%d] aband = %f, aband_avg = %f\n", cnt++, norm1[0], norm1[2]); fprintf(fp,"%f %f %f\n", (real) (clock() - start)/(CLOCKS_PER_SEC), norm1[0], norm1[2]); } } diff --git a/cmd/gvmap/gvmap.c b/cmd/gvmap/gvmap.c index 3b2b9f40d..f908e30f1 100644 --- a/cmd/gvmap/gvmap.c +++ b/cmd/gvmap/gvmap.c @@ -196,13 +196,13 @@ static char* usestr = 10 : light grey\n\ -c_opacity=xx - 2-character hex string for opacity of polygons\n\ -C k - generate at most k clusters. (0)\n\ - -d s - seed used to calculate Fielder vector for optimal coloring\n\ + -d s - seed used to calculate Fiedler vector for optimal coloring\n\ -D - use top-level cluster subgraphs to specify clustering\n\ -e - show edges\n\ -g c - bounding box color. If not specified, a bounding box is not drawn.\n\ -h k - number of artificial points added to maintain bridge between endpoints (0)\n\ -highlight=k - only draw cluster k\n\ - -k - increase randomesss of boundary\n\ + -k - increase randomness of boundary\n\ -l s - specify label\n\ -m v - bounding box margin. If 0, auto-assigned (0)\n\ -o - put output in (stdout)\n\ @@ -213,7 +213,7 @@ static char* usestr = 2 : label points\n\ 3 : random/artificial points\n\ -r k - number of random points k used to define sea and lake boundaries. If 0, auto assigned. (0)\n\ - -s v - depth of the sea and lake shores in points. If 0, auto assigned. (0)\n\ + -s v - depth of the sea and lake shores in points. If < 0, auto assigned. (0)\n\ -t n - improve contiguity up to n times. (0)\n\ -v - verbose\n\ -z c - polygon line color (black)\n"; @@ -566,6 +566,7 @@ makeMap (SparseMatrix graph, int n, real* x, real* width, int* grouping, pm->shore_depth_tol, edge_bridge_tol, &xcombined, &nverts, &x_poly, &npolys, &poly_lines, &polys, &polys_groups, &poly_point_map, &country_graph, pm->highlight_cluster, &flag); + if (Verbose) fprintf(stderr,"nart = %d\n",nart); /* compute a good color permutation */ if (pm->color_optimize && country_graph && rgb_r && rgb_g && rgb_b) map_optimal_coloring(pm->seed, country_graph, rgb_r, rgb_g, rgb_b); diff --git a/cmd/gvmap/make_map.c b/cmd/gvmap/make_map.c index 59adbb621..9de244912 100644 --- a/cmd/gvmap/make_map.c +++ b/cmd/gvmap/make_map.c @@ -60,7 +60,7 @@ void map_palette_optimal_coloring(char *color_scheme, char *lightness, SparseMat int flag; int n = A0->m, i, cdim; - SparseMatrix A, B; + SparseMatrix A; int weightedQ = TRUE; int iter_max = 100; @@ -170,7 +170,7 @@ void improve_contiguity(int n, int dim, int *grouping, SparseMatrix poly_point_m } } - if (Verbose || 1) fprintf(stderr,"ratio (edges among discontigous regions vs total edges)=%f\n",((real) nbad)/ia[n]); + if (Verbose) fprintf(stderr,"ratio (edges among discontiguous regions vs total edges)=%f\n",((real) nbad)/ia[n]); stress_model(dim, D, D, &x, FALSE, maxit, tol, &flag); assert(!flag); @@ -1712,7 +1712,7 @@ static void get_polygons(int exclude_random, int n, int nrandom, int dim, Sparse (groups[comps[comps_ptr[i]]] != GRP_BBOX)) break; } ncomps = i + 1; - if (Verbose) fprintf(stderr," ncomps = %d\n",ncomps); + if (Verbose) fprintf(stderr,"ncomps = %d\n",ncomps); } else {/* alwasy exclud bounding box */ for (i = ncomps - 1; i >= 0; i--) { if (groups[comps[comps_ptr[i]]] != GRP_BBOX) break; @@ -1802,11 +1802,9 @@ int make_map_internal(int exclude_random, int include_OK_points, } else { *nrandom -= 4; } - if (Verbose) fprintf(stderr,"nrandom=%d\n",*nrandom); - - if (Verbose) fprintf(stderr,"nrandom=%d\n",*nrandom); if (shore_depth_tol < 0) shore_depth_tol = sqrt(area/(real) n); /* set to average distance for random distribution */ + if (Verbose) fprintf(stderr,"nrandom=%d shore_depth_tol=%.08f\n",*nrandom, shore_depth_tol); /* add artificial points along each edge to avoid as much as possible @@ -1867,6 +1865,22 @@ int make_map_internal(int exclude_random, int include_OK_points, xmax[i] += boxsize[i]*(-bounding_box_margin[i]); } } + if (Verbose) { + real bbm0 = bounding_box_margin[0]; + real bbm1 = bounding_box_margin[1]; + if (bbm0 > 0) + fprintf (stderr, "bounding box margin: %.06f", bbm0); + else if (bbm0 == 0) + fprintf (stderr, "bounding box margin: %.06f", MAX(boxsize[0]*0.2, 2*shore_depth_tol)); + else + fprintf (stderr, "bounding box margin: (%.06f * %.06f)", boxsize[0], -bbm0); + if (bbm1 > 0) + fprintf (stderr, " %.06f\n", bbm1); + else if (bbm1 == 0) + fprintf (stderr, " %.06f\n", MAX(boxsize[1]*0.2, 2*shore_depth_tol)); + else + fprintf (stderr, " (%.06f * %.06f)\n", boxsize[1], -bbm1); + } if (*nrandom < 0) { real n1, n2, area2; area2 = (xmax[1] - xmin[1])*(xmax[0] - xmin[0]); @@ -2128,9 +2142,9 @@ int make_map_from_rectangle_groups(int exclude_random, int include_OK_points, SparseMatrix *country_graph, int highlight_cluster, int *flag){ /* create a list of polygons from a list of rectangles in 2D. rectangles belong to groups. rectangles in the same group that are also close - gemetrically will be in the same polygon describing the outline of the group. The main difference for this function and + geometrically will be in the same polygon describing the outline of the group. The main difference for this function and make_map_from_point_groups is that in this function, the input are points with width/heights, and we try not to place - "lakes" inside these rectangles. The is achieved approximately by adding artificial points along the perimeter of the rectangles, + "lakes" inside these rectangles. This is achieved approximately by adding artificial points along the perimeter of the rectangles, as well as near the center. input: @@ -2149,13 +2163,13 @@ int make_map_from_rectangle_groups(int exclude_random, int include_OK_points, . If nrandom = 0, no points are inserted, if nrandom < 0, the number is decided automatically. . On exit, it is the actual number of random points used. The last 4 "random" points is always the . - nart: on entry, number of artificla points to be added along rach side of a rectangle enclosing the labels. if < 0, auto-selected. + nart: on entry, number of artificial points to be added along each side of a rectangle enclosing the labels. if < 0, auto-selected. . On exit, actual number of artificial points added. nedgep: number of artificial points are adding along edges to establish as much as possible a bright between nodes . connected by the edge, and avoid islands that are connected. k = 0 mean no points. shore_depth_tol: nrandom random points are inserted in the bounding box of the points, . such random points are then weeded out if it is within distance of shore_depth_tol from - . real points. If < 0, auto assigned + . real points. If 0, auto assigned edge_bridge_tol: insert points on edges to give an bridge effect.These points will be evenly spaced . along each edge, and be less than a distance of edge_bridge_tol from each other and from the two ends of the edge. . If < 0, -edge_bridge_tol is the average number of points inserted per half edge -- 2.40.0