17#include "../tools/openFile.h"
66" where graphfile must contain node positions, and widths and heights for each node. No overlap between nodes should be present. Acceptable options are: \n\
67 -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\
68 -b v - polygon line width, with v < 0 for no line. (0)\n\
69 -c k - polygon color scheme (1)\n\
71 1 : pastel (default)\n\
74 4 : light grey to red\n\
76 6 : sequential single hue red \n\
77 7 : Adam color scheme\n\
79 9 : sequential single hue lighter red \n\
81 -c_opacity=xx - 2-character hex string for opacity of polygons\n\
82 -C k - generate at most k clusters. (0)\n\
83 -d s - seed used to calculate Fiedler vector for optimal coloring\n\
84 -D - use top-level cluster subgraphs to specify clustering\n\
86 -h k - number of artificial points added to maintain bridge between endpoints (0)\n\
87 -highlight=k - only draw cluster k\n\
88 -k - increase randomness of boundary\n\
89 -m v - bounding box margin. If 0, auto-assigned (0)\n\
90 -o <file> - put output in <file> (stdout)\n\
91 -O - do NOT do color assignment optimization that maximizes color difference between neighboring countries\n\
92 -r k - number of random points k used to define sea and lake boundaries. If 0, auto assigned. (0)\n\
93 -s v - depth of the sea and lake shores in points. If < 0, auto assigned. (0)\n\
94 -t n - improve contiguity up to n times. (0)\n\
96 -z c - polygon line color (black)\n";
122 fprintf(stderr,
"Usage: %s <options> graphfile\n",
cmd);
127#define HLPFX "ighlight="
128#define N_HLPFX (sizeof(HLPFX)-1)
164 while ((c = getopt(argc, argv,
":evODQko:m:s:r:c:C:b:t:a:h:z:d:?")) != -1) {
167 if (sscanf(optarg,
"%lf", &
s) > 0 &&
s != 0) {
177 if (sscanf(optarg,
"%lf", &
s) > 0) {
184 if (sscanf(optarg,
"%d", &v) > 0) {
187 sscanf(optarg +
N_HLPFX,
"%d", &v) > 0) {
194 if (sscanf(optarg,
"%d", &r) > 0) {
199 if (sscanf(optarg,
"%d", &r) > 0 && r > 0) {
222 if (sscanf(optarg,
"%d", &r) > 0) {
230 if (sscanf(optarg,
"_opacity=%2s", stmp) > 0 && strlen(stmp) == 2){
239 fprintf(stderr,
"-c option %s is invalid, must be a valid integer or string\n", optarg);
245 if (sscanf(optarg,
"%d",&v) <= 0){
252 if (!(sscanf(optarg,
"%d", &v) > 0 && v >= 0)) {
263 if (sscanf(optarg,
"%lf",&
s) > 0) {
266 fprintf (stderr,
"%s: unexpected argument \"%s\" for -b flag\n",
cmd, optarg);
270 fprintf(stderr,
"gvpack: option -%c missing argument - ignored\n", optopt);
273 if (optopt ==
'\0' || optopt ==
'?')
276 fprintf(stderr,
" option -%c unrecognized\n", optopt);
297 for (i = 0; i < n; i++) {
298 if (grouping[i] == clust_num)
return clust_num;
300 fprintf (stderr,
"Highlighted cluster %d not found - ignored\n", clust_num);
306 int *grouping,
float *rgb_r,
311 int nverts, *polys_groups;
331 &nverts, &x_poly, &poly_lines, &polys,
332 &polys_groups, &poly_point_map,
338 if (
Verbose) fprintf(stderr,
"nart = %d\n",nart);
340 if (pm->
color_optimize && country_graph && rgb_r && rgb_g && rgb_b)
344 &rgb_r, &rgb_g, &rgb_b);
348 fprintf(stderr,
"map making time = %f\n",((
double) (clock() - cpu)) / CLOCKS_PER_SEC);
354 if (
graph && improve_contiguity_n) {
355 for (i = 0; i < improve_contiguity_n; i++){
379 plot_dot_map(g, polys, poly_lines, pm->
line_width, pm->
line_color, x_poly, polys_groups, rgb_r, rgb_g, rgb_b, pm->
opacity,
394 double* width =
NULL;
396 int *grouping =
NULL;
406 rc =
makeMap(
graph, n, x, width, grouping, rgb_r, rgb_g, rgb_b,
421int main(
int argc,
char *argv[])
428 init(argc, argv, &pm);
void Dot_SetClusterColor(Agraph_t *g, float *rgb_r, float *rgb_g, float *rgb_b, int *clusters)
SparseMatrix Import_coord_clusters_from_dot(Agraph_t *g, int maxcluster, int *nn, double **label_sizes, double **x, int **clusters, float **rgb_r, float **rgb_g, float **rgb_b, int default_color_scheme, int clustering_scheme, int useClusters)
void initDotIO(Agraph_t *g)
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, 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)
void plot_dot_map(Agraph_t *gr, SparseMatrix polys, SparseMatrix poly_lines, double line_width, const char *line_color, double *x_poly, int *polys_groups, float *r, float *g, float *b, const char *opacity, SparseMatrix A, FILE *f)
int make_map_from_rectangle_groups(bool include_OK_points, int n, 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 improve_contiguity(int n, int *grouping, SparseMatrix poly_point_map, double *x, SparseMatrix graph)
void map_optimal_coloring(int seed, SparseMatrix A, float *rgb_r, float *rgb_g, float *rgb_b)
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?