for (n = agfstnode (g); n; n = agnxtnode (g, n)) {
i = ND_id(n);
if (rgb_r && rgb_g && rgb_b) {
- rgb2hex((rgb_r)[(clusters)[i]],(rgb_g)[(clusters)[i]],(rgb_b)[(clusters)[i]], scluster);
+ rgb2hex((rgb_r)[(clusters)[i]],(rgb_g)[(clusters)[i]],(rgb_b)[(clusters)[i]], scluster, NULL);
//sprintf(scluster,"#%2x%2x%2x", (int) (255*((rgb_r)[(clusters)[i]])), (int) (255*((rgb_g)[(clusters)[i]])), (int) (255*((rgb_b)[(clusters)[i]])));
}
agxset(n,clust_clr_sym,scluster);
}
*label_sizes = MALLOC(sizeof(real)*dim*nnodes);
- if (pal){
+ if (pal || (!noclusterinfo && clust_clr_sym)){
*rgb_r = MALLOC(sizeof(float)*(1+MAX_GRPS));
*rgb_g = MALLOC(sizeof(float)*(1+MAX_GRPS));
*rgb_b = MALLOC(sizeof(float)*(1+MAX_GRPS));
h[1] = hex[j];
}
-void rgb2hex(float r, float g, float b, char *cstring){
+void rgb2hex(float r, float g, float b, char *cstring, char *opacity){
cstring[0] = '#';
r2hex(r, &(cstring[1]));
r2hex(g, &(cstring[3]));
r2hex(b, &(cstring[5]));
//set to semitransparent for multiple sets vis
- //cstring[7] = cstring[8] = '3';
- //cstring[9]='\0';
- cstring[7] = '\0';
+ if (opacity && strlen(opacity) >= 2){
+ cstring[7] = opacity[0];
+ cstring[8] = opacity[1];
+ cstring[9]='\0';
+ } else {
+ cstring[7] = '\0';
+ }
}
real Hue2RGB(real v1, real v2, real H) {
extern int colorxlate(char *str, gvcolor_t * color, color_type_t target_type);
-void rgb2hex(float r, float g, float b, char *cstring);/* dimension of cstring must be >=7 */
+void rgb2hex(float r, float g, float b, char *cstring, char* opacity);/* dimension of cstring must be >=7 */
char* hue2rgb(real hue, char *color);
void hue2rgb_real(real hue, real *color);
gvmap \- find clusters and create a geographical map highlighting clusters.
.SH SYNOPSIS
.B gvmap
-[\fB\-ekv?\fP]
[
.I options
]
]
.SH DESCRIPTION
.B gvmap
-takes as input a graph in DOT format, finds node clusters and produces a rendering of the graph as a geographic-style map, with clusters highlighted, in xdot format.
+takes as input a graph in DOT format, finds node clusters and produces a rendering of the graph as a geographic-style map, with clusters highlighted
+as countries, in xdot format.
.P
-The input graph must have node positions and width/height information defined,
-and nodes must not overlap.
+In the input graph, each node must have position, width and height information (pos, width and height attributes,
+respectively) defined, and nodes must not overlap.
.P
By default,
.B gvmap
.P
If the input specifies the desired clustering as described above, it can also
specify a desired coloring by having some node in each cluster provide a
-\fIclustercolor\fP attribute.
+\fIclustercolor\fP attribute. \fBN.B.\fP Unless one specifies \fI-c0\fP, only the \fIclustercolor\fP
+of the last node in a cluster has an effect. In addition, unless one uses \fI-O\fP, \fBgvmap\fP may
+permute the given colors.
.SH OPTIONS
The following options are supported:
.TP
7 : sequential single hue lighter red
8 : light grey
.TP
+.BI \-c_opacity= xy
+Specifies a two-character hexadecimal string specifying the opacity of the polygons.
+.TP
.BI \-C " d"
The integer d specifies the maximum number of clusters (countries) allowed. By default d = 0, which means that there is no limit.
.TP
.BI \-g " c"
Specifies the bounding box color. If not specified, a bounding box is not drawn.
.TP
+.BI \-h " k"
+The number of artificial points added to maintain a bridge between endpoints. By default, this is zero.
+.TP
+.BI \-highlight= k
+Only draw cluster \fIk\fP. By default, all clusters are drawn.
+.TP
.BI \-k
If specified, increases the randomness of outer boundary.
.TP
-.BI \-r " k"
-The number of random points k (integer) used to define sea and lake boundaries. If 0, auto assigned. By default v = 0
+.BI \-l " s"
+Use the string \fIs\fP as a label for the drawing.
.TP
-.BI \-s " v"
-The real number v specifies the depth of the sea and lake shores in points. If 0, auto assigned. By default v = 0.
+.BI \-m " v"
+Generate a margin of \fIv\fP points around the drawing. By default, this is determined by \fBgvmap\fP.
.TP
.BI \-O
-Do NOT do color assignment optimization that maximizes color difference between neighboring countries
+Do NOT do color assignment optimization that maximizes color differences between neighboring countries
.TP
.BI \-o <file>
Put output in <file>. Default output is stdout
.TP
+.BI \-p " k"
+Indicates what level of points should be shown. By default, no points are shown.
+.TP
+ Acceptable values are:
+ 0 : no points
+ 1 : all points
+ 2 : label points
+ 3 : random/artificial points
+.TP
+.BI \-r " k"
+The number of random points k (integer) used to define sea and lake boundaries. If 0, auto assigned. By default v = 0
+.TP
+.BI \-s " v"
+The real number v specifies the depth of the sea and lake shores in points. If 0, auto assigned. By default v = 0.
+.TP
+.BI \-t " n"
+Make \fIn\fP attempts to improve cluster contiguity.
+.TP
.BI \-v
Verbose mode.
.TP
.BI \-z " c"
Specified the polygon line color. Default is black.
+.TP
+.BI \-?
+Print usage and exit.
.SH EXAMPLES
.PP
Given a graph foo.gv, one way to generate a layout and highlight the clusters
int plotedges;
int color_scheme;
real line_width;
+ char *opacity;
char *plot_label;
real *bg_color;
int improve_contiguity_n;
}
static char* usestr =
-" where graphfile must contain node positions, and width/height of each node. No overlap between nodes should be present. Acceptable options are: \n\
+" where graphfile must contain node positions, and widths and heights for each node. No overlap between nodes should be present. Acceptable options are: \n\
-a k - average number of artificial points added along the bounding box of the labels. If < 0, a suitable value is selected automatically. (-1)\n\
-b v - polygon line width, with v < 0 for no line. (0)\n\
-c k - polygon color scheme (1)\n\
6 : sequential single hue red \n\
7 : sequential single hue lighter red \n\
8 : light grey\n\
- -d s - seed used to calculate Fielder vector for optimal coloring\n\
-C k - generate at most k clusters. (0)\n\
+ -d s - seed used to calculate Fielder vector for optimal coloring\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\
- -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\
+ -l s - specify label\n\
+ -m v - bounding box margin. If 0, auto-assigned (0)\n\
-o <file> - put output in <file> (stdout)\n\
-O - do NOT do color assignment optimization that maximizes color difference between neighboring countries\n\
- -v - verbose\n\
- -z c - polygon line color (black)\n";
-
-/*
-
- -t n - improve contiguity up to n times. (0)\n\
-p k - show points. (0)\n\
0 : no points\n\
1 : all points\n\
2 : label points\n\
3 : random/artificial points\n\
- -h k - number of artificial points added maintain bridge between endpoints (0)\n\
- -l s - specify label\n\
- -m v - bounding box margin. If 0, auto assigned (0)\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\
+ -t n - improve contiguity up to n times. (0)\n\
+ -v - verbose\n\
+ -z c - polygon line color (black)\n";
+
+/*
+
-q f - output format (3)\n\
0 : Mathematica\n\
1 : PostScript\n\
unsigned int c;
real s;
int v, r;
+ char stmp[3]; /* two character string plus '\0' */
pm->outfile = NULL;
+ pm->opacity = NULL;
pm->nrandom = -1;
pm->dim = 2;
pm->shore_depth_tol = 0;
/* bbox_margin[0] = bbox_margin[1] = -0.2;*/
pm->bbox_margin[0] = pm->bbox_margin[1] = 0;
- while ((c = getopt(argc, argv, ":efvOko:m:s:r:p:c:C:l:b:g:t:a:h:z:d:")) != -1) {
+ while ((c = getopt(argc, argv, ":evOko:m:s:r:p:c:C:l:b:g:t:a:h:z:d:")) != -1) {
switch (c) {
case 'm':
if ((sscanf(optarg,"%lf",&s) > 0) && (s != 0)){
}
break;
case 'c':
- if ((sscanf(optarg,"%d",&r) > 0) && r >= COLOR_SCHEME_NONE && r <= COLOR_SCHEME_GREY){
+ if (sscanf(optarg,"_opacity=%2s", stmp) > 0 && strlen(stmp) == 2){
+ pm->opacity = strdup(stmp);
+ } else if ((sscanf(optarg,"%d",&r) > 0) && r >= COLOR_SCHEME_NONE && r <= COLOR_SCHEME_GREY){
pm->color_scheme = r;
} else {
usage(cmd,1);
if (whatout == OUT_DOT){
#endif
Dot_SetClusterColor(g, rgb_r, rgb_g, rgb_b, grouping);
- plot_dot_map(g, n, dim, x, polys, poly_lines, pm->line_width, pm->line_color, x_poly, polys_groups, labels, width, fsz, rgb_r, rgb_g, rgb_b, pm->plot_label, pm->bg_color, (pm->plotedges?graph:NULL), pm->outfile);
+ plot_dot_map(g, n, dim, x, polys, poly_lines, pm->line_width, pm->line_color, x_poly, polys_groups, labels, width, fsz, rgb_r, rgb_g, rgb_b, pm->opacity,
+ pm->plot_label, pm->bg_color, (pm->plotedges?graph:NULL), pm->outfile);
#if 0
}
goto RETURN;
}
-void plot_dot_polygons(char **sbuff, int *len, int *len_max, real line_width, char *line_color, SparseMatrix polys, real *x_poly, int *polys_groups, float *r, float *g, float *b){
+void plot_dot_polygons(char **sbuff, int *len, int *len_max, real line_width, char *line_color, SparseMatrix polys, real *x_poly, int *polys_groups, float *r, float *g, float *b, char* opacity){
int i, j, *ia = polys->ia, *ja = polys->ja, *a = (int*) polys->a, npolys = polys->m, nverts = polys->n, ipoly,first;
int np = 0, maxlen = 0;
float *xp, *yp;
ipoly = ABS(a[j]);
is_river = (a[j] < 0);
if (r && g && b) {
- rgb2hex(r[polys_groups[i]], g[polys_groups[i]], b[polys_groups[i]], cstring);
+ rgb2hex(r[polys_groups[i]], g[polys_groups[i]], b[polys_groups[i]], cstring, opacity);
}
dot_one_poly(sbuff, len, len_max, use_line, line_width, fill, close, is_river, np, xp, yp, cstring);
np = 0;/* start a new polygon */
void plot_dot_map(Agraph_t* gr, int n, int dim, real *x, SparseMatrix polys, SparseMatrix poly_lines, real line_width, char *line_color, real *x_poly, int *polys_groups, char **labels, real *width,
- float *fsz, float *r, float *g, float *b, char *plot_label, real *bg_color, SparseMatrix A, FILE* f){
+ float *fsz, float *r, float *g, float *b, char* opacity, char *plot_label, real *bg_color, SparseMatrix A, FILE* f){
/* if graph object exist, we just modify some attributes, otherwise we dump the whole graph */
int plot_polyQ = TRUE;
char *sbuff;
/*polygons */
if (plot_polyQ) {
if (!gr) fprintf(f,"_draw_ = \"");
- plot_dot_polygons(&sbuff, &len, &len_max, -1., NULL, polys, x_poly, polys_groups, r, g, b);
+ plot_dot_polygons(&sbuff, &len, &len_max, -1., NULL, polys, x_poly, polys_groups, r, g, b, opacity);
}
/* polylines: line width is set here */
if (line_width >= 0){
- plot_dot_polygons(&sbuff, &len, &len_max, line_width, line_color, poly_lines, x_poly, polys_groups, NULL, NULL, NULL);
+ plot_dot_polygons(&sbuff, &len, &len_max, line_width, line_color, poly_lines, x_poly, polys_groups, NULL, NULL, NULL, NULL);
}
if (!gr) {
fprintf(f,"%s",sbuff);
float *fsz, float *r, float *g, float *b, char *plot_label, real *bg_color, SparseMatrix A);
#endif
-void plot_dot_map(Agraph_t* gr, int n, int dim, real *x, SparseMatrix polys, SparseMatrix poly_lines, real line_width, char *line_color, real *x_poly, int *polys_groups, char **labels, real *width, float *fsz, float *r, float *g, float *b, char *plot_label, real *bg_color, SparseMatrix A, FILE*);
+void plot_dot_map(Agraph_t* gr, int n, int dim, real *x, SparseMatrix polys, SparseMatrix poly_lines, real line_width, char *line_color, real *x_poly, int *polys_groups, char **labels, real *width, float *fsz, float *r, float *g, float *b, char* opacity, char *plot_label, real *bg_color, SparseMatrix A, FILE*);
#if 0
void plot_processing_map(Agraph_t* gr, int n, int dim, real *x, SparseMatrix polys, SparseMatrix poly_lines, real line_width, int nverts, real *x_poly, int *polys_groups, char **labels, real *width, float *fsz, float *r, float *g, float *b, char *plot_label, real *bg_color, SparseMatrix A);