17#include "../tools/openFile.h"
67" where graphfile must contain node positions, and widths and heights for each node. No overlap between nodes should be present. Acceptable options are: \n\
68 -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\
69 -b v - polygon line width, with v < 0 for no line. (0)\n\
70 -c k - polygon color scheme (1)\n\
72 1 : pastel (default)\n\
75 4 : light grey to red\n\
77 6 : sequential single hue red \n\
78 7 : Adam color scheme\n\
80 9 : sequential single hue lighter red \n\
82 -c_opacity=xx - 2-character hex string for opacity of polygons\n\
83 -C k - generate at most k clusters. (0)\n\
84 -d s - seed used to calculate Fiedler vector for optimal coloring\n\
85 -D - use top-level cluster subgraphs to specify clustering\n\
87 -g c - bounding box color. If not specified, a bounding box is not drawn.\n\
88 -h k - number of artificial points added to maintain bridge between endpoints (0)\n\
89 -highlight=k - only draw cluster k\n\
90 -k - increase randomness of boundary\n\
91 -l s - specify label\n\
92 -m v - bounding box margin. If 0, auto-assigned (0)\n\
93 -o <file> - put output in <file> (stdout)\n\
94 -O - do NOT do color assignment optimization that maximizes color difference between neighboring countries\n\
96 -r k - number of random points k used to define sea and lake boundaries. If 0, auto assigned. (0)\n\
97 -s v - depth of the sea and lake shores in points. If < 0, auto assigned. (0)\n\
98 -t n - improve contiguity up to n times. (0)\n\
100 -z c - polygon line color (black)\n";
126 fprintf(stderr,
"Usage: %s <options> graphfile\n",
cmd);
131#define HLPFX "ighlight="
132#define N_HLPFX (sizeof(HLPFX)-1)
170 while ((c = getopt(argc, argv,
":evODQko:m:s:r:p:c:C:l:b:g:t:a:h:z:d:?")) != -1) {
173 if (sscanf(optarg,
"%lf", &
s) > 0 &&
s != 0) {
183 if (sscanf(optarg,
"%lf", &
s) > 0) {
190 if (sscanf(optarg,
"%d", &v) > 0) {
193 sscanf(optarg +
N_HLPFX,
"%d", &v) > 0) {
200 if (sscanf(optarg,
"%d", &r) > 0) {
205 if (sscanf(optarg,
"%d", &r) > 0 && r > 0) {
230 if (sscanf(optarg,
"%d", &r) > 0) {
237 if (sscanf(optarg,
"_opacity=%2s", stmp) > 0 && strlen(stmp) == 2){
246 fprintf(stderr,
"-c option %s is invalid, must be a valid integer or string\n", optarg);
251 if (sscanf(optarg,
"%d",&v) <= 0){
258 if (!(sscanf(optarg,
"%d", &v) > 0 && v >= 0)) {
272 if (sscanf(optarg,
"%lf",&
s) > 0) {
275 fprintf (stderr,
"%s: unexpected argument \"%s\" for -b flag\n",
cmd, optarg);
282 fprintf(stderr,
"gvpack: option -%c missing argument - ignored\n", optopt);
285 if (optopt ==
'\0' || optopt ==
'?')
288 fprintf(stderr,
" option -%c unrecognized\n", optopt);
309 for (i = 0; i < n; i++) {
310 if (grouping[i] == clust_num)
return clust_num;
312 fprintf (stderr,
"Highlighted cluster %d not found - ignored\n", clust_num);
318 int *grouping,
char **labels,
float *fsz,
float *rgb_r,
323 int nverts, *polys_groups;
343 &nverts, &x_poly, &poly_lines, &polys,
344 &polys_groups, &poly_point_map,
350 if (
Verbose) fprintf(stderr,
"nart = %d\n",nart);
352 if (pm->
color_optimize && country_graph && rgb_r && rgb_g && rgb_b)
356 &rgb_r, &rgb_g, &rgb_b);
360 fprintf(stderr,
"map making time = %f\n",((
double) (clock() - cpu)) / CLOCKS_PER_SEC);
366 if (
graph && improve_contiguity_n) {
367 for (i = 0; i < improve_contiguity_n; i++){
371 n,
dim, x, width, grouping,
graph, pm->
bbox_margin, nrandom, &nart, pm->
nedgep,
383 n,
dim, x, width, grouping,
graph, pm->
bbox_margin, nrandom, &nart, pm->
nedgep,
391 plot_dot_map(g, n,
dim, x, polys, poly_lines, pm->
line_width, pm->
line_color, x_poly, polys_groups, labels, fsz, rgb_r, rgb_g, rgb_b, pm->
opacity,
405 double* width =
NULL;
407 char** labels =
NULL;
417 const int rc =
makeMap(
graph, n, x, width, grouping, labels, fsz, rgb_r,
418 rgb_g, rgb_b, pm, g);
425int main(
int argc,
char *argv[])
432 init(argc, argv, &pm);
void Dot_SetClusterColor(Agraph_t *g, float *rgb_r, float *rgb_g, float *rgb_b, int *clusters)
void initDotIO(Agraph_t *g)
SparseMatrix Import_coord_clusters_from_dot(Agraph_t *g, int maxcluster, int dim, int *nn, double **label_sizes, double **x, int **clusters, float **rgb_r, float **rgb_g, float **rgb_b, float **fsz, char ***labels, int default_color_scheme, int clustering_scheme, int useClusters)
void SparseMatrix_delete(SparseMatrix A)
SparseMatrix SparseMatrix_get_real_adjacency_matrix_symmetrized(SparseMatrix A)
bool knownColorScheme(const char *name)
static NORETURN void graphviz_exit(int status)
static int eval(Agraph_t *g, int root)
int agclose(Agraph_t *g)
deletes a graph, freeing its associated storage
Agraph_t * graph(char *name)
static void init(int argc, char **argv, params_t *pm)
static const char usestr[]
static int mapFromGraph(Agraph_t *g, params_t *pm)
static int validateCluster(int n, int *grouping, int clust_num)
static int makeMap(SparseMatrix graph, int n, double *x, double *width, int *grouping, char **labels, float *fsz, float *rgb_r, float *rgb_g, float *rgb_b, params_t *pm, Agraph_t *g)
static const char * usage
Agraph_t * nextGraph(ingraph_state *sp)
ingraph_state * newIngraph(ingraph_state *sp, char **files)
supports user-supplied data
void map_palette_optimal_coloring(char *color_scheme, SparseMatrix A0, float **rgb_r, float **rgb_g, float **rgb_b)
int make_map_from_rectangle_groups(bool include_OK_points, int n, int dim, double *x, double *sizes, int *grouping, SparseMatrix graph, double bounding_box_margin, int nrandom, int *nart, int nedgep, double shore_depth_tol, int *nverts, double **x_poly, SparseMatrix *poly_lines, SparseMatrix *polys, int **polys_groups, SparseMatrix *poly_point_map, SparseMatrix *country_graph, int highlight_cluster)
void map_optimal_coloring(int seed, SparseMatrix A, float *rgb_r, float *rgb_g, float *rgb_b)
void plot_dot_map(Agraph_t *gr, int n, int dim, double *x, SparseMatrix polys, SparseMatrix poly_lines, double line_width, const char *line_color, double *x_poly, int *polys_groups, char **labels, float *fsz, float *r, float *g, float *b, const char *opacity, SparseMatrix A, FILE *f)
void improve_contiguity(int n, int dim, int *grouping, SparseMatrix poly_point_map, double *x, SparseMatrix graph)
static FILE * openFile(const char *argv0, const char *name, const char *mode)
void remove_overlap(int dim, SparseMatrix A, double *x, double *label_sizes, int ntry, double initial_scaling, int edge_labeling_scheme, int n_constr_nodes, int *constr_nodes, SparseMatrix A_constr, bool do_shrinking)
static bool startswith(const char *s, const char *prefix)
does the string s begin with the string prefix?