Graphviz 12.0.1~dev.20240716.0800
Loading...
Searching...
No Matches
make_map.c File Reference
#include <assert.h>
#include <sparse/SparseMatrix.h>
#include <sparse/general.h>
#include <math.h>
#include <sparse/QuadTree.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include <cgraph/agxbuf.h>
#include <cgraph/alloc.h>
#include <cgraph/list.h>
#include <cgraph/prisize_t.h>
#include <cgraph/cgraph.h>
#include "make_map.h"
#include <sfdpgen/stress_model.h>
#include "country_graph_coloring.h"
#include <sparse/colorutil.h>
#include <neatogen/delaunay.h>
#include <edgepaint/lab.h>
#include <edgepaint/node_distinct_coloring.h>
Include dependency graph for make_map.c:

Go to the source code of this file.

Data Structures

struct  Triangle
 

Macros

#define STANDALONE
 

Functions

void map_palette_optimal_coloring (char *color_scheme, SparseMatrix A0, float **rgb_r, float **rgb_g, float **rgb_b)
 
void map_optimal_coloring (int seed, SparseMatrix A, float *rgb_r, float *rgb_g, float *rgb_b)
 
static int get_poly_id (int ip, SparseMatrix point_poly_map)
 
void improve_contiguity (int n, int dim, int *grouping, SparseMatrix poly_point_map, double *x, SparseMatrix graph)
 
static void normal (double v[], double normal[])
 
static void triangle_center (double x[], double y[], double z[], double c[])
 
static SparseMatrix matrix_add_entry (SparseMatrix A, int i, int j, int val)
 
static void plot_dot_edges (FILE *f, SparseMatrix A)
 
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 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)
 
static int get_tri (int n, int dim, double *x, int *nt, struct Triangle **T, SparseMatrix *E)
 
static SparseMatrix get_country_graph (int n, SparseMatrix A, int *groups, int GRP_RANDOM, int GRP_BBOX)
 
static void conn_comp (int n, SparseMatrix A, int *groups, SparseMatrix *poly_point_map)
 
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 void cycle_print (int head, int *cycle, int *edge_table)
 
static int same_edge (int ecur, int elast, int *edge_table)
 
static void get_polygon_solids (int nt, SparseMatrix E, int ncomps, int *comps_ptr, int *comps, SparseMatrix *polys)
 
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 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 add_point (int *n, int igrp, double **x, int *nmax, double point[], int **groups)
 
static void get_boundingbox (int n, int dim, double *x, double *width, double *bbox)
 
void 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)
 

Macro Definition Documentation

◆ STANDALONE

#define STANDALONE

Definition at line 11 of file make_map.c.

Function Documentation

◆ add_point()

static void add_point ( int *  n,
int  igrp,
double **  x,
int *  nmax,
double  point[],
int **  groups 
)
static

Definition at line 1197 of file make_map.c.

References gv_recalloc().

Referenced by make_map_from_rectangle_groups(), and nextpage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ conn_comp()

static void conn_comp ( int  n,
SparseMatrix  A,
int *  groups,
SparseMatrix poly_point_map 
)
static

Definition at line 464 of file make_map.c.

References A, B, FORMAT_COORD, FORMAT_CSR, free(), MATRIX_TYPE_INTEGER, MATRIX_TYPE_PATTERN, NULL, SparseMatrix_coordinate_form_add_entry(), SparseMatrix_delete(), SparseMatrix_from_coordinate_format(), SparseMatrix_new(), and SparseMatrix_weakly_connected_components().

Referenced by get_polygons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cycle_print()

static void cycle_print ( int  head,
int *  cycle,
int *  edge_table 
)
static

Definition at line 592 of file make_map.c.

References cycle_next, edge_head, edge_tail, and head.

Referenced by get_polygon_solids().

Here is the caller graph for this function:

◆ dot_polygon()

static void dot_polygon ( agxbuf sbuff,
doubles_t  xp,
doubles_t  yp,
double  line_width,
bool  fill,
const char *  cstring 
)
static

Definition at line 251 of file make_map.c.

