35 float **rgb_r,
float **rgb_g,
float **rgb_b){
47 double *colors =
NULL;
48 int n = A0->
m, i, cdim;
51 bool weightedQ =
true;
65 int lightness[] = {0, 100};
69 const double accuracy = 0.01;
85 for (i = 0; i < n; i++){
86 (*rgb_r)[i+1] = (float) colors[cdim*i];
87 (*rgb_g)[i+1] = (float) colors[cdim*i + 1];
88 (*rgb_b)[i+1] = (float) colors[cdim*i + 2];
101 rgb_r++; rgb_b++; rgb_g++;
103 for (i = 0; i < n; i++) rgb_r[i] = u[i];
105 for (i = 0; i < n; i++) rgb_g[i] = u[i];
107 for (i = 0; i < n; i++) rgb_b[i] = u[i];
112 return point_poly_map->
ja[point_poly_map->
ia[ip]];
121 int i, j, *ia, *ja, u, v;
129 assert(
graph->m == n);
130 ia =
D->ia; ja =
D->ja;
136 for (i = 0; i < n; i++){
138 for (j = ia[i]; j < ia[i+1]; j++){
141 if (grouping[u] != grouping[v]){
153 if (
Verbose) fprintf(stderr,
"ratio (edges among discontiguous regions vs total edges)=%f\n",((
double) nbad)/ia[n]);
191 double xy[2], yz[2], nxy[2], nyz[2], ymx[2], ymz[2], beta, bot;
194 for (i = 0; i < 2; i++) ymx[i] = y[i] - x[i];
195 for (i = 0; i < 2; i++) ymz[i] = y[i] -
z[i];
196 for (i = 0; i < 2; i++) xy[i] = 0.5*(x[i] + y[i]);
197 for (i = 0; i < 2; i++) yz[i] = 0.5*(y[i] +
z[i]);
202 bot = nyz[0]*(x[0]-y[0])+nyz[1]*(x[1]-y[1]);
204 c[0] = xy[0]; c[1] = xy[1];
207 beta = ((x[0] - y[0])*(xy[0] - yz[0])+(x[1] - y[1])*(xy[1] - yz[1]))/bot;
208 c[0] = yz[0] + beta*nyz[0];
209 c[1] = yz[1] + beta*nyz[1];
228 for (i = 0; i < n; i++){
229 for (j = ia[i]; j < ia[i+1]; j++){
230 if (ja[j] == i)
continue;
231 fprintf(f,
"%d -- %d;\n",i,ja[j]);
239 for (i = 0; i < n; i++){
241 fprintf(f,
"%d [label=\"%s\", pos=\"%lf,%lf\", fontsize=%f];\n",i, labels[i], x[i*
dim], x[i*
dim+1], fsz[i]);
243 fprintf(f,
"%d [label=\"%s\", pos=\"%lf,%lf\"];\n",i, labels[i], x[i*
dim], x[i*
dim+1]);
252 double line_width,
bool fill, const
char *cstring) {
254 assert(doubles_size(&xp) == doubles_size(&yp));
255 if (!doubles_is_empty(&xp)){
259 strlen(cstring), cstring, strlen(cstring), cstring,
263 size_t len_swidth = (size_t)snprintf(
NULL, 0,
"%f", line_width);
265 " -setlinewidth(%f) L %" PRISIZE_T " ", strlen(cstring), cstring,
266 len_swidth + 14, line_width, doubles_size(&xp));
269 cstring, doubles_size(&xp));
272 for (
size_t i = 0; i < doubles_size(&xp); i++) {
273 agxbprint(sbuff,
" %f %f", doubles_get(&xp, i), doubles_get(&yp, i));
280 double *x_poly,
int *polys_groups,
float *r,
281 float *g,
float *b,
const char *opacity) {
282 int i, j, *ia = polys->
ia, *ja = polys->
ja, *a = polys->
a, npolys = polys->
m, nverts = polys->
n, ipoly,first;
283 const bool fill =
false;
284 const bool use_line = line_width >= 0;
286 agxbuf cstring_buffer = {0};
287 agxbput(&cstring_buffer,
"#aaaaaaff");
288 char *cstring =
agxbuse(&cstring_buffer);
293 if (
Verbose) fprintf(stderr,
"npolys = %d\n",npolys);
294 first = abs(a[0]); ipoly = first + 1;
295 for (i = 0; i < npolys; i++){
296 for (j = ia[i]; j < ia[i+1]; j++){
297 assert(ja[j] < nverts && ja[j] >= 0);
299 if (abs(a[j]) != ipoly){
302 rgb2hex(r[polys_groups[i]], g[polys_groups[i]], b[polys_groups[i]],
303 &cstring_buffer, opacity);
304 cstring =
agxbuse(&cstring_buffer);
306 dot_polygon(sbuff, xp, yp, line_width, fill, cstring);
311 doubles_append(&xp, x_poly[2 * ja[j]]);
312 doubles_append(&yp, x_poly[2 * ja[j] + 1]);
315 dot_polygon(sbuff, xp, yp, line_width, fill, line_color);
328 const char *line_color,
double *x_poly,
int *polys_groups,
329 char **labels,
float *fsz,
float *r,
float *g,
float *b,
332 bool plot_polyQ =
true;
335 if (!r || !g || !b) plot_polyQ =
false;
338 fprintf(f,
"graph map {\n node [margin = 0 width=0.0001 height=0.00001 shape=plaintext];\n graph [outputorder=edgesfirst, bgcolor=\"#dae2ff\"]\n edge [color=\"#55555515\",fontname=\"Helvetica-Bold\"]\n");
353 if (!gr) fprintf(f,
"_background = \"");
358 if (line_width >= 0){
362 fprintf(f,
"%s",
agxbuse(&sbuff));
376 if (!gr) fprintf(f,
"}\n");
397 int i, j, i0, i1, i2, ntri;
401 if (trilist ==
NULL) {
408 for (i = 0; i < ntri; i++) {
409 for (j = 0; j < 3; j++) {
410 (*T)[i].vertices[j] = trilist[i * 3 + j];
412 i0 = (*T)[i].vertices[0]; i1 = (*T)[i].vertices[1]; i2 = (*T)[i].vertices[2];
435 int one = 1, jj, i, j, ig1, ig2;
437 int min_grp, max_grp;
439 min_grp = max_grp = groups[0];
440 for (i = 0; i < n; i++) {
441 max_grp =
MAX(groups[i], max_grp);
442 min_grp =
MIN(groups[i], min_grp);
444 if (min_grp <= 0)
return NULL;
448 for (i = 0; i < n; i++){
451 for (j = ia[i]; j < ia[i+1]; j++){
453 if (i != jj && groups[i] != groups[jj] && groups[jj] != GRP_RANDOM && groups[jj] != GRP_BBOX){
454 ig1 = groups[i]-1; ig2 = groups[jj]-1;
467 int one = 1, jj, i, j;
469 int ncomps, *comps =
NULL;
474 for (i = 0; i < n; i++){
475 for (j = ia[i]; j < ia[i+1]; j++){
477 if (i != jj && groups[i] == groups[jj]){
488 free((*poly_point_map)->ia);
489 free((*poly_point_map)->ja);
490 (*poly_point_map)->ia = comps_ptr;
491 (*poly_point_map)->ja = comps;
492 (*poly_point_map)->nz = n;
498 int **polys_groups,
int GRP_RANDOM,
int GRP_BBOX) {
504 int i, *tlist, nz, ipoly, nnt, ii, jj, t1, t2, t, cur, next, nn, j, nlink, sta;
505 int *
elist, edim = 3;
508 int *ie =
E->ia, *je =
E->ja, *e =
E->a;
512 for (i = 0; i < nt; i++) mask[i] = -1;
517 *polys_groups =
gv_calloc(ncomps,
sizeof(
int));
519 for (i = 0; i < nt; i++)
elist[i*edim + 2] = 0;
520 nz = ie[
E->m] - ie[0];
524 for (i = 0; i < ncomps; i++){
526 for (j = comps_ptr[i]; j < comps_ptr[i+1]; j++){
529 (*polys_groups)[i] = groups[ii];
532 if (groups[ii] == GRP_RANDOM || groups[ii] == GRP_BBOX)
continue;
534 for (jj = ie[ii]; jj < ie[ii+1]; jj++){
535 if (groups[je[jj]] != groups[ii] && jj < nz - 1 && je[jj] == je[jj+1]){
539 nlink =
elist[t1*edim + 2]%2;
540 elist[t1*edim + nlink] = t2;
541 elist[t1*edim + 2]++;
543 nlink =
elist[t2*edim + 2]%2;
544 elist[t2*edim + nlink] = t1;
545 elist[t2*edim + 2]++;
547 tlist[nnt++] = t1; tlist[nnt++] = t2;
554 for (j = 0; j < nnt; j++){
557 cur = sta = t; mask[cur] = i;
596 fprintf(stderr,
"cycle (edges): {");
598 fprintf(stderr,
"%d,",cur);
601 fprintf(stderr,
"%d}\n",cur);
604 fprintf(stderr,
"cycle (vertices): ");
612static int same_edge(
int ecur,
int elast,
int *edge_table){
634 int n =
E->
m, *ie =
E->ia, *je =
E->ja, *e =
E->a, ne, i, j, t1, t2, jj, ii;
635 int *cycle, cycle_head = 0;
638 int *edge_cycle_map, NOT_ON_CYCLE = -1;
640 enum {NO_DUPLICATE = -1};
641 int *
elist, edim = 3;
645 int k, duplicate, ee = 0, ecur, enext, eprev, cur, next, nn, nlink,
head, elast = 0, etail, tail, ehead, efirst;
651 edge_table =
gv_calloc(ne * 2,
sizeof(
int));
656 for (i = 0; i < n; i++){
657 for (j = ie[i]; j < ie[i+1]; j++){
658 if (j < ie[n] - ie[0] - 1 && i > je[j] && je[j] == je[j+1]){
663 edge_table[ne*2] = t1;
664 edge_table[ne*2+1] = t2;
669 edge_table[ne*2] = t2;
670 edge_table[ne*2+1] = t1;
686 edge_cycle_map =
gv_calloc(ne,
sizeof(
int));
688 for (i = 0; i < ne; i++) edge_cycle_map[i] = NOT_ON_CYCLE;
689 for (i = 0; i < ne; i++) emask[i] = -1;
695 for (i = 0; i < nt; i++)
elist[i*edim + 2] = 0;
699 for (i = 0; i < ncomps; i++){
700 if (DEBUG_CYCLE) fprintf(stderr,
"\n ============ comp %d has %d members\n",i, comps_ptr[i+1]-comps_ptr[i]);
701 for (k = comps_ptr[i]; k < comps_ptr[i+1]; k++){
703 duplicate = NO_DUPLICATE;
704 if (DEBUG_CYCLE) fprintf(stderr,
"member = %d has %d neighbors\n",ii, ie[ii+1]-ie[ii]);
705 for (j = ie[ii]; j < ie[ii+1]; j++){
709 if (DEBUG_CYCLE) fprintf(stderr,
" linked with %d using half-edge %d, {head,tail} of the edge = {%d, %d}\n",jj, ee, t1,
edge_tail(ee));
710 nlink =
elist[t1*edim + 2]%2;
711 elist[t1*edim + nlink] = ee;
712 elist[t1*edim + 2]++;
714 if (edge_cycle_map[ee] != NOT_ON_CYCLE) duplicate = ee;
718 if (duplicate == NO_DUPLICATE){
724 edge_cycle_map[ecur] = 1;
727 if (DEBUG_CYCLE) fprintf(stderr,
"NEW CYCLE\n starting with edge %d, {head,tail}={%d,%d}\n", ee,
head, next);
728 while (next !=
head){
734 if (DEBUG_CYCLE) fprintf(stderr,
"cur edge = %d, next edge %d, {head,tail}={%d,%d},\n",ecur, enext,
edge_head(enext),
edge_tail(enext));
741 edge_cycle_map[enext] = 1;
747 if (DEBUG_CYCLE)
cycle_print(ee, cycle,edge_table);
751 ecur = ee = duplicate;
752 while (emask[ecur] == ii){
759 if (DEBUG_CYCLE) fprintf(stderr,
" duplicating edge = %d, starting from the a non-duplicating edge %d, search backwards\n",ee, ecur);
763 while (emask[ecur] == ii){
764 if (DEBUG_CYCLE) fprintf(stderr,
" remove edge %d (%d--%d)\n",ecur,
edge_head(ecur),
edge_tail(ecur));
766 edge_cycle_map[ecur] = NOT_ON_CYCLE;
778 fprintf(stderr,
"remaining (broken) cycle = ");
798 if (DEBUG_CYCLE) fprintf(stderr,
"forwarding now from edge %d = {%d, %d}, try to reach vtx %d, first edge from voro = %d\n",
806 if (
same_edge(ecur, efirst, edge_table)){
807 if (DEBUG_CYCLE) fprintf(stderr,
"this voro cell fill in a hole completely!!!!\n");
810 edge_cycle_map[ecur] = 1;
813 if (DEBUG_CYCLE) fprintf(stderr,
"starting with edge %d, {head,tail}={%d,%d}\n", ecur,
head, next);
814 while (next != tail){
820 if (DEBUG_CYCLE) fprintf(stderr,
"cur edge = %d, next edge %d, {head,tail}={%d,%d},\n",ecur, enext,
edge_head(enext),
edge_tail(enext));
829 edge_cycle_map[enext] = 1;
842 while ((enext =
cycle_next(ecur)) != cycle_head){
843 edge_cycle_map[ecur] = NOT_ON_CYCLE;
848 edge_cycle_map[ecur] = NOT_ON_CYCLE;
863 free(edge_cycle_map);
878 int *comps =
NULL, *comps_ptr =
NULL, ncomps;
879 int GRP_RANDOM, GRP_BBOX;
884 groups =
gv_calloc(n + nrandom,
sizeof(
int));
885 maxgrp = grouping[0];
886 for (i = 0; i < n; i++) {
887 maxgrp =
MAX(maxgrp, grouping[i]);
888 groups[i] = grouping[i];
891 GRP_RANDOM = maxgrp + 1; GRP_BBOX = maxgrp + 2;
892 for (i = n; i < n + nrandom - 4; i++) {
893 groups[i] = GRP_RANDOM;
895 for (i = n + nrandom - 4; i < n + nrandom; i++) {
896 groups[i] = GRP_BBOX;
900 conn_comp(n + nrandom,
E, groups, poly_point_map);
902 ncomps = (*poly_point_map)->m;
903 comps = (*poly_point_map)->ja;
904 comps_ptr = (*poly_point_map)->ia;
908 for (i = ncomps - 1; i >= 0; i--) {
909 if (groups[comps[comps_ptr[i]]] != GRP_RANDOM &&
910 groups[comps[comps_ptr[i]]] != GRP_BBOX)
break;
913 if (
Verbose) fprintf(stderr,
"ncomps = %d\n",ncomps);
916 for (i = 0; i < nt; i++){
917 for (j = 0; j <
dim; j++){
928 polys_groups, GRP_RANDOM, GRP_BBOX);
944 double bounding_box_margin,
int nrandom,
945 int nedgep,
double shore_depth_tol,
int *nverts,
952 double xmax[2],
xmin[2], area, *x = x0;
955 int dim2 = 2, nn = 0;
956 int max_qtree_level = 10;
958 int imin, nzok = 0, nzok0 = 0, nt;
959 double *xran,
point[2];
963 bool INCLUDE_OK_POINTS = include_OK_points;
965 int *grouping = grouping0;
967 int HIGHLIGHT_SET = highlight_cluster;
969 for (j = 0; j < dim2; j++) {
974 for (i = 0; i < n; i++){
975 for (j = 0; j < dim2; j++) {
982 area = boxsize[0]*boxsize[1];
986 }
else if (nrandom < 0){
987 nrandom = -nrandom * n;
988 }
else if (nrandom < 4) {
994 if (shore_depth_tol < 0) shore_depth_tol = sqrt(area/(
double) n);
995 if (
Verbose) fprintf(stderr,
"nrandom=%d shore_depth_tol=%.08f\n", nrandom, shore_depth_tol);
1003 int k, t, np=nedgep;
1005 fprintf(stderr,
"add art np = %d\n",np);
1008 for (i = 0; i < n*
dim; i++) y[i] = x[i];
1009 grouping =
gv_calloc(n + nz * np,
sizeof(
int));
1010 for (i = 0; i < n; i++) grouping[i] = grouping0[i];
1012 for (i = 0; i <
graph->m; i++){
1014 for (j =
graph->ia[i]; j <
graph->ia[i+1]; j++){
1015 if (!HIGHLIGHT_SET || (grouping[i] == grouping[
graph->ja[j]] && grouping[i] == HIGHLIGHT_SET)){
1016 for (t = 0; t < np; t++){
1017 for (k = 0; k <
dim; k++){
1018 y[nz*
dim+k] = t/((double) np)*x[i*
dim+k] + (1-t/((double) np))*x[(
graph->ja[j])*
dim + k];
1020 assert(n + (nz-n)*np + t < n + nz*np && n + (nz-n)*np + t >= 0);
1021 if (t/((
double) np) > 0.5){
1022 grouping[nz] = grouping[i];
1024 grouping[nz] = grouping[
graph->ja[j]];
1031 fprintf(stderr,
"after adding edge points, n:%d->%d\n",n, nz);
1042 for (i = 0; i < dim2; i++) {
1043 if (bounding_box_margin > 0){
1044 xmin[i] -= bounding_box_margin;
1045 xmax[i] += bounding_box_margin;
1046 }
else if (bounding_box_margin < 0) {
1047 xmin[i] -= boxsize[i]*(-bounding_box_margin);
1048 xmax[i] += boxsize[i]*(-bounding_box_margin);
1050 xmin[i] -= fmax(boxsize[i] * 0.2, 2.* shore_depth_tol);
1051 xmax[i] += fmax(boxsize[i] * 0.2, 2 * shore_depth_tol);
1055 double bbm = bounding_box_margin;
1057 fprintf (stderr,
"bounding box margin: %.06f", bbm);
1059 fprintf (stderr,
"bounding box margin: (%.06f * %.06f)", boxsize[0], -bbm);
1061 fprintf(stderr,
"bounding box margin: %.06f",
1062 fmax(boxsize[0] * 0.2, 2 * shore_depth_tol));
1066 const double n1 = floor(
area2 / (shore_depth_tol * shore_depth_tol));
1067 const double n2 = n * floor(
area2 / area);
1068 nrandom = fmax(n1, n2);
1071 xran =
gv_calloc((nrandom + 4) * dim2,
sizeof(
double));
1073 if (INCLUDE_OK_POINTS){
1074 nzok0 = nzok = nrandom - 1;
1075 if (grouping == grouping0) {
1076 int *grouping2 =
gv_calloc(n + nrandom,
sizeof(
int));
1077 memcpy(grouping2, grouping,
sizeof(
int)*n);
1078 grouping = grouping2;
1080 grouping =
gv_recalloc(grouping, n, n + nrandom,
sizeof(
int));
1085 for (i = 0; i < nrandom; i++){
1087 for (j = 0; j < dim2; j++){
1093 if (min > shore_depth_tol){
1094 for (j = 0; j < dim2; j++){
1095 xran[nz*dim2+j] =
point[j];
1098 }
else if (INCLUDE_OK_POINTS && min > shore_depth_tol/10){
1099 for (j = 0; j < dim2; j++){
1100 xran[nzok*dim2+j] =
point[j];
1102 grouping[nn++] = grouping[
imin];
1109 if (
Verbose) fprintf(stderr,
"nn nrandom=%d\n", nrandom);
1111 xran =
gv_calloc(4 * dim2,
sizeof(
double));
1117 for (i = 0; i < dim2; i++)
xmin[i] -= 0.2*(
xmax[i]-
xmin[i]);
1118 for (i = 0; i < dim2; i++)
xmax[i] += 0.2*(
xmax[i]-
xmin[i]);
1120 for (j = 0; j < dim2; j++) xran[i*dim2+j] =
xmin[j];
1122 for (j = 0; j < dim2; j++) xran[i*dim2+j] =
xmax[j];
1124 xran[i*dim2] =
xmin[0]; xran[i*dim2+1] =
xmax[1];
1126 xran[i*dim2] =
xmax[0]; xran[i*dim2+1] =
xmin[1];
1131 if (INCLUDE_OK_POINTS){
1132 xcombined =
gv_calloc((nn + nrandom) * dim2,
sizeof(
double));
1134 xcombined =
gv_calloc((n + nrandom) * dim2,
sizeof(
double));
1136 for (i = 0; i < n; i++) {
1137 for (j = 0; j < dim2; j++) xcombined[i*dim2+j] = x[i*
dim+j];
1139 for (i = 0; i < nrandom; i++) {
1140 for (j = 0; j < dim2; j++) xcombined[(i + nn)*dim2+j] = xran[i*
dim+j];
1143 if (INCLUDE_OK_POINTS){
1144 for (i = 0; i < nn - n; i++) {
1145 for (j = 0; j < dim2; j++) xcombined[(i + n)*dim2+j] = xran[(nzok0 - i)*
dim+j];
1154 if (
Verbose) fprintf(stderr,
" highlight cluster %d, n = %d\n",HIGHLIGHT_SET, n);
1157 for (i = 0; i < n; i++){
1158 if (grouping[i] == HIGHLIGHT_SET){
1160 for (j = 0; j <
dim; j++){
1161 xcombined[nz++] = x[i*
dim+j];
1165 for (i = 0; i < n; i++){
1166 if (grouping[i] != HIGHLIGHT_SET){
1167 for (j = 0; j <
dim; j++){
1168 xcombined[nz++] = x[i*
dim+j];
1172 assert(nz == n*
dim);
1173 for (i = 0; i < nh; i++){
1176 for (i = nh; i < n; i++){
1181 if (
Verbose) fprintf(stderr,
"nh = %d\n",nh);
1186 if (
get_tri(n + nrandom, dim2, xcombined, &nt, &Tp, &
E) != 0) {
1190 get_polygons(n, nrandom, dim2, grouping, nt, Tp,
E, nverts, x_poly,
1191 poly_lines, polys, polys_groups, poly_point_map, country_graph);
1198 if (grouping != grouping0)
free(grouping);
1199 if (x != x0)
free(x);
1203static void add_point(
int *n,
int igrp,
double **x,
int *nmax,
double point[],
int **groups){
1206 int old_nmax = *nmax;
1208 *x =
gv_recalloc(*x, 2 * old_nmax, 2 * *nmax,
sizeof(
double));
1209 *groups =
gv_recalloc(*groups, old_nmax, *nmax,
sizeof(
int));
1212 (*x)[(*n)*2] =
point[0];
1213 (*x)[(*n)*2+1] =
point[1];
1214 (*groups)[*n] = igrp;
1223 for (i = 0; i < n; i++){
1232 int n,
int dim,
double *x,
double *sizes,
1233 int *grouping,
SparseMatrix graph,
double bounding_box_margin,
int nrandom,
int *nart,
int nedgep,
1234 double shore_depth_tol,
1235 int *nverts,
double **x_poly,
1293 int N, nmax, i, j, k, igrp;
1294 int *groups, K = *nart;
1296 double avgsize[2], avgsz, h[2], p1, p0;
1303 K = (int) 10/(1+n/400.);
1307 int maxgp = grouping[0];
1308 int mingp = grouping[0];
1309 for (i = 0; i < n; i++) {
1310 maxgp =
MAX(maxgp, grouping[i]);
1311 mingp =
MIN(mingp, grouping[i]);
1313 fprintf(stderr,
"max grouping - min grouping + 1 = %d\n",maxgp - mingp + 1);
1319 bounding_box_margin, nrandom, nedgep,
1320 shore_depth_tol, nverts, x_poly, poly_lines, polys,
1321 polys_groups, poly_point_map, country_graph,
1328 for (i = 0; i < n; i++){
1329 for (j = 0; j < 2; j++) {
1330 avgsize[j] += sizes[i*
dim+j];
1333 for (i = 0; i < 2; i++) avgsize[i] /= n;
1334 avgsz = 0.5*(avgsize[0] + avgsize[1]);
1335 if (
Verbose) fprintf(stderr,
"avgsize = {%f, %f}\n",avgsize[0], avgsize[1]);
1339 groups =
gv_calloc(n + nmax,
sizeof(
int));
1340 for (i = 0; i < n; i++) {
1341 groups[i] = grouping[i];
1342 for (j = 0; j < 2; j++){
1343 X[i*2+j] = x[i*
dim+j];
1348 if (shore_depth_tol < 0) {
1349 shore_depth_tol = -(shore_depth_tol)*avgsz;
1350 }
else if (shore_depth_tol == 0){
1353 shore_depth_tol = sqrt(area / n);
1354 if (
Verbose) fprintf(stderr,
"setting shore length ======%f\n",shore_depth_tol);
1361 delta[0] = .5*avgsize[0]/K;
delta[1] = .5*avgsize[1]/K;
1365 for (i = 0; i < n; i++){
1367 for (j = 0; j < 2; j++) {
1371 nadded[j] = (int) K*sizes[i*
dim+j]/avgsz;
1377 h[0] = sizes[i*
dim]/nadded[0];
1381 for (k = 0; k < nadded[0] - 1; k++){
1391 for (k = 0; k < nadded[0] - 1; k++){
1400 h[1] = sizes[i*
dim + 1]/nadded[1];
1404 for (k = 0; k < nadded[1] - 1; k++){
1414 for (k = 0; k < nadded[1] - 1; k++){
1425 bounding_box_margin, nrandom, nedgep,
1426 shore_depth_tol, nverts, x_poly, poly_lines, polys,
1427 polys_groups, poly_point_map, country_graph,
void QuadTree_get_nearest(QuadTree qt, double *x, double *ymin, int *imin, double *min)
QuadTree QuadTree_new_from_point_list(int dim, int n, int max_level, double *coord)
void SparseMatrix_distance_matrix(SparseMatrix D0, double **dist0)
SparseMatrix SparseMatrix_from_coordinate_format(SparseMatrix A)
SparseMatrix SparseMatrix_transpose(SparseMatrix A)
SparseMatrix SparseMatrix_symmetrize(SparseMatrix A, bool pattern_symmetric_only)
SparseMatrix SparseMatrix_coordinate_form_add_entry(SparseMatrix A, int irn, int jcn, const void *val)
void SparseMatrix_export(FILE *f, SparseMatrix A)
void SparseMatrix_delete(SparseMatrix A)
SparseMatrix SparseMatrix_get_real_adjacency_matrix_symmetrized(SparseMatrix A)
SparseMatrix SparseMatrix_sort(SparseMatrix A)
int * SparseMatrix_weakly_connected_components(SparseMatrix A0, int *ncomp, int **comps)
SparseMatrix SparseMatrix_from_coordinate_format_not_compacted(SparseMatrix A)
SparseMatrix SparseMatrix_remove_diagonal(SparseMatrix A)
SparseMatrix SparseMatrix_new(int m, int n, int nz, int type, int format)
SparseMatrix SparseMatrix_from_dense(int m, int n, double *x)
static void agxbfree(agxbuf *xb)
free any malloced resources
static int agxbprint(agxbuf *xb, const char *fmt,...)
Printf-style output to an agxbuf.
static WUR char * agxbuse(agxbuf *xb)
Memory allocation wrappers that exit on failure.
static void * gv_recalloc(void *ptr, size_t old_nmemb, size_t new_nmemb, size_t size)
static void * gv_calloc(size_t nmemb, size_t size)
abstract graph C library, Cgraph API
void rgb2hex(float r, float g, float b, agxbuf *cstring, const char *opacity)
void country_graph_coloring(int seed, SparseMatrix A, int **p)
int * get_triangles(double *x, int n, int *tris)
static double dist(int dim, double *x, double *y)
#define X(prefix, name, str, type, subtype,...)
void vector_float_take(int n, float *v, int m, int *p, float **u)
double distance_cropped(double *x, int dim, int i, int j)
static double drand(void)
Agsym_t * agattr(Agraph_t *g, int kind, char *name, const char *value)
creates or looks up attributes of a graph
int agwrite(Agraph_t *g, void *chan)
Return 0 on success, EOF on failure.
Agraph_t * graph(char *name)
static int imin(int a, int b)
minimum of two integers
#define DEFINE_LIST(name, type)
static int make_map_internal(bool include_OK_points, int n, int dim, double *x0, int *grouping0, SparseMatrix graph, double bounding_box_margin, int nrandom, 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)
static void triangle_center(double x[], double y[], double z[], double c[])
void map_palette_optimal_coloring(char *color_scheme, SparseMatrix A0, float **rgb_r, float **rgb_g, float **rgb_b)
static void plot_dot_edges(FILE *f, SparseMatrix A)
static void get_polygons(int n, int nrandom, int dim, int *grouping, int nt, struct Triangle *Tp, SparseMatrix E, int *nverts, double **x_poly, SparseMatrix *poly_lines, SparseMatrix *polys, int **polys_groups, SparseMatrix *poly_point_map, SparseMatrix *country_graph)
static void add_point(int *n, int igrp, double **x, int *nmax, double point[], int **groups)
static SparseMatrix get_country_graph(int n, SparseMatrix A, int *groups, int GRP_RANDOM, int GRP_BBOX)
static int same_edge(int ecur, int elast, int *edge_table)
static void get_boundingbox(int n, int dim, double *x, double *width, double *bbox)
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)
static void get_poly_lines(int nt, SparseMatrix E, int ncomps, int *comps_ptr, int *comps, int *groups, SparseMatrix *poly_lines, int **polys_groups, int GRP_RANDOM, int GRP_BBOX)
static int get_tri(int n, int dim, double *x, int *nt, struct Triangle **T, SparseMatrix *E)
static SparseMatrix matrix_add_entry(SparseMatrix A, int i, int j, int val)
static void normal(double v[], double normal[])
static void cycle_print(int head, int *cycle, int *edge_table)
void map_optimal_coloring(int seed, SparseMatrix A, float *rgb_r, float *rgb_g, float *rgb_b)
static void plot_dot_labels(FILE *f, int n, int dim, double *x, char **labels, float *fsz)
static void dot_polygon(agxbuf *sbuff, doubles_t xp, doubles_t yp, double line_width, bool fill, const char *cstring)
static int get_poly_id(int ip, SparseMatrix point_poly_map)
static void get_polygon_solids(int nt, SparseMatrix E, int ncomps, int *comps_ptr, int *comps, SparseMatrix *polys)
static void plot_dot_polygons(agxbuf *sbuff, double line_width, const char *line_color, SparseMatrix polys, double *x_poly, int *polys_groups, float *r, float *g, float *b, const char *opacity)
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 void conn_comp(int n, SparseMatrix A, int *groups, SparseMatrix *poly_point_map)
#define neighbor(t, i, edim, elist)
static boxf bbox(Ppoly_t **obsp, int npoly, int *np)
int node_distinct_coloring(const char *color_scheme, int *lightness, bool weightedQ, SparseMatrix A0, double accuracy, int seed, int *cdim0, double **colors)
PATHUTIL_API COORD area2(Ppoint_t, Ppoint_t, Ppoint_t)
#define PRISIZE_T
PRIu64 alike for printing size_t
void stress_model(int dim, SparseMatrix B, double **x, int maxit_sm, int *flag)
static point center(point vertex[], size_t n)