References agxbprint(), NULL, and PRISIZE_T.

Referenced by plot_dot_polygons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_boundingbox()

static void get_boundingbox ( int  n,
int  dim,
double *  x,
double *  width,
double *  bbox 
)
static

Definition at line 1212 of file make_map.c.

References bbox().

Referenced by make_map_from_rectangle_groups().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_country_graph()

static SparseMatrix get_country_graph ( int  n,
SparseMatrix  A,
int *  groups,
int  GRP_RANDOM,
int  GRP_BBOX 
)
static

Definition at line 431 of file make_map.c.

References A, B, FORMAT_COORD, MATRIX_TYPE_INTEGER, MAX, MIN, NULL, SparseMatrix_coordinate_form_add_entry(), SparseMatrix_delete(), SparseMatrix_from_coordinate_format(), and SparseMatrix_new().

Referenced by get_polygons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_poly_id()

static int get_poly_id ( int  ip,
SparseMatrix  point_poly_map 
)
static

Definition at line 111 of file make_map.c.

References SparseMatrix_struct::ia, and SparseMatrix_struct::ja.

Referenced by improve_contiguity().

Here is the caller graph for this function:

◆ get_poly_lines()

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

Definition at line 496 of file make_map.c.

References A, E, FORMAT_COORD, free(), gv_calloc(), MATRIX_TYPE_INTEGER, neighbor, SparseMatrix_coordinate_form_add_entry(), SparseMatrix_delete(), SparseMatrix_from_coordinate_format_not_compacted(), and SparseMatrix_new().

Referenced by get_polygons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_polygon_solids()

static void get_polygon_solids ( int  nt,
SparseMatrix  E,
int  ncomps,
int *  comps_ptr,
int *  comps,
SparseMatrix polys 
)
static

Definition at line 617 of file make_map.c.

References SparseMatrix_struct::a, B, cycle_next, cycle_prev, cycle_print(), E, edge_head, edge_tail, FORMAT_COORD, free(), gv_calloc(), head, SparseMatrix_struct::ia, SparseMatrix_struct::ja, SparseMatrix_struct::m, MATRIX_TYPE_INTEGER, neighbor, SparseMatrix_struct::nz, same_edge(), SparseMatrix_coordinate_form_add_entry(), SparseMatrix_delete(), SparseMatrix_from_coordinate_format_not_compacted(), and SparseMatrix_new().

Referenced by get_polygons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_polygons()

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

Definition at line 869 of file make_map.c.

References Triangle::center, conn_comp(), E, free(), get_country_graph(), get_poly_lines(), get_polygon_solids(), gv_calloc(), MAX, NULL, and Verbose.

Referenced by make_map_internal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_tri()

static int get_tri ( int  n,
int  dim,
double *  x,
int *  nt,
struct Triangle **  T,
SparseMatrix E 
)
static

construct triangles

Always contains a self edge and is symmetric.

Parameters
nNumber of points
dimDimension, only first2D is used
xPoint j is stored x[j × dim] – x[j × dim + dim - 1]
nt[out] Number of triangles
T[out] triangles
E[out] A matrix of size n×n, if two points i > j are connected by an triangulation edge, and is neighboring two triangles t1 and t2, then A[i, j] is both t1 and t2
Returns
0 on success

Definition at line 395 of file make_map.c.

References A, B, center(), E, FORMAT_COORD, free(), get_triangles(), gv_calloc(), matrix_add_entry(), MATRIX_TYPE_INTEGER, NULL, SparseMatrix_delete(), SparseMatrix_from_coordinate_format_not_compacted(), SparseMatrix_new(), SparseMatrix_sort(), T, and triangle_center().

Referenced by make_map_internal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ improve_contiguity()

void improve_contiguity ( int  n,
int  dim,
int *  grouping,
SparseMatrix  poly_point_map,
double *  x,
SparseMatrix  graph 
)

Definition at line 115 of file make_map.c.

References D, dist(), distance_cropped(), get_poly_id(), graph(), maxit, SparseMatrix_delete(), SparseMatrix_get_real_adjacency_matrix_symmetrized(), SparseMatrix_transpose(), stress_model(), and Verbose.

Referenced by makeMap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_map_from_rectangle_groups()

void 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 
)

Definition at line 1225 of file make_map.c.

References add_point(), bbox(), delta, drand(), free(), get_boundingbox(), graph(), gv_calloc(), make_map_internal(), MAX, MIN, N, Verbose, and X.

Referenced by makeMap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_map_internal()

static void 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

Definition at line 942 of file make_map.c.

References area2(), drand(), E, free(), get_polygons(), get_tri(), graph(), gv_calloc(), gv_recalloc(), imin(), QuadTree_get_nearest(), QuadTree_new_from_point_list(), SparseMatrix_delete(), Verbose, xmax, xmin, and ymin.

Referenced by make_map_from_rectangle_groups().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ map_optimal_coloring()

void map_optimal_coloring ( int  seed,
SparseMatrix  A,
float *  rgb_r,
float *  rgb_g,
float *  rgb_b 
)

Definition at line 93 of file make_map.c.

References A, country_graph_coloring(), free(), NULL, seed, and vector_float_take().

Referenced by makeMap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ map_palette_optimal_coloring()

void map_palette_optimal_coloring ( char *  color_scheme,
SparseMatrix  A0,
float **  rgb_r,
float **  rgb_g,
float **  rgb_b 
)

Definition at line 34 of file make_map.c.

References A, dist(), free(), gv_calloc(), SparseMatrix_struct::m, node_distinct_coloring(), NULL, seed, SparseMatrix_delete(), SparseMatrix_distance_matrix(), SparseMatrix_export(), SparseMatrix_from_dense(), SparseMatrix_remove_diagonal(), and SparseMatrix_symmetrize().

Referenced by makeMap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ matrix_add_entry()

static SparseMatrix matrix_add_entry ( SparseMatrix  A,
int  i,
int  j,
int  val 
)
static

Definition at line 212 of file make_map.c.

References A, and SparseMatrix_coordinate_form_add_entry().

Referenced by get_tri().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ normal()

static void normal ( double  v[],
double  normal[] 
)
static

Definition at line 167 of file make_map.c.

References normal().

Referenced by normal(), and triangle_center().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plot_dot_edges()

static void plot_dot_edges ( FILE *  f,
SparseMatrix  A 
)
static

Definition at line 221 of file make_map.c.

References A.

Referenced by plot_dot_map().

Here is the caller graph for this function:

◆ plot_dot_labels()

static void plot_dot_labels ( FILE *  f,
int  n,
int  dim,
double *  x,
char **  labels,
float *  fsz 
)
static

Definition at line 236 of file make_map.c.

Referenced by plot_dot_map().

Here is the caller graph for this function:

◆ plot_dot_map()

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 
)

Definition at line 326 of file make_map.c.

References A, agattr(), AGEDGE, AGNODE, AGRAPH, agwrite(), agxbfree(), agxbuse(), NULL, plot_dot_edges(), plot_dot_labels(), and plot_dot_polygons().

Referenced by makeMap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plot_dot_polygons()

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 
)
static

Definition at line 278 of file make_map.c.

References SparseMatrix_struct::a, agxbfree(), agxbput(), agxbuse(), dot_polygon(), SparseMatrix_struct::ia, SparseMatrix_struct::ja, SparseMatrix_struct::m, SparseMatrix_struct::n, rgb2hex(), and Verbose.

Referenced by plot_dot_map().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ same_edge()

static int same_edge ( int  ecur,
int  elast,
int *  edge_table 
)
static

Definition at line 612 of file make_map.c.

References edge_head, and edge_tail.

Referenced by get_polygon_solids().

Here is the caller graph for this function:

◆ triangle_center()

static void triangle_center ( double  x[],
double  y[],
double  z[],
double  c[] 
)
static

Definition at line 176 of file make_map.c.

References normal(), and z.

Referenced by get_tri().

Here is the call graph for this function:
Here is the caller graph for this function: