]> granicus.if.org Git - graphviz/commitdiff
Integrate Yifan's edgepaint code into graphviz.
authorEmden R. Gansner <erg@alum.mit.edu>
Fri, 28 Feb 2014 20:05:44 +0000 (15:05 -0500)
committerEmden R. Gansner <erg@alum.mit.edu>
Fri, 28 Feb 2014 20:05:44 +0000 (15:05 -0500)
14 files changed:
cmd/edgepaint/edgepaint.1
cmd/edgepaint/edgepaintmain.c
lib/neatogen/overlap.h
lib/sfdpgen/Makefile.am
lib/sfdpgen/spring_electrical.c
lib/sparse/DotIO.c
lib/sparse/DotIO.h
lib/sparse/Makefile.am
lib/sparse/QuadTree.c [moved from lib/sfdpgen/QuadTree.c with 99% similarity]
lib/sparse/QuadTree.h [moved from lib/sfdpgen/QuadTree.h with 96% similarity]
lib/sparse/SparseMatrix.c
lib/sparse/SparseMatrix.h
lib/sparse/color_palette.c
lib/sparse/general.c

index cb62185b86fbe1944e269bcc02ee292a202841ca..411afbcd6c7106e791c00acd6e6618a1ea320654 100644 (file)
@@ -1,14 +1,6 @@
-.EQ
-delim $$
-.EN
-.de TQ
-.  br
-.  ns
-.  TP \\$1
-..
 .TH CLARIFY 1 "26 February 2014"
 .SH NAME
-clarify \- edge coloring to disambiguate crossing edges
+edgepaint \- edge coloring to disambiguate crossing edges
 .SH SYNOPSIS
 .B 
 [
@@ -22,48 +14,50 @@ clarify \- edge coloring to disambiguate crossing edges
 .I files
 ]
 .SH DESCRIPTION
-.B clarify
+.B edgepaint
 takes as input a graph in DOT format with node position information (the \fIpos\fP attribute) and
-color the edges.
+colors the edges in a manner making it easier to tell them apart.
 .SH OPTIONS
 The following options are supported:
 .TP
-.BI \-accuracy="e"
+.BI \-accuracy=  e 
 accuracy with which to find the maximally different coloring for each node with regard to its neighbors. Default e = 0.01. 
 .TP
-.BI \-angle="a"
-if edge crossing is less than that angle a, then make the edge colors different. Default a=15.
+.BI \-angle= a
+color two edges differently if their incidence angle is less than \fIa\fP degrees. Default \fIa\fP=15.
 .TP
-.BI \-random_seed="s"
-random seed to use. s must be an integer. If s is negative, we do -s iterations with different seeds and pick the best. 
+.BI \-random_seed= s 
+random seed to use. \fIs\fP must be an integer. If \fIs\fP is negative, we do |\fIs\fP| iterations with different seeds and pick the best. 
 .TP
-.BI \-lightness="l1,l2"
-only applied for LAB color scheme: l1 must be integer >=0, l2 integer <=100, and l1 <=l2. By default we use 0,70 
+.BI \-lightness= "l1,l2j"
+only applies for the "lab" color scheme: \fIl1\fP and \fIl2\fP must integers, with 0 <= \fIl1\fP <= \fIl2 <=100. By default, we use "0,70" 
 .TP
 .BI \-share_endpoint
-if this option is specified, edges that shares an end point are not considered in conflict if they are close to parallel but is on the opposite ends of the shared point (around 180 degree). 
+if this option is specified, edges that shares an node are not considered in conflict if they are close to parallel but 
+are on the opposite sides of the node (around 180 degree). 
 .TP
 .BI \-o " f"  
-write output to file f (if not speficied, stdout).
+write output to file f (default: stdout).
 .TP
-.BI \-color_scheme="c"
-color scheme. It is a string of either rgb, gray, lab (default), or of the form #ff0000,#aabbed,#eeffaa representing a color pallet, or one of the ColorBrewer palettes: ColorBrewer_accent_3, ColorBrewer_accent_4, ColorBrewer_accent_5, ColorBrewer_accent_6, ColorBrewer_accent_7, ColorBrewer_accent_8, ColorBrewer_blues_3, ColorBrewer_blues_4, ColorBrewer_blues_5, ColorBrewer_blues_6, ColorBrewer_blues_7, ColorBrewer_blues_8, ColorBrewer_blues_9, ColorBrewer_brbg_10, ColorBrewer_brbg_11, ColorBrewer_brbg_3, ColorBrewer_brbg_4, ColorBrewer_brbg_5, ColorBrewer_brbg_6, ColorBrewer_brbg_7, ColorBrewer_brbg_8, ColorBrewer_brbg_9, ColorBrewer_bugn_3, ColorBrewer_bugn_4, ColorBrewer_bugn_5, ColorBrewer_bugn_6, ColorBrewer_bugn_7, ColorBrewer_bugn_8, ColorBrewer_bugn_9, ColorBrewer_bupu_3, ColorBrewer_bupu_4, ColorBrewer_bupu_5, ColorBrewer_bupu_6, ColorBrewer_bupu_7, ColorBrewer_bupu_8, ColorBrewer_bupu_9, ColorBrewer_dark2_3, ColorBrewer_dark2_4, ColorBrewer_dark2_5, ColorBrewer_dark2_6, ColorBrewer_dark2_7, ColorBrewer_dark2_8, ColorBrewer_gnbu_3, ColorBrewer_gnbu_4, ColorBrewer_gnbu_5, ColorBrewer_gnbu_6, ColorBrewer_gnbu_7, ColorBrewer_gnbu_8, ColorBrewer_gnbu_9, ColorBrewer_greens_3, ColorBrewer_greens_4, ColorBrewer_greens_5, ColorBrewer_greens_6, ColorBrewer_greens_7, ColorBrewer_greens_8, ColorBrewer_greens_9, ColorBrewer_greys_3, ColorBrewer_greys_4, ColorBrewer_greys_5, ColorBrewer_greys_6, ColorBrewer_greys_7, ColorBrewer_greys_8, ColorBrewer_greys_9, ColorBrewer_oranges_3, ColorBrewer_oranges_4, ColorBrewer_oranges_5, ColorBrewer_oranges_6, ColorBrewer_oranges_7, ColorBrewer_oranges_8, ColorBrewer_oranges_9, ColorBrewer_orrd_3, ColorBrewer_orrd_4, ColorBrewer_orrd_5, ColorBrewer_orrd_6, ColorBrewer_orrd_7, ColorBrewer_orrd_8, ColorBrewer_orrd_9, ColorBrewer_paired_10, ColorBrewer_paired_11, ColorBrewer_paired_12, ColorBrewer_paired_3, ColorBrewer_paired_4, ColorBrewer_paired_5, ColorBrewer_paired_6, ColorBrewer_paired_7, ColorBrewer_paired_8, ColorBrewer_paired_9, ColorBrewer_pastel1_3, ColorBrewer_pastel1_4, ColorBrewer_pastel1_5, ColorBrewer_pastel1_6, ColorBrewer_pastel1_7, ColorBrewer_pastel1_8, ColorBrewer_pastel1_9, ColorBrewer_pastel2_3, ColorBrewer_pastel2_4, ColorBrewer_pastel2_5, ColorBrewer_pastel2_6, ColorBrewer_pastel2_7, ColorBrewer_pastel2_8, ColorBrewer_piyg_10, ColorBrewer_piyg_11, ColorBrewer_piyg_3, ColorBrewer_piyg_4, ColorBrewer_piyg_5, ColorBrewer_piyg_6, ColorBrewer_piyg_7, ColorBrewer_piyg_8, ColorBrewer_piyg_9, ColorBrewer_prgn_10, ColorBrewer_prgn_11, ColorBrewer_prgn_3, ColorBrewer_prgn_4, ColorBrewer_prgn_5, ColorBrewer_prgn_6, ColorBrewer_prgn_7, ColorBrewer_prgn_8, ColorBrewer_prgn_9, ColorBrewer_pubu_3, ColorBrewer_pubu_4, ColorBrewer_pubu_5, ColorBrewer_pubu_6, ColorBrewer_pubu_7, ColorBrewer_pubu_8, ColorBrewer_pubu_9, ColorBrewer_pubugn_3, ColorBrewer_pubugn_4, ColorBrewer_pubugn_5, ColorBrewer_pubugn_6, ColorBrewer_pubugn_7, ColorBrewer_pubugn_8, ColorBrewer_pubugn_9, ColorBrewer_puor_10, ColorBrewer_puor_11, ColorBrewer_puor_3, ColorBrewer_puor_4, ColorBrewer_puor_5, ColorBrewer_puor_6, ColorBrewer_puor_7, ColorBrewer_puor_8, ColorBrewer_puor_9, ColorBrewer_purd_3, ColorBrewer_purd_4, ColorBrewer_purd_5, ColorBrewer_purd_6, ColorBrewer_purd_7, ColorBrewer_purd_8, ColorBrewer_purd_9, ColorBrewer_purples_3, ColorBrewer_purples_4, ColorBrewer_purples_5, ColorBrewer_purples_6, ColorBrewer_purples_7, ColorBrewer_purples_8, ColorBrewer_purples_9, ColorBrewer_rdbu_10, ColorBrewer_rdbu_11, ColorBrewer_rdbu_3, ColorBrewer_rdbu_4, ColorBrewer_rdbu_5, ColorBrewer_rdbu_6, ColorBrewer_rdbu_7, ColorBrewer_rdbu_8, ColorBrewer_rdbu_9, ColorBrewer_rdgy_10, ColorBrewer_rdgy_11, ColorBrewer_rdgy_3, ColorBrewer_rdgy_4, ColorBrewer_rdgy_5, ColorBrewer_rdgy_6, ColorBrewer_rdgy_7, ColorBrewer_rdgy_8, ColorBrewer_rdgy_9, ColorBrewer_rdpu_3, ColorBrewer_rdpu_4, ColorBrewer_rdpu_5, ColorBrewer_rdpu_6, ColorBrewer_rdpu_7, ColorBrewer_rdpu_8, ColorBrewer_rdpu_9, ColorBrewer_rdylbu_10, ColorBrewer_rdylbu_11, ColorBrewer_rdylbu_3, ColorBrewer_rdylbu_4, ColorBrewer_rdylbu_5, ColorBrewer_rdylbu_6, ColorBrewer_rdylbu_7, ColorBrewer_rdylbu_8, ColorBrewer_rdylbu_9, ColorBrewer_rdylgn_10, ColorBrewer_rdylgn_11, ColorBrewer_rdylgn_3, ColorBrewer_rdylgn_4, ColorBrewer_rdylgn_5, ColorBrewer_rdylgn_6, ColorBrewer_rdylgn_7, ColorBrewer_rdylgn_8, ColorBrewer_rdylgn_9, ColorBrewer_reds_3, ColorBrewer_reds_4, ColorBrewer_reds_5, ColorBrewer_reds_6, ColorBrewer_reds_7, ColorBrewer_reds_8, ColorBrewer_reds_9, ColorBrewer_set1_3, ColorBrewer_set1_4, ColorBrewer_set1_5, ColorBrewer_set1_6, ColorBrewer_set1_7, ColorBrewer_set1_8, ColorBrewer_set1_9, ColorBrewer_set2_3, ColorBrewer_set2_4, ColorBrewer_set2_5, ColorBrewer_set2_6, ColorBrewer_set2_7, ColorBrewer_set2_8, ColorBrewer_set3_10, ColorBrewer_set3_11, ColorBrewer_set3_12, ColorBrewer_set3_3, ColorBrewer_set3_4, ColorBrewer_set3_5, ColorBrewer_set3_6, ColorBrewer_set3_7, ColorBrewer_set3_8, ColorBrewer_set3_9, ColorBrewer_spectral_10, ColorBrewer_spectral_11, ColorBrewer_spectral_3, ColorBrewer_spectral_4, ColorBrewer_spectral_5, ColorBrewer_spectral_6, ColorBrewer_spectral_7, ColorBrewer_spectral_8, ColorBrewer_spectral_9, ColorBrewer_ylgn_3, ColorBrewer_ylgn_4, ColorBrewer_ylgn_5, ColorBrewer_ylgn_6, ColorBrewer_ylgn_7, ColorBrewer_ylgn_8, ColorBrewer_ylgn_9, ColorBrewer_ylgnbu_3, ColorBrewer_ylgnbu_4, ColorBrewer_ylgnbu_5, ColorBrewer_ylgnbu_6, ColorBrewer_ylgnbu_7, ColorBrewer_ylgnbu_8, ColorBrewer_ylgnbu_9, ColorBrewer_ylorbr_3, ColorBrewer_ylorbr_4, ColorBrewer_ylorbr_5, ColorBrewer_ylorbr_6, ColorBrewer_ylorbr_7, ColorBrewer_ylorbr_8, ColorBrewer_ylorbr_9, ColorBrewer_ylorrd_3, ColorBrewer_ylorrd_4, ColorBrewer_ylorrd_5, ColorBrewer_ylorrd_6, ColorBrewer_ylorrd_7, ColorBrewer_ylorrd_8, ColorBrewer_ylorrd_9 
+.BI \-color_scheme= "c"
+specifies the color scheme.  This can be "rgb", "gray", "lab" (default);
+or a comma-separated list of RGB colors in hex (e.g., "#ff0000,#aabbed,#eeffaa") representing a palette;
+or a string specifying a Brewer color scheme (e.g., "accent7"; see http://www.graphviz.org/content/color-names#brewer).
 .TP
-.BI \-v " k"  
-determines the verbose level used for tracing the algorithm. The value \fIk\fP is optional; if not
-provided, the value 1 is used.
+.B \-v 
+turns on verbose mode.
 .TP
 .BI \-? 
 Print usage and exit.
 
 .SH BUGS
-At present, \fBclarify\fP does not handle graphs with loops or directed multiedges. So, a graph with edges
+At present, \fBedgepaint\fP does not handle graphs with loops or directed multiedges. So, a graph with edges
 \fIa -> b\fP and \fIb -> a\fP is acceptable, but not if it has edges \fIa -> b\fP and \fIa -> b\fP or
 \fIa -- b\fP and \fIa -- b\fP.
 .SH AUTHOR
 Yifan Hu <yifanhu@research.att.com>
 .SH "SEE ALSO"
 .PP
-gvmap(1)
+gvmap(1), sfdp(1), neato (1), dot(1)
 .PP
 
index 4f742b343641537ee8131fd45736ee3a87ff4215..d6b28f88f5ebc6f6e9e9974715bc4fcca5d6894a 100644 (file)
@@ -79,16 +79,16 @@ static void usage (char* cmd, int eval){
   fprintf(stderr, "Usage: %s <options> gv file with 2D coordinates.\n", cmd);
   fprintf(stderr, "Find a color assignment of the edges, such that edges that cross at small angle have as different as posible.\n");
   fprintf(stderr, "Options are: \n");
-  fprintf(stderr, "-accuracy=e: accuracy with which to find the maximally different coloring for each node with regard to its neighbors. Default 0.01.\n");
-  fprintf(stderr, "-angle=a: if edge crossing is less than that angle a, then make the edge colors different. Default 15.\n");
-  fprintf(stderr, "-random_seed=s: random seed to use. s must be an integer. If s is negative, we do -s iterations with different seeds and pick the best.\n");
-  fprintf(stderr, "-color_scheme=c: color scheme. It is a string of either rgb, gray, lab (default), or of the form #ff0000,#aabbed,#eeffaa representing a color pallet, or one of the ColorBrewer palettes: ");
-  color_palettes_name_print(stderr);
-  fprintf(stderr,\n");
-  fprintf(stderr, "-lightness=l1,l2: only applied for LAB color scheme: l1 must be integer >=0, l2 integer <=100, and l1 <=l2. By default we use 0,70\n");
-  fprintf(stderr, "-share_endpoint: if this option is specified, edges that shares an end point are not considered in conflict if they are close to parallel but is on the opposite ends of the shared point (around 180 degree).\n");
-  fprintf(stderr, "-v: verbose\n");
-  fprintf(stderr, "-o fname - write output to file fname (stdout)\n");
+  fprintf(stderr, " -accuracy=e      : accuracy with which to find the maximally different coloring for each node with regard to its neighbors. Default 0.01.\n");
+  fprintf(stderr, " -angle=a         : if edge crossing is less than that angle a, then make the edge colors different. Default 15.\n");
+  fprintf(stderr, " -random_seed=s   : random seed to use. s must be an integer. If s is negative, we do -s iterations with different seeds and pick the best.\n");
+  fprintf(stderr, " -color_scheme=c  : palette used. The string c should be \"rgb\", \"gray\", \"lab\" (default); or\n");
+  fprintf(stderr, "       a comma-separated list of RGB colors in hex (e.g., \"#ff0000,#aabbed,#eeffaa\"); or\n");
+  fprintf(stderr, "       a string specifying a Brewer color scheme (e.g., \"accent7\")\n");
+  fprintf(stderr, " -lightness=l1,l2 : only applied for LAB color scheme: l1 must be integer >=0, l2 integer <=100, and l1 <=l2. By default we use 0,70\n");
+  fprintf(stderr, " -share_endpoint  :  if this option is specified, edges that shares an end point are not considered in conflict if they are close to parallel but is on the opposite ends of the shared point (around 180 degree).\n");
+  fprintf(stderr, " -v               : verbose\n");
+  fprintf(stderr, " -o fname         :  write output to file fname (stdout)\n");
   exit(eval);
 }
 
index f309980a278ef24fae6e24c3692e93831440f658..9673f41316275bbc926048070babd64de5a714bd 100644 (file)
@@ -22,30 +22,30 @@ typedef  StressMajorizationSmoother OverlapSmoother;
 
 void OverlapSmoother_delete(OverlapSmoother sm);
 
-OverlapSmoother OverlapSmoother_new(SparseMatrix A, int m,
-                                    int dim, real lambda0, real *x, real *width, int include_original_graph, int neighborhood_only,
-                                    real *max_overlap, real *min_overlap,
-                                    int edge_labeling_scheme, int n_constr_nodes, int *constr_nodes, SparseMatrix A_constr, int shrink
-                                    );
+OverlapSmoother OverlapSmoother_new(SparseMatrix A, int m, 
+                                   int dim, real lambda0, real *x, real *width, int include_original_graph, int neighborhood_only, 
+                                   real *max_overlap, real *min_overlap,
+                                   int edge_labeling_scheme, int n_constr_nodes, int *constr_nodes, SparseMatrix A_constr, int shrink
+                                   );
 
 enum {ELSCHEME_NONE = 0, ELSCHEME_PENALTY, ELSCHEME_PENALTY2, ELSCHEME_STRAIGHTLINE_PENALTY, ELSCHEME_STRAIGHTLINE_PENALTY2};
 
 struct relative_position_constraints_struct{
   real constr_penalty; /* penalty parameter used in making edge labels as much on the line as possible */
-  int edge_labeling_scheme;/* specifying whether to treat node of the form |edgelabel|* as a special node representing an edge label.
-                               0 (no action, default), 1 (penalty based method to make that kind of node close to the center of its neighbor),
-                               2 (penalty based method to make that kind of node close to the "old" center of its neighbor),
-                               3 (two step process of overlap removal and straightening) */
+  int edge_labeling_scheme;/* specifying whether to treat node of the form |edgelabel|* as a special node representing an edge label. 
+                              0 (no action, default), 1 (penalty based method to make that kind of node close to the center of its neighbor), 
+                              2 (penalty based method to make that kind of node close to the "old" center of its neighbor), 
+                              3 (two step process of overlap removal and straightening) */
   int n_constr_nodes;/*n_constr_nodes: number of nodes that has constraints, these are nodes that is
-                       constrained to be close to the average of its neighbors.*/
+                      constrained to be close to the average of its neighbors.*/
   int *constr_nodes;/*constr_nodes: a list of nodes that need to be constrained. If NULL, unused.*/
   int *irn;/* working arrays to hold the Laplacian of the constrain graph */
   int *jcn;
   real *val;
   SparseMatrix A_constr; /*A_constr: neighbors of node i are in the row i of this matrix. i needs to sit
-                           in between these neighbors as much as possible. this must not be NULL
-                           if constr_nodes != NULL.*/
-
+                          in between these neighbors as much as possible. this must not be NULL
+                          if constr_nodes != NULL.*/
+  
 };
 
 typedef struct relative_position_constraints_struct*  relative_position_constraints;
index 70c5bb3c8ef9cce6318ad8119b02b3b053c7aaf6..e4baa45e5a8ebb068865432e9cad080694fc212f 100644 (file)
@@ -16,7 +16,7 @@ AM_CPPFLAGS = \
 noinst_HEADERS = sfdpinternal.h spring_electrical.h \
        sparse_solve.h post_process.h \
        stress_model.h uniform_stress.h \
-       QuadTree.h Multilevel.h sfdp.h PriorityQueue.h 
+       Multilevel.h sfdp.h PriorityQueue.h 
 
 if WITH_SFDP
 noinst_LTLIBRARIES = libsfdpgen_C.la
@@ -25,6 +25,6 @@ endif
 libsfdpgen_C_la_SOURCES = sfdpinit.c spring_electrical.c \
        sparse_solve.c post_process.c \
        stress_model.c uniform_stress.c \
-       QuadTree.c Multilevel.c PriorityQueue.c
+       Multilevel.c PriorityQueue.c
 
 EXTRA_DIST = sfdp.vcproj
index 0360a64659aaf474cfe780bc19de264fef5308e0..b55779d62062a4eb6f4a4fc9837d1644e2e4c8a3 100644 (file)
@@ -278,7 +278,7 @@ static real update_step(int adaptive_cooling, real step, real Fnorm, real Fnorm0
   if (Fnorm >= Fnorm0){
     step = cool*step;
   } else if (Fnorm > 0.95*Fnorm0){
-    step = step;
+    //    step = step;
   } else {
     step = 0.99*step/cool;
   }
@@ -471,7 +471,7 @@ void spring_electrical_embedding_fast(int dim, SparseMatrix A0, spring_electrica
   QuadTree qt = NULL;
   real counts[4], *force = NULL;
 #ifdef TIME
-  clock_t start, end, start0, start2;
+  clock_t start, end, start0;
   real qtree_cpu = 0, qtree_cpu0 = 0, qtree_new_cpu = 0, qtree_new_cpu0 = 0;
   real total_cpu = 0;
   start0 = clock();
@@ -513,7 +513,21 @@ void spring_electrical_embedding_fast(int dim, SparseMatrix A0, spring_electrica
 
   do {
 #ifdef TIME
-    start2 = clock();
+    //start2 = clock();
+#endif
+
+#ifdef GVIEWER
+    if (Gviewer){
+      char *lab;
+      lab = MALLOC(sizeof(char)*100);
+      sprintf(lab,"sfdp, iter=%d", iter);
+      gviewer_set_label(lab);
+      gviewer_reset_graph_coord(A, dim, x);
+      drawScene();
+      gviewer_dump_current_frame();
+      //if ((adaptive_cooling && iter%100 == 0) || (!adaptive_cooling && iter%10 == 0)) gviewer_dump_current_frame();
+      FREE(lab);
+    }
 #endif
 
     iter++;
@@ -600,14 +614,12 @@ void spring_electrical_embedding_fast(int dim, SparseMatrix A0, spring_electrica
 #endif
       oned_optimizer_train(qtree_level_optimizer, counts[0]+0.85*counts[1]+3.3*counts[2]);
     } else {   
-#ifdef DEBUG_PRINT
       if (Verbose) {
         fprintf(stderr, "\r                iter = %d, step = %f Fnorm = %f nz = %d  K = %f                                  ",iter, step, Fnorm, A->nz,K);
 #ifdef ENERGY
         fprintf(stderr, "energy = %f\n",spring_electrical_energy(dim, A, x, p, CRK, KP));
 #endif
       }
-#endif
     }
 
     step = update_step(adaptive_cooling, step, Fnorm, Fnorm0, cool);
@@ -978,6 +990,33 @@ void spring_electrical_embedding(int dim, SparseMatrix A0, spring_electrical_con
   f = MALLOC(sizeof(real)*dim);
   xold = MALLOC(sizeof(real)*dim*n); 
   do {
+
+    //#define VIS_MULTILEVEL
+#ifdef VIS_MULTILEVEL
+  {
+    FILE *f;
+    char fname[10000];
+    static int count = 0;
+    sprintf(fname, "/tmp/multilevel_%d",count++);
+    f = fopen(fname,"w");
+    export_embedding(f, dim, A, x, NULL);
+    fclose(f);
+  }
+#endif
+#ifdef GVIEWER
+    if (Gviewer){
+      char *lab;
+      lab = MALLOC(sizeof(char)*100);
+      sprintf(lab,"sfdp, adaptive_cooling = %d iter=%d", adaptive_cooling, iter);
+      gviewer_set_label(lab);
+      gviewer_reset_graph_coord(A, dim, x);
+      drawScene();
+      gviewer_dump_current_frame();
+      //if ((adaptive_cooling && iter%100 == 0) || (!adaptive_cooling && iter%10 == 0)) gviewer_dump_current_frame();
+      FREE(lab);
+    }
+#endif
+
     iter++;
     xold = MEMCPY(xold, x, sizeof(real)*dim*n);
     Fnorm0 = Fnorm;
@@ -1300,7 +1339,7 @@ void spring_maxent_embedding(int dim, SparseMatrix A0, SparseMatrix D, spring_el
     xold = MEMCPY(xold, x, sizeof(real)*dim*n);
     Fnorm0 = Fnorm;
     Fnorm = 0.;
-    nsuper_avg =- 0;
+    nsuper_avg = 0;
 #ifdef DEBUG
     stress = 0;
 #endif
@@ -1540,7 +1579,7 @@ void spring_electrical_spring_embedding(int dim, SparseMatrix A0, SparseMatrix D
     xold = MEMCPY(xold, x, sizeof(real)*dim*n);
     Fnorm0 = Fnorm;
     Fnorm = 0.;
-    nsuper_avg =- 0;
+    nsuper_avg = 0;
 
     if (USE_QT) {
       if (ctrl->use_node_weights){
index 12e658aecfa6c8261f205762d96ba56d05d192ca..cc784fdcbe981ef3ec1d694cd2c8417a17f0bf5a 100644 (file)
@@ -70,6 +70,51 @@ attach_embedding (Agraph_t* g, int dim, double sc, real *x)
 }
 #endif
 
+static void color_string(int slen, char *buf, int dim, real *color){
+  if (dim > 3 || dim < 1){
+    fprintf(stderr,"can only 1, 2 or 3 dimensional color space. with color value between 0 to 1\n");
+    assert(0);
+  }
+  assert(slen >= 3);
+  if (dim == 3){
+    sprintf(buf,"#%02x%02x%02x", MIN((unsigned int)(color[0]*255),255), 
+           MIN((unsigned int) (color[1]*255), 255), MIN((unsigned int)(color[2]*255), 255));
+  } else if (dim == 1){
+    sprintf(buf,"#%02x%02x%02x", MIN((unsigned int)(color[0]*255),255), 
+           MIN((unsigned int) (color[0]*255), 255), MIN((unsigned int)(color[0]*255), 255));
+  } else if (dim == 2){
+    sprintf(buf,"#%02x%02x%02x", MIN((unsigned int)(color[0]*255),255), 
+           0, MIN((unsigned int)(color[1]*255), 255));
+  }
+}
+
+void attach_edge_colors(Agraph_t* g, int dim, real *colors){
+  /* colors is array of dim*nedges, with color for edge i at colors[dim*i, dim(i+1))
+   */
+  Agsym_t* sym = agattr(g, AGEDGE, "color", 0); 
+  Agedge_t* e;
+  Agnode_t* n;
+  enum {slen = 1024};
+  char buf[slen];
+  int row, col;
+  int ie = 0;
+
+  if (!sym)
+    sym = agattr (g, AGEDGE, "color", "");
+
+  for (n = agfstnode (g); n; n = agnxtnode (g, n)) {
+    row = ND_id(n);
+    for (e = agfstout (g, n); e; e = agnxtout (g, e)) {
+      col = ND_id(aghead(e));
+      if (row == col) continue;
+      color_string(slen, buf, dim, colors + ie*dim);
+      agxset(e, sym, buf);
+      ie++;
+    }
+  }
+
+}
+
 /* SparseMatrix_read_dot:
  * Wrapper for reading dot graph from file
  */
@@ -109,7 +154,7 @@ SparseMatrix_import_dot (Agraph_t* g, int dim, real **label_sizes, real **x, int
   if (!g) return NULL;
   nnodes = agnnodes (g);
   nedges = agnedges (g);
-  if (format != FORMAT_CSR) {
+  if (format != FORMAT_CSR && format != FORMAT_COORD) {
     fprintf (stderr, "Format %d not supported\n", format);
     exit (1);
   }
@@ -119,9 +164,17 @@ SparseMatrix_import_dot (Agraph_t* g, int dim, real **label_sizes, real **x, int
   for (n = agfstnode (g); n; n = agnxtnode (g, n))
     ND_id(n) = i++;
 
-  I = N_NEW(nedges, int);
-  J = N_NEW(nedges, int);
-  val = N_NEW(nedges, real);
+  if (format == FORMAT_COORD){
+    A = SparseMatrix_new(i, i, nedges, MATRIX_TYPE_REAL, format);
+    A->nz = nedges;
+    I = A->ia;
+    J = A->ja;
+    val = (real*) A->a;
+  } else {
+    I = N_NEW(nedges, int);
+    J = N_NEW(nedges, int);
+    val = N_NEW(nedges, real);
+  }
 
   sym = agattr(g, AGEDGE, "weight", NULL); 
   if (D) {
@@ -244,14 +297,16 @@ SparseMatrix_import_dot (Agraph_t* g, int dim, real **label_sizes, real **x, int
   else if (x)
     agerr (AGERR, "Error: graph %s has missing \"pos\" information", agnameof(g));
 
-  A = SparseMatrix_from_coordinate_arrays(nedges, nnodes, nnodes, I, J, val, type, sz);
+  if (format == FORMAT_CSR) A = SparseMatrix_from_coordinate_arrays(nedges, nnodes, nnodes, I, J, val, type, sz);
   if (edge_label_nodes) *n_edge_label_nodes = nedge_nodes;
 
   if (D) *D = SparseMatrix_from_coordinate_arrays(nedges, nnodes, nnodes, I, J, valD, type, sz);
 
-  FREE(I);
-  FREE(J);
-  FREE(val);
+  if (format != FORMAT_COORD){
+    FREE(I);
+    FREE(J);
+    FREE(val);
+  }
   if (valD) FREE(valD);
 
   return A;
@@ -264,6 +319,52 @@ static real dist(int dim, real *x, real *y){
   return sqrt(d);
 }
 
+/* get spline info */
+int Import_dot_splines(Agraph_t* g, int *ne, char ***xsplines){
+  /* get the list of splines for the edges in the order they appear, and store as a list of strings in xspline.
+     If *xsplines = NULL, it will be allocated. On exit (*xsplines)[i] is the control point string for the i-th edge. This string
+     is of the form "x1,y1 x2,y2...", the two end points of the edge is not included per Dot format 
+     Return 1 if success. 0 if not.
+  */
+  Agnode_t* n;
+  Agedge_t* e;
+  Agsym_t *sym;
+  int nedges;
+  int i;
+
+  if (!g){
+    return 0;
+  }
+
+  *ne = nedges = agnedges (g);
+
+  /* Assign node ids */
+  i = 0;
+  for (n = agfstnode (g); n; n = agnxtnode (g, n))
+    ND_id(n) = i++;
+
+  sym = agattr(g, AGNODE, "pos", 0); 
+  if (!sym) return 0;
+
+  if (!(*xsplines)) *xsplines = malloc(sizeof(char*)*nedges);
+
+  i = 0;
+  for (n = agfstnode (g); n; n = agnxtnode (g, n)) {
+    for (e = agfstout (g, n); e; e = agnxtout (g, e)) {
+      /* edge weight */
+      if (sym) {
+       char *pos = agxget (e, sym);
+       (*xsplines)[i] = malloc(sizeof(char)*(strlen(pos)+1));
+       strcpy((*xsplines)[i], pos);
+      } else {
+       (*xsplines)[i] = NULL;
+      }
+      i++;
+    }
+  }
+  return 1;
+}
+
 void edgelist_export(FILE* f, SparseMatrix A, int dim, real *x){
   int n = A->m, *ia = A->ia, *ja = A->ja;
   int i, j, len;
index 00258b03bb041d13b081b55bb8d6f04d167eedea..934693b23d2f08b16de5cd8e792720f866581f33 100644 (file)
@@ -25,6 +25,7 @@ extern void setDotNodeID (Agnode_t* n, int v);
 extern int getDotNodeID (Agnode_t* n);
 
 /* extern void attach_embedding(Agraph_t *g, int dim, double sc, real *x); */
+extern void attach_edge_colors(Agraph_t* g, int dim, real *colors);
 extern SparseMatrix SparseMatrix_import_dot(Agraph_t* g, int dim, real **label_sizes, real **x, int *n_edge_label_nodes,
                                            int **edge_label_nodes, int format, SparseMatrix *D);
 extern Agraph_t* makeDotGraph (SparseMatrix, char *title, int dim, real *x, int with_color, int with_label, int use_matrix_value);
@@ -39,4 +40,6 @@ SparseMatrix Import_coord_clusters_from_dot(Agraph_t* g, int maxcluster, int dim
 void Dot_SetClusterColor(Agraph_t* g, float *rgb_r,  float *rgb_g,  float *rgb_b, int *clustering);
 void attached_clustering(Agraph_t* g, int maxcluster, int clustering_scheme);
 
+int Import_dot_splines(Agraph_t* g, int *ne, char ***xsplines);
+
 #endif
index 376046d80247a95de31ba27451e16684c0abeff1..77472634f7603ea2afd9811830bb06f1b2da3986 100644 (file)
@@ -8,11 +8,11 @@ AM_CPPFLAGS = \
        -I$(top_srcdir)/lib/cdt 
 
 noinst_HEADERS = SparseMatrix.h general.h BinaryHeap.h IntStack.h vector.h DotIO.h \
-    LinkedList.h colorutil.h color_palette.h mq.h clustering.h
+    LinkedList.h colorutil.h color_palette.h mq.h clustering.h QuadTree.h 
 
 noinst_LTLIBRARIES = libsparse_C.la
 
 libsparse_C_la_SOURCES = SparseMatrix.c general.c BinaryHeap.c IntStack.c vector.c DotIO.c \
-    LinkedList.c colorutil.c color_palette.c mq.c clustering.c
+    LinkedList.c colorutil.c color_palette.c mq.c clustering.c QuadTree.c
 
 EXTRA_DIST = gvsparse.vcproj
similarity index 99%
rename from lib/sfdpgen/QuadTree.c
rename to lib/sparse/QuadTree.c
index bd6b289d4a445de5e138f8bc800bafbd6adeb7f9..aeb14254d81b9a3984ad347cdbacc36a16856a00 100644 (file)
@@ -373,6 +373,7 @@ QuadTree QuadTree_new_from_point_list(int dim, int n, int max_level, real *coord
     center[i] = (xmin[i] + xmax[i])*0.5;
     width = MAX(width, xmax[i] - xmin[i]);
   }
+  if (width == 0) width = 0.00001;/* if we only have one point, width = 0! */
   width *= 0.52;
   qt = QuadTree_new(dim, center, width, max_level);
 
@@ -446,7 +447,7 @@ static int QuadTree_get_quadrant(int dim, real *center, real *coord){
   return d;
 }
 
-static QuadTree QuadTree_new_in_quadrant(int dim, real *center, real width, int max_level, int i){
+QuadTree QuadTree_new_in_quadrant(int dim, real *center, real width, int max_level, int i){
   /* a new quadtree in quadrant i of the original cell. The original cell is centered at 'center".
      The new cell have width "width".
    */
similarity index 96%
rename from lib/sfdpgen/QuadTree.h
rename to lib/sparse/QuadTree.h
index bbd90485934f658a1458ed28fc703dc0e66c10e1..358cb78850cf1173b216ae9af3baa4250c1d49dd 100644 (file)
@@ -59,5 +59,6 @@ void QuadTree_get_repulsive_force(QuadTree qt, real *force, real *x, real bh, re
 /* find the nearest point and put in ymin, index in imin and distance in min */
 void QuadTree_get_nearest(QuadTree qt, real *x, real *ymin, int *imin, real *min, int *flag);
 
+QuadTree QuadTree_new_in_quadrant(int dim, real *center, real width, int max_level, int i);
 
 #endif
index c077ce92627bd552b4e7bea19f89b14b4b81a91e..914824cc92dd448662f6b3ed5325c86de082495c 100644 (file)
@@ -622,15 +622,8 @@ static void SparseMatrix_export_csr(FILE *f, SparseMatrix A){
 
 }
 
-void SparseMatrix_export_binary(char *name, SparseMatrix A, int *flag){
-  FILE *f;
+void SparseMatrix_export_binary_fp(FILE *f, SparseMatrix A){
 
-  *flag = 0;
-  f = fopen(name, "wb");
-  if (!f) {
-    *flag = 1;
-    return;
-  }
   fwrite(&(A->m), sizeof(int), 1, f);
   fwrite(&(A->n), sizeof(int), 1, f);
   fwrite(&(A->nz), sizeof(int), 1, f);
@@ -646,21 +639,30 @@ void SparseMatrix_export_binary(char *name, SparseMatrix A, int *flag){
   }
   fwrite(A->ja, sizeof(int), A->nz, f);
   if (A->size > 0) fwrite(A->a, A->size, A->nz, f);
+
+}
+
+void SparseMatrix_export_binary(char *name, SparseMatrix A, int *flag){
+  FILE *f;
+
+  *flag = 0;
+  f = fopen(name, "wb");
+  if (!f) {
+    *flag = 1;
+    return;
+  }
+  SparseMatrix_export_binary_fp(f, A);
   fclose(f);
 
 }
 
 
 
-SparseMatrix SparseMatrix_import_binary(char *name){
+SparseMatrix SparseMatrix_import_binary_fp(FILE *f){
   SparseMatrix A = NULL;
   int m, n, nz, nzmax, type, format, property, iread;
   size_t sz;
-  FILE *f;
-
-  f = fopen(name, "rb");
 
-  if (!f) return NULL;
   iread = fread(&m, sizeof(int), 1, f);
   if (iread != 1) return NULL;
   iread = fread(&n, sizeof(int), 1, f);
@@ -700,6 +702,16 @@ SparseMatrix SparseMatrix_import_binary(char *name){
   return A;
 }
 
+
+SparseMatrix SparseMatrix_import_binary(char *name){
+  SparseMatrix A = NULL;
+  FILE *f;
+  f = fopen(name, "rb");
+
+  A = SparseMatrix_import_binary_fp(f);
+  return A;
+}
+
 static void SparseMatrix_export_coord(FILE *f, SparseMatrix A){
   int *ia, *ja;
   real *a;
@@ -1342,23 +1354,42 @@ SparseMatrix SparseMatrix_scaled_by_vector(SparseMatrix A, real *v, int apply_to
 SparseMatrix SparseMatrix_multiply_by_scaler(SparseMatrix A, real s){
   /* A scaled by a number */
   int i, j, *ia, m;
-  real *a;
+  real *a, *b = NULL;
+  int *ai;
   assert(A->format == FORMAT_CSR);
-  assert(A->type == MATRIX_TYPE_REAL);
-
-  a = (real*) A->a;
-  ia = A->ia;
 
-  m = A->m;
-
-
-
-
-
-  for (i = 0; i < m; i++){
-    for (j = ia[i]; j < ia[i+1]; j++){
-      a[j] *= s;
+  switch (A->type){
+  case MATRIX_TYPE_INTEGER:
+    b = MALLOC(sizeof(real)*A->nz);
+    ai = (int*) A->a;
+    for (i = 0; i < A->nz; i++) b[i] = ai[i];
+    FREE(A->a);
+    A->a = b;
+    A->type = MATRIX_TYPE_REAL;
+  case MATRIX_TYPE_REAL:
+    a = (real*) A->a;
+    ia = A->ia;
+    m = A->m;
+    for (i = 0; i < m; i++){
+      for (j = ia[i]; j < ia[i+1]; j++){
+       a[j] *= s;
+      }
+    }
+    break;
+  case MATRIX_TYPE_COMPLEX:
+    a = (real*) A->a;
+    ia = A->ia;
+    m = A->m;
+    for (i = 0; i < m; i++){
+      for (j = ia[i]; j < ia[i+1]; j++){
+       a[2*j] *= s;
+       a[2*j+1] *= s;
+      }
     }
+
+    break;
+  default:
+    fprintf(stderr,"warning: scaling of matrix this type is not supported\n");
   }
 
   return A;
@@ -1788,6 +1819,26 @@ SparseMatrix SparseMatrix_sum_repeat_entries(SparseMatrix A, int what_to_sum){
          sta = ia[i+1];
          ia[i+1] = nz;
        }
+      } else if (what_to_sum == SUM_IMGINARY_KEEP_LAST_REAL){
+       /* merge {i,j,R1,I1} and {i,j,R2,I2} into {i,j,R1+R2,I2}*/
+       nz = 0;
+       sta = ia[0];
+       for (i = 0; i < A->m; i++){
+         for (j = sta; j < ia[i+1]; j++){
+           if (mask[ja[j]] < ia[i]){
+             ja[nz] = ja[j];
+             a[2*nz] = a[2*j];
+             a[2*nz+1] = a[2*j+1];
+             mask[ja[j]] = nz++;
+           } else {
+             assert(ja[mask[ja[j]]] == ja[j]);
+             a[2*mask[ja[j]]] += a[2*j];
+             a[2*mask[ja[j]]+1] = a[2*j+1];
+           }
+         }
+         sta = ia[i+1];
+         ia[i+1] = nz;
+        }
       } else if (what_to_sum == SUM_REPEATED_REAL_PART){
        int ymin, ymax, id;
        ymax = ymin = a[1];
@@ -2245,6 +2296,61 @@ SparseMatrix SparseMatrix_normalize_by_row(SparseMatrix A){
 }
 
 
+SparseMatrix SparseMatrix_to_complex(SparseMatrix A){
+  int i, *ia, *ja;
+  
+  if (!A) return A;
+  if (A->format != FORMAT_CSR) {
+#ifdef DEBUG
+    printf("only CSR format supported.\n");
+#endif
+    return A;
+  }
+
+  ia = A->ia;
+  ja = A->ja;
+  switch (A->type){
+  case MATRIX_TYPE_REAL:{
+    real *a = (real*) A->a;
+    int nz = A->nz;
+    A->a = a = REALLOC(a, 2*sizeof(real)*nz);
+    for (i = nz - 1; i >= 0; i--){
+      a[2*i] = a[i];
+      a[2*i - 1] = 0;
+    }
+    A->type = MATRIX_TYPE_COMPLEX;
+    A->size = 2*sizeof(real);
+    break;
+  }
+  case MATRIX_TYPE_COMPLEX:{
+    break;
+  }
+  case MATRIX_TYPE_INTEGER:{
+    int *a = (int*) A->a;
+    int nz = A->nz;
+    A->a = MALLOC(2*sizeof(real)*nz);
+    real *aa = A->a;
+    for (i = nz - 1; i >= 0; i--){
+      aa[2*i] = (real) a[i];
+      aa[2*i - 1] = 0;
+    }
+    A->type = MATRIX_TYPE_COMPLEX;
+    A->size = 2*sizeof(real);
+    FREE(a);
+    break;
+  }
+  case MATRIX_TYPE_PATTERN:{
+    break;
+  }
+  case MATRIX_TYPE_UNKNOWN:
+    return NULL;
+  default:
+    return NULL;
+  }
+
+  return A;
+}
+
 
 SparseMatrix SparseMatrix_apply_fun(SparseMatrix A, double (*fun)(double x)){
   int i, j;
@@ -3155,8 +3261,8 @@ SparseMatrix SparseMatrix_largest_component(SparseMatrix A){
 
 }
 
-SparseMatrix SparseMatrix_delete_empty_columns(SparseMatrix A, int **new2old, int *nnew, int inplace){
-  /* delete empty columns in A. After than number of columns will be nnew, and 
+SparseMatrix SparseMatrix_delete_sparse_columns(SparseMatrix A, int threshold, int **new2old, int *nnew, int inplace){
+  /* delete sparse columns of threshold or less entries in A. After than number of columns will be nnew, and 
      the mapping from new matrix column to old matrix column is new2old.
      On entry, if new2old is NULL, it is allocated.
   */
@@ -3171,7 +3277,7 @@ SparseMatrix SparseMatrix_delete_empty_columns(SparseMatrix A, int **new2old, in
   B = SparseMatrix_transpose(A);
   ia = B->ia; ja = B->ja;
   for (i = 0; i < B->m; i++){
-    if (ia[i+1] > ia[i]){
+    if (ia[i+1] > ia[i] + threshold){
       (*nnew)++;
     }
   }
@@ -3179,7 +3285,7 @@ SparseMatrix SparseMatrix_delete_empty_columns(SparseMatrix A, int **new2old, in
 
   *nnew = 0;
   for (i = 0; i < B->m; i++){
-    if (ia[i+1] > ia[i]){
+    if (ia[i+1] > ia[i] + threshold){
       (*new2old)[*nnew] = i;
       old2new[i] = *nnew;
       (*nnew)++;
@@ -3205,6 +3311,10 @@ SparseMatrix SparseMatrix_delete_empty_columns(SparseMatrix A, int **new2old, in
 
 }
 
+SparseMatrix SparseMatrix_delete_empty_columns(SparseMatrix A, int **new2old, int *nnew, int inplace){
+  return SparseMatrix_delete_sparse_columns(A, 0, new2old, nnew, inplace);
+}
+
 SparseMatrix SparseMatrix_set_entries_to_real_one(SparseMatrix A){
   real *a;
   int i;
@@ -3282,6 +3392,7 @@ int SparseMatrix_k_centers(SparseMatrix D0, int weighted, int K, int root, int *
   real *dist = NULL;
   int nlist, *list = NULL;
   int flag = 0, i, j, k, nlevel;
+  int check_connected = FALSE;
 
   if (!SparseMatrix_is_symmetric(D, FALSE)){
     D = SparseMatrix_symmetrize(D, FALSE);
@@ -3291,13 +3402,14 @@ int SparseMatrix_k_centers(SparseMatrix D0, int weighted, int K, int root, int *
 
   dist_min = MALLOC(sizeof(real)*n);
   dist_sum = MALLOC(sizeof(real)*n);
+  for (i = 0; i < n; i++) dist_min[i] = -1;
   for (i = 0; i < n; i++) dist_sum[i] = 0;
   if (!(*centers)) *centers = MALLOC(sizeof(int)*K);
   if (!(*dist0)) *dist0 = MALLOC(sizeof(real)*K*n);
   if (!weighted){
     dist = MALLOC(sizeof(real)*n);
     SparseMatrix_pseudo_diameter_unweighted(D, root, aggressive, &end1, &end2, &connectedQ);
-    if (!connectedQ) {
+    if (check_connected && !connectedQ) {
       flag =  K_CENTER_DISCONNECTED;
       goto RETURN;
     }
@@ -3306,7 +3418,7 @@ int SparseMatrix_k_centers(SparseMatrix D0, int weighted, int K, int root, int *
       (*centers)[k] = root;
       //      fprintf(stderr,"k = %d, root = %d\n",k, root+1);
       SparseMatrix_level_sets(D, root, &nlevel, &levelset_ptr, &levelset, &mask, TRUE);
-      assert(levelset_ptr[nlevel] == n);
+      if (check_connected) assert(levelset_ptr[nlevel] == n);
       for (i = 0; i < nlevel; i++) {
        for (j = levelset_ptr[i]; j < levelset_ptr[i+1]; j++){
          (*dist0)[k*n+levelset[j]] = i;
@@ -3324,6 +3436,8 @@ int SparseMatrix_k_centers(SparseMatrix D0, int weighted, int K, int root, int *
       dsum = dist_sum[0];
       root = 0;
       for (i = 0; i < n; i++) {
+       if (!check_connected && dist_min[i] < 0) continue;/* if the graph is disconnected, then we can not count on every node to be in level set. 
+                                                            Usee dist_min<0 to identify those not in level set */
        if (dmax < dist_min[i] || (dmax == dist_min[i] && dsum < dist_sum[i])){/* tie break with avg dist */
          dmax = dist_min[i];
          dsum = dist_sum[i];
@@ -3333,7 +3447,7 @@ int SparseMatrix_k_centers(SparseMatrix D0, int weighted, int K, int root, int *
     }
  } else {
     SparseMatrix_pseudo_diameter_weighted(D, root, aggressive, &end1, &end2, &connectedQ);
-    if (!connectedQ) return K_CENTER_DISCONNECTED;
+    if (check_connected && !connectedQ) return K_CENTER_DISCONNECTED;
     root = end1;
     list = MALLOC(sizeof(int)*n);
 
@@ -3346,7 +3460,7 @@ int SparseMatrix_k_centers(SparseMatrix D0, int weighted, int K, int root, int *
        flag = K_CENTER_MEM;
        goto RETURN;
       }
-      assert(nlist == n);
+      if (check_connected) assert(nlist == n);
       for (i = 0; i < n; i++){
        if (k == 0){
          dist_min[i] = dist[i];
@@ -3361,6 +3475,8 @@ int SparseMatrix_k_centers(SparseMatrix D0, int weighted, int K, int root, int *
       dsum = dist_sum[0];
       root = 0;
       for (i = 0; i < n; i++) {
+       if (!check_connected && dist_min[i] < 0) continue;/* if the graph is disconnected, then we can not count on every node to be in level set. 
+                                                            Usee dist_min<0 to identify those not in level set */
        if (dmax < dist_min[i] || (dmax == dist_min[i] && dsum < dist_sum[i])){/* tie break with avg dist */
          dmax = dist_min[i];
          dsum = dist_sum[i];
index 62b1b0a64c4e6114bea1662d2e4f6e9c194f7ed9..0a6dacb44985b3caacb06fec3b84b764de3fc404 100644 (file)
@@ -48,7 +48,7 @@ SparseMatrix SparseMatrix_general_new(int m, int n, int nz, int type, size_t sz,
 
 /* this version sum repeated entries */
 SparseMatrix SparseMatrix_from_coordinate_format(SparseMatrix A);
-/* what_to_sum is SUM_REPEATED_NONE, SUM_REPEATED_ALL, SUM_REPEATED_REAL_PART, SUM_REPEATED_IMAGINARY_PART*/
+/* what_to_sum is SUM_REPEATED_NONE, SUM_REPEATED_ALL, SUM_REPEATED_REAL_PART, SUM_REPEATED_IMAGINARY_PART, SUM_IMGINARY_KEEP_LAST_REAL*/
 SparseMatrix SparseMatrix_from_coordinate_format_not_compacted(SparseMatrix A, int what_to_sum);
 
 SparseMatrix SparseMatrix_from_coordinate_arrays(int nz, int m, int n, int *irn, int *jcn, void *val, int type, size_t sz);
@@ -60,8 +60,10 @@ void SparseMatrix_print(char *, SparseMatrix A);/*print to stdout in Mathematica
 void SparseMatrix_export(FILE *f, SparseMatrix A);/* export into MM format except the header */
 
 SparseMatrix SparseMatrix_import_binary(char *name);
+SparseMatrix SparseMatrix_import_binary_fp(FILE *f);/* import into a preopenned file */
 
 void SparseMatrix_export_binary(char *name, SparseMatrix A, int *flag);
+void SparseMatrix_export_binary_fp(FILE *f, SparseMatrix A);/* export binary into a file preopened */
 
 void SparseMatrix_delete(SparseMatrix A);
 
@@ -74,8 +76,10 @@ SparseMatrix SparseMatrix_multiply3(SparseMatrix A, SparseMatrix B, SparseMatrix
    if what_to_sum = SUM_REPEATED_IMAGINARY_PART, we find entries {i,j,x + i y} and sum the y's if {i,j,Round(x)} are the same
    For other matrix, what_to_sum = SUM_REPEATED_REAL_PART is the same as what_to_sum = SUM_REPEATED_IMAGINARY_PART
    or what_to_sum = SUM_REPEATED_ALL
+   if what_to_sum = SUM_IMGINARY_KEEP_LAST_REAL, we merge {i,j,R1,I1} and {i,j,R2,I2} into {i,j,R1+R2,I2}. Useful if I1 and I2 are time stamps, 
+   .   and we use this to indicate that a user watched R1+R2 seconds, last watch is I2.
 */
-enum {SUM_REPEATED_NONE = 0, SUM_REPEATED_ALL, SUM_REPEATED_REAL_PART, SUM_REPEATED_IMAGINARY_PART};
+enum {SUM_REPEATED_NONE = 0, SUM_REPEATED_ALL, SUM_REPEATED_REAL_PART, SUM_REPEATED_IMAGINARY_PART, SUM_IMGINARY_KEEP_LAST_REAL};
 SparseMatrix SparseMatrix_sum_repeat_entries(SparseMatrix A, int what_to_sum);
 SparseMatrix SparseMatrix_coordinate_form_add_entries(SparseMatrix A, int nentries, int *irn, int *jcn, void *val);
 int SparseMatrix_is_symmetric(SparseMatrix A, int test_pattern_symmetry_only);
@@ -121,7 +125,9 @@ SparseMatrix SparseMatrix_to_square_matrix(SparseMatrix A, int bipartite_options
 
 SparseMatrix SparseMatrix_largest_component(SparseMatrix A);
 
+/* columns with <= threhold entries are deleted */
 SparseMatrix SparseMatrix_delete_empty_columns(SparseMatrix A, int **new2old, int *nnew, int inplace);
+SparseMatrix SparseMatrix_delete_sparse_columns(SparseMatrix A, int threshold, int **new2old, int *nnew, int inplace);
 
 SparseMatrix SparseMatrix_sort(SparseMatrix A);
 
@@ -158,6 +164,14 @@ void SparseMatrix_page_rank(SparseMatrix A, real teleport_probablity, int weight
 #define SparseMatrix_set_skew(A) set_flag((A)->property, MATRIX_SKEW)
 #define SparseMatrix_set_hemitian(A) set_flag((A)->property, MATRIX_HERMITIAN)
 
+
+#define SparseMatrix_clear_undirected(A) clear_flag((A)->property, MATRIX_UNDIRECTED)
+#define SparseMatrix_clear_symmetric(A) clear_flag((A)->property, MATRIX_SYMMETRIC)
+#define SparseMatrix_clear_pattern_symmetric(A) clear_flag((A)->property, MATRIX_PATTERN_SYMMETRIC)
+#define SparseMatrix_clear_skew(A) clear_flag((A)->property, MATRIX_SKEW)
+#define SparseMatrix_clear_hemitian(A) clear_flag((A)->property, MATRIX_HERMITIAN)
+
+
 #define SparseMatrix_known_undirected(A) test_flag((A)->property, MATRIX_UNDIRECTED)
 #define SparseMatrix_known_symmetric(A) test_flag((A)->property, MATRIX_SYMMETRIC)
 #define SparseMatrix_known_strucural_symmetric(A) test_flag((A)->property, MATRIX_PATTERN_SYMMETRIC)
index 82568ca9b5790079c5aab8fbedfaf4a1c82d657b..4b57a97e470808e0da3eb9650b0152568373e69d 100644 (file)
@@ -31,271 +31,271 @@ int color_palettes_Q(char *color_palette_name){
 }
 
 
-char *color_palettes[npalettes][2] = {{"ColorBrewer_accent_3","#7fc97f,#beaed4,#fdc086"},
-                                     {"ColorBrewer_accent_4","#7fc97f,#beaed4,#fdc086,#ffff99"},
-                                     {"ColorBrewer_accent_5","#7fc97f,#beaed4,#fdc086,#ffff99,#386cb0"},
-                                     {"ColorBrewer_accent_6","#7fc97f,#beaed4,#fdc086,#ffff99,#386cb0,#f0027f"},
-                                     {"ColorBrewer_accent_7","#7fc97f,#beaed4,#fdc086,#ffff99,#386cb0,#f0027f,#bf5b17"},
-                                     {"ColorBrewer_accent_8","#7fc97f,#beaed4,#fdc086,#ffff99,#386cb0,#f0027f,#bf5b17,#666666"},
-                                     {"ColorBrewer_blues_3","#deebf7,#9ecae1,#3182bd"},
-                                     {"ColorBrewer_blues_4","#eff3ff,#bdd7e7,#6baed6,#2171b5"},
-                                     {"ColorBrewer_blues_5","#eff3ff,#bdd7e7,#6baed6,#3182bd,#08519c"},
-                                     {"ColorBrewer_blues_6","#eff3ff,#c6dbef,#9ecae1,#6baed6,#3182bd,#08519c"},
-                                     {"ColorBrewer_blues_7","#eff3ff,#c6dbef,#9ecae1,#6baed6,#4292c6,#2171b5,#084594"},
-                                     {"ColorBrewer_blues_8","#f7fbff,#deebf7,#c6dbef,#9ecae1,#6baed6,#4292c6,#2171b5,#084594"},
-                                     {"ColorBrewer_blues_9","#f7fbff,#deebf7,#c6dbef,#9ecae1,#6baed6,#4292c6,#2171b5,#08519c,#08306b"},
-                                     {"ColorBrewer_brbg_10","#543005,#8c510a,#bf812d,#dfc27d,#f6e8c3,#c7eae5,#80cdc1,#35978f,#01665e,#003c30"},
-                                     {"ColorBrewer_brbg_11","#543005,#8c510a,#bf812d,#dfc27d,#f6e8c3,#f5f5f5,#c7eae5,#80cdc1,#35978f,#01665e,#003c30"},
-                                     {"ColorBrewer_brbg_3","#d8b365,#f5f5f5,#5ab4ac"},
-                                     {"ColorBrewer_brbg_4","#a6611a,#dfc27d,#80cdc1,#018571"},
-                                     {"ColorBrewer_brbg_5","#a6611a,#dfc27d,#f5f5f5,#80cdc1,#018571"},
-                                     {"ColorBrewer_brbg_6","#8c510a,#d8b365,#f6e8c3,#c7eae5,#5ab4ac,#01665e"},
-                                     {"ColorBrewer_brbg_7","#8c510a,#d8b365,#f6e8c3,#f5f5f5,#c7eae5,#5ab4ac,#01665e"},
-                                     {"ColorBrewer_brbg_8","#8c510a,#bf812d,#dfc27d,#f6e8c3,#c7eae5,#80cdc1,#35978f,#01665e"},
-                                     {"ColorBrewer_brbg_9","#8c510a,#bf812d,#dfc27d,#f6e8c3,#f5f5f5,#c7eae5,#80cdc1,#35978f,#01665e"},
-                                     {"ColorBrewer_bugn_3","#e5f5f9,#99d8c9,#2ca25f"},
-                                     {"ColorBrewer_bugn_4","#edf8fb,#b2e2e2,#66c2a4,#238b45"},
-                                     {"ColorBrewer_bugn_5","#edf8fb,#b2e2e2,#66c2a4,#2ca25f,#006d2c"},
-                                     {"ColorBrewer_bugn_6","#edf8fb,#ccece6,#99d8c9,#66c2a4,#2ca25f,#006d2c"},
-                                     {"ColorBrewer_bugn_7","#edf8fb,#ccece6,#99d8c9,#66c2a4,#41ae76,#238b45,#005824"},
-                                     {"ColorBrewer_bugn_8","#f7fcfd,#e5f5f9,#ccece6,#99d8c9,#66c2a4,#41ae76,#238b45,#005824"},
-                                     {"ColorBrewer_bugn_9","#f7fcfd,#e5f5f9,#ccece6,#99d8c9,#66c2a4,#41ae76,#238b45,#006d2c,#00441b"},
-                                     {"ColorBrewer_bupu_3","#e0ecf4,#9ebcda,#8856a7"},
-                                     {"ColorBrewer_bupu_4","#edf8fb,#b3cde3,#8c96c6,#88419d"},
-                                     {"ColorBrewer_bupu_5","#edf8fb,#b3cde3,#8c96c6,#8856a7,#810f7c"},
-                                     {"ColorBrewer_bupu_6","#edf8fb,#bfd3e6,#9ebcda,#8c96c6,#8856a7,#810f7c"},
-                                     {"ColorBrewer_bupu_7","#edf8fb,#bfd3e6,#9ebcda,#8c96c6,#8c6bb1,#88419d,#6e016b"},
-                                     {"ColorBrewer_bupu_8","#f7fcfd,#e0ecf4,#bfd3e6,#9ebcda,#8c96c6,#8c6bb1,#88419d,#6e016b"},
-                                     {"ColorBrewer_bupu_9","#f7fcfd,#e0ecf4,#bfd3e6,#9ebcda,#8c96c6,#8c6bb1,#88419d,#810f7c,#4d004b"},
-                                     {"ColorBrewer_dark2_3","#1b9e77,#d95f02,#7570b3"},
-                                     {"ColorBrewer_dark2_4","#1b9e77,#d95f02,#7570b3,#e7298a"},
-                                     {"ColorBrewer_dark2_5","#1b9e77,#d95f02,#7570b3,#e7298a,#66a61e"},
-                                     {"ColorBrewer_dark2_6","#1b9e77,#d95f02,#7570b3,#e7298a,#66a61e,#e6ab02"},
-                                     {"ColorBrewer_dark2_7","#1b9e77,#d95f02,#7570b3,#e7298a,#66a61e,#e6ab02,#a6761d"},
-                                     {"ColorBrewer_dark2_8","#1b9e77,#d95f02,#7570b3,#e7298a,#66a61e,#e6ab02,#a6761d,#666666"},
-                                     {"ColorBrewer_gnbu_3","#e0f3db,#a8ddb5,#43a2ca"},
-                                     {"ColorBrewer_gnbu_4","#f0f9e8,#bae4bc,#7bccc4,#2b8cbe"},
-                                     {"ColorBrewer_gnbu_5","#f0f9e8,#bae4bc,#7bccc4,#43a2ca,#0868ac"},
-                                     {"ColorBrewer_gnbu_6","#f0f9e8,#ccebc5,#a8ddb5,#7bccc4,#43a2ca,#0868ac"},
-                                     {"ColorBrewer_gnbu_7","#f0f9e8,#ccebc5,#a8ddb5,#7bccc4,#4eb3d3,#2b8cbe,#08589e"},
-                                     {"ColorBrewer_gnbu_8","#f7fcf0,#e0f3db,#ccebc5,#a8ddb5,#7bccc4,#4eb3d3,#2b8cbe,#08589e"},
-                                     {"ColorBrewer_gnbu_9","#f7fcf0,#e0f3db,#ccebc5,#a8ddb5,#7bccc4,#4eb3d3,#2b8cbe,#0868ac,#084081"},
-                                     {"ColorBrewer_greens_3","#e5f5e0,#a1d99b,#31a354"},
-                                     {"ColorBrewer_greens_4","#edf8e9,#bae4b3,#74c476,#238b45"},
-                                     {"ColorBrewer_greens_5","#edf8e9,#bae4b3,#74c476,#31a354,#006d2c"},
-                                     {"ColorBrewer_greens_6","#edf8e9,#c7e9c0,#a1d99b,#74c476,#31a354,#006d2c"},
-                                     {"ColorBrewer_greens_7","#edf8e9,#c7e9c0,#a1d99b,#74c476,#41ab5d,#238b45,#005a32"},
-                                     {"ColorBrewer_greens_8","#f7fcf5,#e5f5e0,#c7e9c0,#a1d99b,#74c476,#41ab5d,#238b45,#005a32"},
-                                     {"ColorBrewer_greens_9","#f7fcf5,#e5f5e0,#c7e9c0,#a1d99b,#74c476,#41ab5d,#238b45,#006d2c,#00441b"},
-                                     {"ColorBrewer_greys_3","#f0f0f0,#bdbdbd,#636363"},
-                                     {"ColorBrewer_greys_4","#f7f7f7,#cccccc,#969696,#525252"},
-                                     {"ColorBrewer_greys_5","#f7f7f7,#cccccc,#969696,#636363,#252525"},
-                                     {"ColorBrewer_greys_6","#f7f7f7,#d9d9d9,#bdbdbd,#969696,#636363,#252525"},
-                                     {"ColorBrewer_greys_7","#f7f7f7,#d9d9d9,#bdbdbd,#969696,#737373,#525252,#252525"},
-                                     {"ColorBrewer_greys_8","#ffffff,#f0f0f0,#d9d9d9,#bdbdbd,#969696,#737373,#525252,#252525"},
-                                     {"ColorBrewer_greys_9","#ffffff,#f0f0f0,#d9d9d9,#bdbdbd,#969696,#737373,#525252,#252525,#000000"},
-                                     {"ColorBrewer_oranges_3","#fee6ce,#fdae6b,#e6550d"},
-                                     {"ColorBrewer_oranges_4","#feedde,#fdbe85,#fd8d3c,#d94701"},
-                                     {"ColorBrewer_oranges_5","#feedde,#fdbe85,#fd8d3c,#e6550d,#a63603"},
-                                     {"ColorBrewer_oranges_6","#feedde,#fdd0a2,#fdae6b,#fd8d3c,#e6550d,#a63603"},
-                                     {"ColorBrewer_oranges_7","#feedde,#fdd0a2,#fdae6b,#fd8d3c,#f16913,#d94801,#8c2d04"},
-                                     {"ColorBrewer_oranges_8","#fff5eb,#fee6ce,#fdd0a2,#fdae6b,#fd8d3c,#f16913,#d94801,#8c2d04"},
-                                     {"ColorBrewer_oranges_9","#fff5eb,#fee6ce,#fdd0a2,#fdae6b,#fd8d3c,#f16913,#d94801,#a63603,#7f2704"},
-                                     {"ColorBrewer_orrd_3","#fee8c8,#fdbb84,#e34a33"},
-                                     {"ColorBrewer_orrd_4","#fef0d9,#fdcc8a,#fc8d59,#d7301f"},
-                                     {"ColorBrewer_orrd_5","#fef0d9,#fdcc8a,#fc8d59,#e34a33,#b30000"},
-                                     {"ColorBrewer_orrd_6","#fef0d9,#fdd49e,#fdbb84,#fc8d59,#e34a33,#b30000"},
-                                     {"ColorBrewer_orrd_7","#fef0d9,#fdd49e,#fdbb84,#fc8d59,#ef6548,#d7301f,#990000"},
-                                     {"ColorBrewer_orrd_8","#fff7ec,#fee8c8,#fdd49e,#fdbb84,#fc8d59,#ef6548,#d7301f,#990000"},
-                                     {"ColorBrewer_orrd_9","#fff7ec,#fee8c8,#fdd49e,#fdbb84,#fc8d59,#ef6548,#d7301f,#b30000,#7f0000"},
-                                     {"ColorBrewer_paired_10","#a6cee3,#1f78b4,#b2df8a,#33a02c,#fb9a99,#e31a1c,#fdbf6f,#ff7f00,#cab2d6,#6a3d9a"},
-                                     {"ColorBrewer_paired_11","#a6cee3,#1f78b4,#b2df8a,#33a02c,#fb9a99,#e31a1c,#fdbf6f,#ff7f00,#cab2d6,#6a3d9a,#ffff99"},
-                                     {"ColorBrewer_paired_12","#a6cee3,#1f78b4,#b2df8a,#33a02c,#fb9a99,#e31a1c,#fdbf6f,#ff7f00,#cab2d6,#6a3d9a,#ffff99,#b15928"},
-                                     {"ColorBrewer_paired_3","#a6cee3,#1f78b4,#b2df8a"},
-                                     {"ColorBrewer_paired_4","#a6cee3,#1f78b4,#b2df8a,#33a02c"},
-                                     {"ColorBrewer_paired_5","#a6cee3,#1f78b4,#b2df8a,#33a02c,#fb9a99"},
-                                     {"ColorBrewer_paired_6","#a6cee3,#1f78b4,#b2df8a,#33a02c,#fb9a99,#e31a1c"},
-                                     {"ColorBrewer_paired_7","#a6cee3,#1f78b4,#b2df8a,#33a02c,#fb9a99,#e31a1c,#fdbf6f"},
-                                     {"ColorBrewer_paired_8","#a6cee3,#1f78b4,#b2df8a,#33a02c,#fb9a99,#e31a1c,#fdbf6f,#ff7f00"},
-                                     {"ColorBrewer_paired_9","#a6cee3,#1f78b4,#b2df8a,#33a02c,#fb9a99,#e31a1c,#fdbf6f,#ff7f00,#cab2d6"},
-                                     {"ColorBrewer_pastel1_3","#fbb4ae,#b3cde3,#ccebc5"},
-                                     {"ColorBrewer_pastel1_4","#fbb4ae,#b3cde3,#ccebc5,#decbe4"},
-                                     {"ColorBrewer_pastel1_5","#fbb4ae,#b3cde3,#ccebc5,#decbe4,#fed9a6"},
-                                     {"ColorBrewer_pastel1_6","#fbb4ae,#b3cde3,#ccebc5,#decbe4,#fed9a6,#ffffcc"},
-                                     {"ColorBrewer_pastel1_7","#fbb4ae,#b3cde3,#ccebc5,#decbe4,#fed9a6,#ffffcc,#e5d8bd"},
-                                     {"ColorBrewer_pastel1_8","#fbb4ae,#b3cde3,#ccebc5,#decbe4,#fed9a6,#ffffcc,#e5d8bd,#fddaec"},
-                                     {"ColorBrewer_pastel1_9","#fbb4ae,#b3cde3,#ccebc5,#decbe4,#fed9a6,#ffffcc,#e5d8bd,#fddaec,#f2f2f2"},
-                                     {"ColorBrewer_pastel2_3","#b3e2cd,#fdcdac,#cbd5e8"},
-                                     {"ColorBrewer_pastel2_4","#b3e2cd,#fdcdac,#cbd5e8,#f4cae4"},
-                                     {"ColorBrewer_pastel2_5","#b3e2cd,#fdcdac,#cbd5e8,#f4cae4,#e6f5c9"},
-                                     {"ColorBrewer_pastel2_6","#b3e2cd,#fdcdac,#cbd5e8,#f4cae4,#e6f5c9,#fff2ae"},
-                                     {"ColorBrewer_pastel2_7","#b3e2cd,#fdcdac,#cbd5e8,#f4cae4,#e6f5c9,#fff2ae,#f1e2cc"},
-                                     {"ColorBrewer_pastel2_8","#b3e2cd,#fdcdac,#cbd5e8,#f4cae4,#e6f5c9,#fff2ae,#f1e2cc,#cccccc"},
-                                     {"ColorBrewer_piyg_10","#8e0152,#c51b7d,#de77ae,#f1b6da,#fde0ef,#e6f5d0,#b8e186,#7fbc41,#4d9221,#276419"},
-                                     {"ColorBrewer_piyg_11","#8e0152,#c51b7d,#de77ae,#f1b6da,#fde0ef,#f7f7f7,#e6f5d0,#b8e186,#7fbc41,#4d9221,#276419"},
-                                     {"ColorBrewer_piyg_3","#e9a3c9,#f7f7f7,#a1d76a"},
-                                     {"ColorBrewer_piyg_4","#d01c8b,#f1b6da,#b8e186,#4dac26"},
-                                     {"ColorBrewer_piyg_5","#d01c8b,#f1b6da,#f7f7f7,#b8e186,#4dac26"},
-                                     {"ColorBrewer_piyg_6","#c51b7d,#e9a3c9,#fde0ef,#e6f5d0,#a1d76a,#4d9221"},
-                                     {"ColorBrewer_piyg_7","#c51b7d,#e9a3c9,#fde0ef,#f7f7f7,#e6f5d0,#a1d76a,#4d9221"},
-                                     {"ColorBrewer_piyg_8","#c51b7d,#de77ae,#f1b6da,#fde0ef,#e6f5d0,#b8e186,#7fbc41,#4d9221"},
-                                     {"ColorBrewer_piyg_9","#c51b7d,#de77ae,#f1b6da,#fde0ef,#f7f7f7,#e6f5d0,#b8e186,#7fbc41,#4d9221"},
-                                     {"ColorBrewer_prgn_10","#40004b,#762a83,#9970ab,#c2a5cf,#e7d4e8,#d9f0d3,#a6dba0,#5aae61,#1b7837,#00441b"},
-                                     {"ColorBrewer_prgn_11","#40004b,#762a83,#9970ab,#c2a5cf,#e7d4e8,#f7f7f7,#d9f0d3,#a6dba0,#5aae61,#1b7837,#00441b"},
-                                     {"ColorBrewer_prgn_3","#af8dc3,#f7f7f7,#7fbf7b"},
-                                     {"ColorBrewer_prgn_4","#7b3294,#c2a5cf,#a6dba0,#008837"},
-                                     {"ColorBrewer_prgn_5","#7b3294,#c2a5cf,#f7f7f7,#a6dba0,#008837"},
-                                     {"ColorBrewer_prgn_6","#762a83,#af8dc3,#e7d4e8,#d9f0d3,#7fbf7b,#1b7837"},
-                                     {"ColorBrewer_prgn_7","#762a83,#af8dc3,#e7d4e8,#f7f7f7,#d9f0d3,#7fbf7b,#1b7837"},
-                                     {"ColorBrewer_prgn_8","#762a83,#9970ab,#c2a5cf,#e7d4e8,#d9f0d3,#a6dba0,#5aae61,#1b7837"},
-                                     {"ColorBrewer_prgn_9","#762a83,#9970ab,#c2a5cf,#e7d4e8,#f7f7f7,#d9f0d3,#a6dba0,#5aae61,#1b7837"},
-                                     {"ColorBrewer_pubu_3","#ece7f2,#a6bddb,#2b8cbe"},
-                                     {"ColorBrewer_pubu_4","#f1eef6,#bdc9e1,#74a9cf,#0570b0"},
-                                     {"ColorBrewer_pubu_5","#f1eef6,#bdc9e1,#74a9cf,#2b8cbe,#045a8d"},
-                                     {"ColorBrewer_pubu_6","#f1eef6,#d0d1e6,#a6bddb,#74a9cf,#2b8cbe,#045a8d"},
-                                     {"ColorBrewer_pubu_7","#f1eef6,#d0d1e6,#a6bddb,#74a9cf,#3690c0,#0570b0,#034e7b"},
-                                     {"ColorBrewer_pubu_8","#fff7fb,#ece7f2,#d0d1e6,#a6bddb,#74a9cf,#3690c0,#0570b0,#034e7b"},
-                                     {"ColorBrewer_pubu_9","#fff7fb,#ece7f2,#d0d1e6,#a6bddb,#74a9cf,#3690c0,#0570b0,#045a8d,#023858"},
-                                     {"ColorBrewer_pubugn_3","#ece2f0,#a6bddb,#1c9099"},
-                                     {"ColorBrewer_pubugn_4","#f6eff7,#bdc9e1,#67a9cf,#02818a"},
-                                     {"ColorBrewer_pubugn_5","#f6eff7,#bdc9e1,#67a9cf,#1c9099,#016c59"},
-                                     {"ColorBrewer_pubugn_6","#f6eff7,#d0d1e6,#a6bddb,#67a9cf,#1c9099,#016c59"},
-                                     {"ColorBrewer_pubugn_7","#f6eff7,#d0d1e6,#a6bddb,#67a9cf,#3690c0,#02818a,#016450"},
-                                     {"ColorBrewer_pubugn_8","#fff7fb,#ece2f0,#d0d1e6,#a6bddb,#67a9cf,#3690c0,#02818a,#016450"},
-                                     {"ColorBrewer_pubugn_9","#fff7fb,#ece2f0,#d0d1e6,#a6bddb,#67a9cf,#3690c0,#02818a,#016c59,#014636"},
-                                     {"ColorBrewer_puor_10","#7f3b08,#b35806,#e08214,#fdb863,#fee0b6,#d8daeb,#b2abd2,#8073ac,#542788,#2d004b"},
-                                     {"ColorBrewer_puor_11","#7f3b08,#b35806,#e08214,#fdb863,#fee0b6,#f7f7f7,#d8daeb,#b2abd2,#8073ac,#542788,#2d004b"},
-                                     {"ColorBrewer_puor_3","#f1a340,#f7f7f7,#998ec3"},
-                                     {"ColorBrewer_puor_4","#e66101,#fdb863,#b2abd2,#5e3c99"},
-                                     {"ColorBrewer_puor_5","#e66101,#fdb863,#f7f7f7,#b2abd2,#5e3c99"},
-                                     {"ColorBrewer_puor_6","#b35806,#f1a340,#fee0b6,#d8daeb,#998ec3,#542788"},
-                                     {"ColorBrewer_puor_7","#b35806,#f1a340,#fee0b6,#f7f7f7,#d8daeb,#998ec3,#542788"},
-                                     {"ColorBrewer_puor_8","#b35806,#e08214,#fdb863,#fee0b6,#d8daeb,#b2abd2,#8073ac,#542788"},
-                                     {"ColorBrewer_puor_9","#b35806,#e08214,#fdb863,#fee0b6,#f7f7f7,#d8daeb,#b2abd2,#8073ac,#542788"},
-                                     {"ColorBrewer_purd_3","#e7e1ef,#c994c7,#dd1c77"},
-                                     {"ColorBrewer_purd_4","#f1eef6,#d7b5d8,#df65b0,#ce1256"},
-                                     {"ColorBrewer_purd_5","#f1eef6,#d7b5d8,#df65b0,#dd1c77,#980043"},
-                                     {"ColorBrewer_purd_6","#f1eef6,#d4b9da,#c994c7,#df65b0,#dd1c77,#980043"},
-                                     {"ColorBrewer_purd_7","#f1eef6,#d4b9da,#c994c7,#df65b0,#e7298a,#ce1256,#91003f"},
-                                     {"ColorBrewer_purd_8","#f7f4f9,#e7e1ef,#d4b9da,#c994c7,#df65b0,#e7298a,#ce1256,#91003f"},
-                                     {"ColorBrewer_purd_9","#f7f4f9,#e7e1ef,#d4b9da,#c994c7,#df65b0,#e7298a,#ce1256,#980043,#67001f"},
-                                     {"ColorBrewer_purples_3","#efedf5,#bcbddc,#756bb1"},
-                                     {"ColorBrewer_purples_4","#f2f0f7,#cbc9e2,#9e9ac8,#6a51a3"},
-                                     {"ColorBrewer_purples_5","#f2f0f7,#cbc9e2,#9e9ac8,#756bb1,#54278f"},
-                                     {"ColorBrewer_purples_6","#f2f0f7,#dadaeb,#bcbddc,#9e9ac8,#756bb1,#54278f"},
-                                     {"ColorBrewer_purples_7","#f2f0f7,#dadaeb,#bcbddc,#9e9ac8,#807dba,#6a51a3,#4a1486"},
-                                     {"ColorBrewer_purples_8","#fcfbfd,#efedf5,#dadaeb,#bcbddc,#9e9ac8,#807dba,#6a51a3,#4a1486"},
-                                     {"ColorBrewer_purples_9","#fcfbfd,#efedf5,#dadaeb,#bcbddc,#9e9ac8,#807dba,#6a51a3,#54278f,#3f007d"},
-                                     {"ColorBrewer_rdbu_10","#67001f,#b2182b,#d6604d,#f4a582,#fddbc7,#d1e5f0,#92c5de,#4393c3,#2166ac,#053061"},
-                                     {"ColorBrewer_rdbu_11","#67001f,#b2182b,#d6604d,#f4a582,#fddbc7,#f7f7f7,#d1e5f0,#92c5de,#4393c3,#2166ac,#053061"},
-                                     {"ColorBrewer_rdbu_3","#ef8a62,#f7f7f7,#67a9cf"},
-                                     {"ColorBrewer_rdbu_4","#ca0020,#f4a582,#92c5de,#0571b0"},
-                                     {"ColorBrewer_rdbu_5","#ca0020,#f4a582,#f7f7f7,#92c5de,#0571b0"},
-                                     {"ColorBrewer_rdbu_6","#b2182b,#ef8a62,#fddbc7,#d1e5f0,#67a9cf,#2166ac"},
-                                     {"ColorBrewer_rdbu_7","#b2182b,#ef8a62,#fddbc7,#f7f7f7,#d1e5f0,#67a9cf,#2166ac"},
-                                     {"ColorBrewer_rdbu_8","#b2182b,#d6604d,#f4a582,#fddbc7,#d1e5f0,#92c5de,#4393c3,#2166ac"},
-                                     {"ColorBrewer_rdbu_9","#b2182b,#d6604d,#f4a582,#fddbc7,#f7f7f7,#d1e5f0,#92c5de,#4393c3,#2166ac"},
-                                     {"ColorBrewer_rdgy_10","#67001f,#b2182b,#d6604d,#f4a582,#fddbc7,#e0e0e0,#bababa,#878787,#4d4d4d,#1a1a1a"},
-                                     {"ColorBrewer_rdgy_11","#67001f,#b2182b,#d6604d,#f4a582,#fddbc7,#ffffff,#e0e0e0,#bababa,#878787,#4d4d4d,#1a1a1a"},
-                                     {"ColorBrewer_rdgy_3","#ef8a62,#ffffff,#999999"},
-                                     {"ColorBrewer_rdgy_4","#ca0020,#f4a582,#bababa,#404040"},
-                                     {"ColorBrewer_rdgy_5","#ca0020,#f4a582,#ffffff,#bababa,#404040"},
-                                     {"ColorBrewer_rdgy_6","#b2182b,#ef8a62,#fddbc7,#e0e0e0,#999999,#4d4d4d"},
-                                     {"ColorBrewer_rdgy_7","#b2182b,#ef8a62,#fddbc7,#ffffff,#e0e0e0,#999999,#4d4d4d"},
-                                     {"ColorBrewer_rdgy_8","#b2182b,#d6604d,#f4a582,#fddbc7,#e0e0e0,#bababa,#878787,#4d4d4d"},
-                                     {"ColorBrewer_rdgy_9","#b2182b,#d6604d,#f4a582,#fddbc7,#ffffff,#e0e0e0,#bababa,#878787,#4d4d4d"},
-                                     {"ColorBrewer_rdpu_3","#fde0dd,#fa9fb5,#c51b8a"},
-                                     {"ColorBrewer_rdpu_4","#feebe2,#fbb4b9,#f768a1,#ae017e"},
-                                     {"ColorBrewer_rdpu_5","#feebe2,#fbb4b9,#f768a1,#c51b8a,#7a0177"},
-                                     {"ColorBrewer_rdpu_6","#feebe2,#fcc5c0,#fa9fb5,#f768a1,#c51b8a,#7a0177"},
-                                     {"ColorBrewer_rdpu_7","#feebe2,#fcc5c0,#fa9fb5,#f768a1,#dd3497,#ae017e,#7a0177"},
-                                     {"ColorBrewer_rdpu_8","#fff7f3,#fde0dd,#fcc5c0,#fa9fb5,#f768a1,#dd3497,#ae017e,#7a0177"},
-                                     {"ColorBrewer_rdpu_9","#fff7f3,#fde0dd,#fcc5c0,#fa9fb5,#f768a1,#dd3497,#ae017e,#7a0177,#49006a"},
-                                     {"ColorBrewer_rdylbu_10","#a50026,#d73027,#f46d43,#fdae61,#fee090,#e0f3f8,#abd9e9,#74add1,#4575b4,#313695"},
-                                     {"ColorBrewer_rdylbu_11","#a50026,#d73027,#f46d43,#fdae61,#fee090,#ffffbf,#e0f3f8,#abd9e9,#74add1,#4575b4,#313695"},
-                                     {"ColorBrewer_rdylbu_3","#fc8d59,#ffffbf,#91bfdb"},
-                                     {"ColorBrewer_rdylbu_4","#d7191c,#fdae61,#abd9e9,#2c7bb6"},
-                                     {"ColorBrewer_rdylbu_5","#d7191c,#fdae61,#ffffbf,#abd9e9,#2c7bb6"},
-                                     {"ColorBrewer_rdylbu_6","#d73027,#fc8d59,#fee090,#e0f3f8,#91bfdb,#4575b4"},
-                                     {"ColorBrewer_rdylbu_7","#d73027,#fc8d59,#fee090,#ffffbf,#e0f3f8,#91bfdb,#4575b4"},
-                                     {"ColorBrewer_rdylbu_8","#d73027,#f46d43,#fdae61,#fee090,#e0f3f8,#abd9e9,#74add1,#4575b4"},
-                                     {"ColorBrewer_rdylbu_9","#d73027,#f46d43,#fdae61,#fee090,#ffffbf,#e0f3f8,#abd9e9,#74add1,#4575b4"},
-                                     {"ColorBrewer_rdylgn_10","#a50026,#d73027,#f46d43,#fdae61,#fee08b,#d9ef8b,#a6d96a,#66bd63,#1a9850,#006837"},
-                                     {"ColorBrewer_rdylgn_11","#a50026,#d73027,#f46d43,#fdae61,#fee08b,#ffffbf,#d9ef8b,#a6d96a,#66bd63,#1a9850,#006837"},
-                                     {"ColorBrewer_rdylgn_3","#fc8d59,#ffffbf,#91cf60"},
-                                     {"ColorBrewer_rdylgn_4","#d7191c,#fdae61,#a6d96a,#1a9641"},
-                                     {"ColorBrewer_rdylgn_5","#d7191c,#fdae61,#ffffbf,#a6d96a,#1a9641"},
-                                     {"ColorBrewer_rdylgn_6","#d73027,#fc8d59,#fee08b,#d9ef8b,#91cf60,#1a9850"},
-                                     {"ColorBrewer_rdylgn_7","#d73027,#fc8d59,#fee08b,#ffffbf,#d9ef8b,#91cf60,#1a9850"},
-                                     {"ColorBrewer_rdylgn_8","#d73027,#f46d43,#fdae61,#fee08b,#d9ef8b,#a6d96a,#66bd63,#1a9850"},
-                                     {"ColorBrewer_rdylgn_9","#d73027,#f46d43,#fdae61,#fee08b,#ffffbf,#d9ef8b,#a6d96a,#66bd63,#1a9850"},
-                                     {"ColorBrewer_reds_3","#fee0d2,#fc9272,#de2d26"},
-                                     {"ColorBrewer_reds_4","#fee5d9,#fcae91,#fb6a4a,#cb181d"},
-                                     {"ColorBrewer_reds_5","#fee5d9,#fcae91,#fb6a4a,#de2d26,#a50f15"},
-                                     {"ColorBrewer_reds_6","#fee5d9,#fcbba1,#fc9272,#fb6a4a,#de2d26,#a50f15"},
-                                     {"ColorBrewer_reds_7","#fee5d9,#fcbba1,#fc9272,#fb6a4a,#ef3b2c,#cb181d,#99000d"},
-                                     {"ColorBrewer_reds_8","#fff5f0,#fee0d2,#fcbba1,#fc9272,#fb6a4a,#ef3b2c,#cb181d,#99000d"},
-                                     {"ColorBrewer_reds_9","#fff5f0,#fee0d2,#fcbba1,#fc9272,#fb6a4a,#ef3b2c,#cb181d,#a50f15,#67000d"},
-                                     {"ColorBrewer_set1_3","#e41a1c,#377eb8,#4daf4a"},
-                                     {"ColorBrewer_set1_4","#e41a1c,#377eb8,#4daf4a,#984ea3"},
-                                     {"ColorBrewer_set1_5","#e41a1c,#377eb8,#4daf4a,#984ea3,#ff7f00"},
-                                     {"ColorBrewer_set1_6","#e41a1c,#377eb8,#4daf4a,#984ea3,#ff7f00,#ffff33"},
-                                     {"ColorBrewer_set1_7","#e41a1c,#377eb8,#4daf4a,#984ea3,#ff7f00,#ffff33,#a65628"},
-                                     {"ColorBrewer_set1_8","#e41a1c,#377eb8,#4daf4a,#984ea3,#ff7f00,#ffff33,#a65628,#f781bf"},
-                                     {"ColorBrewer_set1_9","#e41a1c,#377eb8,#4daf4a,#984ea3,#ff7f00,#ffff33,#a65628,#f781bf,#999999"},
-                                     {"ColorBrewer_set2_3","#66c2a5,#fc8d62,#8da0cb"},
-                                     {"ColorBrewer_set2_4","#66c2a5,#fc8d62,#8da0cb,#e78ac3"},
-                                     {"ColorBrewer_set2_5","#66c2a5,#fc8d62,#8da0cb,#e78ac3,#a6d854"},
-                                     {"ColorBrewer_set2_6","#66c2a5,#fc8d62,#8da0cb,#e78ac3,#a6d854,#ffd92f"},
-                                     {"ColorBrewer_set2_7","#66c2a5,#fc8d62,#8da0cb,#e78ac3,#a6d854,#ffd92f,#e5c494"},
-                                     {"ColorBrewer_set2_8","#66c2a5,#fc8d62,#8da0cb,#e78ac3,#a6d854,#ffd92f,#e5c494,#b3b3b3"},
-                                     {"ColorBrewer_set3_10","#8dd3c7,#ffffb3,#bebada,#fb8072,#80b1d3,#fdb462,#b3de69,#fccde5,#d9d9d9,#bc80bd"},
-                                     {"ColorBrewer_set3_11","#8dd3c7,#ffffb3,#bebada,#fb8072,#80b1d3,#fdb462,#b3de69,#fccde5,#d9d9d9,#bc80bd,#ccebc5"},
-                                     {"ColorBrewer_set3_12","#8dd3c7,#ffffb3,#bebada,#fb8072,#80b1d3,#fdb462,#b3de69,#fccde5,#d9d9d9,#bc80bd,#ccebc5,#ffed6f"},
-                                     {"ColorBrewer_set3_3","#8dd3c7,#ffffb3,#bebada"},
-                                     {"ColorBrewer_set3_4","#8dd3c7,#ffffb3,#bebada,#fb8072"},
-                                     {"ColorBrewer_set3_5","#8dd3c7,#ffffb3,#bebada,#fb8072,#80b1d3"},
-                                     {"ColorBrewer_set3_6","#8dd3c7,#ffffb3,#bebada,#fb8072,#80b1d3,#fdb462"},
-                                     {"ColorBrewer_set3_7","#8dd3c7,#ffffb3,#bebada,#fb8072,#80b1d3,#fdb462,#b3de69"},
-                                     {"ColorBrewer_set3_8","#8dd3c7,#ffffb3,#bebada,#fb8072,#80b1d3,#fdb462,#b3de69,#fccde5"},
-                                     {"ColorBrewer_set3_9","#8dd3c7,#ffffb3,#bebada,#fb8072,#80b1d3,#fdb462,#b3de69,#fccde5,#d9d9d9"},
-                                     {"ColorBrewer_spectral_10","#9e0142,#d53e4f,#f46d43,#fdae61,#fee08b,#e6f598,#abdda4,#66c2a5,#3288bd,#5e4fa2"},
-                                     {"ColorBrewer_spectral_11","#9e0142,#d53e4f,#f46d43,#fdae61,#fee08b,#ffffbf,#e6f598,#abdda4,#66c2a5,#3288bd,#5e4fa2"},
-                                     {"ColorBrewer_spectral_3","#fc8d59,#ffffbf,#99d594"},
-                                     {"ColorBrewer_spectral_4","#d7191c,#fdae61,#abdda4,#2b83ba"},
-                                     {"ColorBrewer_spectral_5","#d7191c,#fdae61,#ffffbf,#abdda4,#2b83ba"},
-                                     {"ColorBrewer_spectral_6","#d53e4f,#fc8d59,#fee08b,#e6f598,#99d594,#3288bd"},
-                                     {"ColorBrewer_spectral_7","#d53e4f,#fc8d59,#fee08b,#ffffbf,#e6f598,#99d594,#3288bd"},
-                                     {"ColorBrewer_spectral_8","#d53e4f,#f46d43,#fdae61,#fee08b,#e6f598,#abdda4,#66c2a5,#3288bd"},
-                                     {"ColorBrewer_spectral_9","#d53e4f,#f46d43,#fdae61,#fee08b,#ffffbf,#e6f598,#abdda4,#66c2a5,#3288bd"},
-                                     {"ColorBrewer_ylgn_3","#f7fcb9,#addd8e,#31a354"},
-                                     {"ColorBrewer_ylgn_4","#ffffcc,#c2e699,#78c679,#238443"},
-                                     {"ColorBrewer_ylgn_5","#ffffcc,#c2e699,#78c679,#31a354,#006837"},
-                                     {"ColorBrewer_ylgn_6","#ffffcc,#d9f0a3,#addd8e,#78c679,#31a354,#006837"},
-                                     {"ColorBrewer_ylgn_7","#ffffcc,#d9f0a3,#addd8e,#78c679,#41ab5d,#238443,#005a32"},
-                                     {"ColorBrewer_ylgn_8","#ffffe5,#f7fcb9,#d9f0a3,#addd8e,#78c679,#41ab5d,#238443,#005a32"},
-                                     {"ColorBrewer_ylgn_9","#ffffe5,#f7fcb9,#d9f0a3,#addd8e,#78c679,#41ab5d,#238443,#006837,#004529"},
-                                     {"ColorBrewer_ylgnbu_3","#edf8b1,#7fcdbb,#2c7fb8"},
-                                     {"ColorBrewer_ylgnbu_4","#ffffcc,#a1dab4,#41b6c4,#225ea8"},
-                                     {"ColorBrewer_ylgnbu_5","#ffffcc,#a1dab4,#41b6c4,#2c7fb8,#253494"},
-                                     {"ColorBrewer_ylgnbu_6","#ffffcc,#c7e9b4,#7fcdbb,#41b6c4,#2c7fb8,#253494"},
-                                     {"ColorBrewer_ylgnbu_7","#ffffcc,#c7e9b4,#7fcdbb,#41b6c4,#1d91c0,#225ea8,#0c2c84"},
-                                     {"ColorBrewer_ylgnbu_8","#ffffd9,#edf8b1,#c7e9b4,#7fcdbb,#41b6c4,#1d91c0,#225ea8,#0c2c84"},
-                                     {"ColorBrewer_ylgnbu_9","#ffffd9,#edf8b1,#c7e9b4,#7fcdbb,#41b6c4,#1d91c0,#225ea8,#253494,#081d58"},
-                                     {"ColorBrewer_ylorbr_3","#fff7bc,#fec44f,#d95f0e"},
-                                     {"ColorBrewer_ylorbr_4","#ffffd4,#fed98e,#fe9929,#cc4c02"},
-                                     {"ColorBrewer_ylorbr_5","#ffffd4,#fed98e,#fe9929,#d95f0e,#993404"},
-                                     {"ColorBrewer_ylorbr_6","#ffffd4,#fee391,#fec44f,#fe9929,#d95f0e,#993404"},
-                                     {"ColorBrewer_ylorbr_7","#ffffd4,#fee391,#fec44f,#fe9929,#ec7014,#cc4c02,#8c2d04"},
-                                     {"ColorBrewer_ylorbr_8","#ffffe5,#fff7bc,#fee391,#fec44f,#fe9929,#ec7014,#cc4c02,#8c2d04"},
-                                     {"ColorBrewer_ylorbr_9","#ffffe5,#fff7bc,#fee391,#fec44f,#fe9929,#ec7014,#cc4c02,#993404,#662506"},
-                                     {"ColorBrewer_ylorrd_3","#ffeda0,#feb24c,#f03b20"},
-                                     {"ColorBrewer_ylorrd_4","#ffffb2,#fecc5c,#fd8d3c,#e31a1c"},
-                                     {"ColorBrewer_ylorrd_5","#ffffb2,#fecc5c,#fd8d3c,#f03b20,#bd0026"},
-                                     {"ColorBrewer_ylorrd_6","#ffffb2,#fed976,#feb24c,#fd8d3c,#f03b20,#bd0026"},
-                                     {"ColorBrewer_ylorrd_7","#ffffb2,#fed976,#feb24c,#fd8d3c,#fc4e2a,#e31a1c,#b10026"},
-                                     {"ColorBrewer_ylorrd_8","#ffffcc,#ffeda0,#fed976,#feb24c,#fd8d3c,#fc4e2a,#e31a1c,#b10026"},
-                                     {"ColorBrewer_ylorrd_9","#ffffcc,#ffeda0,#fed976,#feb24c,#fd8d3c,#fc4e2a,#e31a1c,#bd0026,#800026"}};
+char *color_palettes[npalettes][2] = {{"accent3","#7fc97f,#beaed4,#fdc086"},
+                                     {"accent4","#7fc97f,#beaed4,#fdc086,#ffff99"},
+                                     {"accent5","#7fc97f,#beaed4,#fdc086,#ffff99,#386cb0"},
+                                     {"accent6","#7fc97f,#beaed4,#fdc086,#ffff99,#386cb0,#f0027f"},
+                                     {"accent7","#7fc97f,#beaed4,#fdc086,#ffff99,#386cb0,#f0027f,#bf5b17"},
+                                     {"accent8","#7fc97f,#beaed4,#fdc086,#ffff99,#386cb0,#f0027f,#bf5b17,#666666"},
+                                     {"blues3","#deebf7,#9ecae1,#3182bd"},
+                                     {"blues4","#eff3ff,#bdd7e7,#6baed6,#2171b5"},
+                                     {"blues5","#eff3ff,#bdd7e7,#6baed6,#3182bd,#08519c"},
+                                     {"blues6","#eff3ff,#c6dbef,#9ecae1,#6baed6,#3182bd,#08519c"},
+                                     {"blues7","#eff3ff,#c6dbef,#9ecae1,#6baed6,#4292c6,#2171b5,#084594"},
+                                     {"blues8","#f7fbff,#deebf7,#c6dbef,#9ecae1,#6baed6,#4292c6,#2171b5,#084594"},
+                                     {"blues9","#f7fbff,#deebf7,#c6dbef,#9ecae1,#6baed6,#4292c6,#2171b5,#08519c,#08306b"},
+                                     {"brbg10","#543005,#8c510a,#bf812d,#dfc27d,#f6e8c3,#c7eae5,#80cdc1,#35978f,#01665e,#003c30"},
+                                     {"brbg11","#543005,#8c510a,#bf812d,#dfc27d,#f6e8c3,#f5f5f5,#c7eae5,#80cdc1,#35978f,#01665e,#003c30"},
+                                     {"brbg3","#d8b365,#f5f5f5,#5ab4ac"},
+                                     {"brbg4","#a6611a,#dfc27d,#80cdc1,#018571"},
+                                     {"brbg5","#a6611a,#dfc27d,#f5f5f5,#80cdc1,#018571"},
+                                     {"brbg6","#8c510a,#d8b365,#f6e8c3,#c7eae5,#5ab4ac,#01665e"},
+                                     {"brbg7","#8c510a,#d8b365,#f6e8c3,#f5f5f5,#c7eae5,#5ab4ac,#01665e"},
+                                     {"brbg8","#8c510a,#bf812d,#dfc27d,#f6e8c3,#c7eae5,#80cdc1,#35978f,#01665e"},
+                                     {"brbg9","#8c510a,#bf812d,#dfc27d,#f6e8c3,#f5f5f5,#c7eae5,#80cdc1,#35978f,#01665e"},
+                                     {"bugn3","#e5f5f9,#99d8c9,#2ca25f"},
+                                     {"bugn4","#edf8fb,#b2e2e2,#66c2a4,#238b45"},
+                                     {"bugn5","#edf8fb,#b2e2e2,#66c2a4,#2ca25f,#006d2c"},
+                                     {"bugn6","#edf8fb,#ccece6,#99d8c9,#66c2a4,#2ca25f,#006d2c"},
+                                     {"bugn7","#edf8fb,#ccece6,#99d8c9,#66c2a4,#41ae76,#238b45,#005824"},
+                                     {"bugn8","#f7fcfd,#e5f5f9,#ccece6,#99d8c9,#66c2a4,#41ae76,#238b45,#005824"},
+                                     {"bugn9","#f7fcfd,#e5f5f9,#ccece6,#99d8c9,#66c2a4,#41ae76,#238b45,#006d2c,#00441b"},
+                                     {"bupu3","#e0ecf4,#9ebcda,#8856a7"},
+                                     {"bupu4","#edf8fb,#b3cde3,#8c96c6,#88419d"},
+                                     {"bupu5","#edf8fb,#b3cde3,#8c96c6,#8856a7,#810f7c"},
+                                     {"bupu6","#edf8fb,#bfd3e6,#9ebcda,#8c96c6,#8856a7,#810f7c"},
+                                     {"bupu7","#edf8fb,#bfd3e6,#9ebcda,#8c96c6,#8c6bb1,#88419d,#6e016b"},
+                                     {"bupu8","#f7fcfd,#e0ecf4,#bfd3e6,#9ebcda,#8c96c6,#8c6bb1,#88419d,#6e016b"},
+                                     {"bupu9","#f7fcfd,#e0ecf4,#bfd3e6,#9ebcda,#8c96c6,#8c6bb1,#88419d,#810f7c,#4d004b"},
+                                     {"dark23","#1b9e77,#d95f02,#7570b3"},
+                                     {"dark24","#1b9e77,#d95f02,#7570b3,#e7298a"},
+                                     {"dark25","#1b9e77,#d95f02,#7570b3,#e7298a,#66a61e"},
+                                     {"dark26","#1b9e77,#d95f02,#7570b3,#e7298a,#66a61e,#e6ab02"},
+                                     {"dark27","#1b9e77,#d95f02,#7570b3,#e7298a,#66a61e,#e6ab02,#a6761d"},
+                                     {"dark28","#1b9e77,#d95f02,#7570b3,#e7298a,#66a61e,#e6ab02,#a6761d,#666666"},
+                                     {"gnbu3","#e0f3db,#a8ddb5,#43a2ca"},
+                                     {"gnbu4","#f0f9e8,#bae4bc,#7bccc4,#2b8cbe"},
+                                     {"gnbu5","#f0f9e8,#bae4bc,#7bccc4,#43a2ca,#0868ac"},
+                                     {"gnbu6","#f0f9e8,#ccebc5,#a8ddb5,#7bccc4,#43a2ca,#0868ac"},
+                                     {"gnbu7","#f0f9e8,#ccebc5,#a8ddb5,#7bccc4,#4eb3d3,#2b8cbe,#08589e"},
+                                     {"gnbu8","#f7fcf0,#e0f3db,#ccebc5,#a8ddb5,#7bccc4,#4eb3d3,#2b8cbe,#08589e"},
+                                     {"gnbu9","#f7fcf0,#e0f3db,#ccebc5,#a8ddb5,#7bccc4,#4eb3d3,#2b8cbe,#0868ac,#084081"},
+                                     {"greens3","#e5f5e0,#a1d99b,#31a354"},
+                                     {"greens4","#edf8e9,#bae4b3,#74c476,#238b45"},
+                                     {"greens5","#edf8e9,#bae4b3,#74c476,#31a354,#006d2c"},
+                                     {"greens6","#edf8e9,#c7e9c0,#a1d99b,#74c476,#31a354,#006d2c"},
+                                     {"greens7","#edf8e9,#c7e9c0,#a1d99b,#74c476,#41ab5d,#238b45,#005a32"},
+                                     {"greens8","#f7fcf5,#e5f5e0,#c7e9c0,#a1d99b,#74c476,#41ab5d,#238b45,#005a32"},
+                                     {"greens9","#f7fcf5,#e5f5e0,#c7e9c0,#a1d99b,#74c476,#41ab5d,#238b45,#006d2c,#00441b"},
+                                     {"greys3","#f0f0f0,#bdbdbd,#636363"},
+                                     {"greys4","#f7f7f7,#cccccc,#969696,#525252"},
+                                     {"greys5","#f7f7f7,#cccccc,#969696,#636363,#252525"},
+                                     {"greys6","#f7f7f7,#d9d9d9,#bdbdbd,#969696,#636363,#252525"},
+                                     {"greys7","#f7f7f7,#d9d9d9,#bdbdbd,#969696,#737373,#525252,#252525"},
+                                     {"greys8","#ffffff,#f0f0f0,#d9d9d9,#bdbdbd,#969696,#737373,#525252,#252525"},
+                                     {"greys9","#ffffff,#f0f0f0,#d9d9d9,#bdbdbd,#969696,#737373,#525252,#252525,#000000"},
+                                     {"oranges3","#fee6ce,#fdae6b,#e6550d"},
+                                     {"oranges4","#feedde,#fdbe85,#fd8d3c,#d94701"},
+                                     {"oranges5","#feedde,#fdbe85,#fd8d3c,#e6550d,#a63603"},
+                                     {"oranges6","#feedde,#fdd0a2,#fdae6b,#fd8d3c,#e6550d,#a63603"},
+                                     {"oranges7","#feedde,#fdd0a2,#fdae6b,#fd8d3c,#f16913,#d94801,#8c2d04"},
+                                     {"oranges8","#fff5eb,#fee6ce,#fdd0a2,#fdae6b,#fd8d3c,#f16913,#d94801,#8c2d04"},
+                                     {"oranges9","#fff5eb,#fee6ce,#fdd0a2,#fdae6b,#fd8d3c,#f16913,#d94801,#a63603,#7f2704"},
+                                     {"orrd3","#fee8c8,#fdbb84,#e34a33"},
+                                     {"orrd4","#fef0d9,#fdcc8a,#fc8d59,#d7301f"},
+                                     {"orrd5","#fef0d9,#fdcc8a,#fc8d59,#e34a33,#b30000"},
+                                     {"orrd6","#fef0d9,#fdd49e,#fdbb84,#fc8d59,#e34a33,#b30000"},
+                                     {"orrd7","#fef0d9,#fdd49e,#fdbb84,#fc8d59,#ef6548,#d7301f,#990000"},
+                                     {"orrd8","#fff7ec,#fee8c8,#fdd49e,#fdbb84,#fc8d59,#ef6548,#d7301f,#990000"},
+                                     {"orrd9","#fff7ec,#fee8c8,#fdd49e,#fdbb84,#fc8d59,#ef6548,#d7301f,#b30000,#7f0000"},
+                                     {"paired10","#a6cee3,#1f78b4,#b2df8a,#33a02c,#fb9a99,#e31a1c,#fdbf6f,#ff7f00,#cab2d6,#6a3d9a"},
+                                     {"paired11","#a6cee3,#1f78b4,#b2df8a,#33a02c,#fb9a99,#e31a1c,#fdbf6f,#ff7f00,#cab2d6,#6a3d9a,#ffff99"},
+                                     {"paired12","#a6cee3,#1f78b4,#b2df8a,#33a02c,#fb9a99,#e31a1c,#fdbf6f,#ff7f00,#cab2d6,#6a3d9a,#ffff99,#b15928"},
+                                     {"paired3","#a6cee3,#1f78b4,#b2df8a"},
+                                     {"paired4","#a6cee3,#1f78b4,#b2df8a,#33a02c"},
+                                     {"paired5","#a6cee3,#1f78b4,#b2df8a,#33a02c,#fb9a99"},
+                                     {"paired6","#a6cee3,#1f78b4,#b2df8a,#33a02c,#fb9a99,#e31a1c"},
+                                     {"paired7","#a6cee3,#1f78b4,#b2df8a,#33a02c,#fb9a99,#e31a1c,#fdbf6f"},
+                                     {"paired8","#a6cee3,#1f78b4,#b2df8a,#33a02c,#fb9a99,#e31a1c,#fdbf6f,#ff7f00"},
+                                     {"paired9","#a6cee3,#1f78b4,#b2df8a,#33a02c,#fb9a99,#e31a1c,#fdbf6f,#ff7f00,#cab2d6"},
+                                     {"pastel13","#fbb4ae,#b3cde3,#ccebc5"},
+                                     {"pastel14","#fbb4ae,#b3cde3,#ccebc5,#decbe4"},
+                                     {"pastel15","#fbb4ae,#b3cde3,#ccebc5,#decbe4,#fed9a6"},
+                                     {"pastel16","#fbb4ae,#b3cde3,#ccebc5,#decbe4,#fed9a6,#ffffcc"},
+                                     {"pastel17","#fbb4ae,#b3cde3,#ccebc5,#decbe4,#fed9a6,#ffffcc,#e5d8bd"},
+                                     {"pastel18","#fbb4ae,#b3cde3,#ccebc5,#decbe4,#fed9a6,#ffffcc,#e5d8bd,#fddaec"},
+                                     {"pastel19","#fbb4ae,#b3cde3,#ccebc5,#decbe4,#fed9a6,#ffffcc,#e5d8bd,#fddaec,#f2f2f2"},
+                                     {"pastel23","#b3e2cd,#fdcdac,#cbd5e8"},
+                                     {"pastel24","#b3e2cd,#fdcdac,#cbd5e8,#f4cae4"},
+                                     {"pastel25","#b3e2cd,#fdcdac,#cbd5e8,#f4cae4,#e6f5c9"},
+                                     {"pastel26","#b3e2cd,#fdcdac,#cbd5e8,#f4cae4,#e6f5c9,#fff2ae"},
+                                     {"pastel27","#b3e2cd,#fdcdac,#cbd5e8,#f4cae4,#e6f5c9,#fff2ae,#f1e2cc"},
+                                     {"pastel28","#b3e2cd,#fdcdac,#cbd5e8,#f4cae4,#e6f5c9,#fff2ae,#f1e2cc,#cccccc"},
+                                     {"piyg10","#8e0152,#c51b7d,#de77ae,#f1b6da,#fde0ef,#e6f5d0,#b8e186,#7fbc41,#4d9221,#276419"},
+                                     {"piyg11","#8e0152,#c51b7d,#de77ae,#f1b6da,#fde0ef,#f7f7f7,#e6f5d0,#b8e186,#7fbc41,#4d9221,#276419"},
+                                     {"piyg3","#e9a3c9,#f7f7f7,#a1d76a"},
+                                     {"piyg4","#d01c8b,#f1b6da,#b8e186,#4dac26"},
+                                     {"piyg5","#d01c8b,#f1b6da,#f7f7f7,#b8e186,#4dac26"},
+                                     {"piyg6","#c51b7d,#e9a3c9,#fde0ef,#e6f5d0,#a1d76a,#4d9221"},
+                                     {"piyg7","#c51b7d,#e9a3c9,#fde0ef,#f7f7f7,#e6f5d0,#a1d76a,#4d9221"},
+                                     {"piyg8","#c51b7d,#de77ae,#f1b6da,#fde0ef,#e6f5d0,#b8e186,#7fbc41,#4d9221"},
+                                     {"piyg9","#c51b7d,#de77ae,#f1b6da,#fde0ef,#f7f7f7,#e6f5d0,#b8e186,#7fbc41,#4d9221"},
+                                     {"prgn10","#40004b,#762a83,#9970ab,#c2a5cf,#e7d4e8,#d9f0d3,#a6dba0,#5aae61,#1b7837,#00441b"},
+                                     {"prgn11","#40004b,#762a83,#9970ab,#c2a5cf,#e7d4e8,#f7f7f7,#d9f0d3,#a6dba0,#5aae61,#1b7837,#00441b"},
+                                     {"prgn3","#af8dc3,#f7f7f7,#7fbf7b"},
+                                     {"prgn4","#7b3294,#c2a5cf,#a6dba0,#008837"},
+                                     {"prgn5","#7b3294,#c2a5cf,#f7f7f7,#a6dba0,#008837"},
+                                     {"prgn6","#762a83,#af8dc3,#e7d4e8,#d9f0d3,#7fbf7b,#1b7837"},
+                                     {"prgn7","#762a83,#af8dc3,#e7d4e8,#f7f7f7,#d9f0d3,#7fbf7b,#1b7837"},
+                                     {"prgn8","#762a83,#9970ab,#c2a5cf,#e7d4e8,#d9f0d3,#a6dba0,#5aae61,#1b7837"},
+                                     {"prgn9","#762a83,#9970ab,#c2a5cf,#e7d4e8,#f7f7f7,#d9f0d3,#a6dba0,#5aae61,#1b7837"},
+                                     {"pubu3","#ece7f2,#a6bddb,#2b8cbe"},
+                                     {"pubu4","#f1eef6,#bdc9e1,#74a9cf,#0570b0"},
+                                     {"pubu5","#f1eef6,#bdc9e1,#74a9cf,#2b8cbe,#045a8d"},
+                                     {"pubu6","#f1eef6,#d0d1e6,#a6bddb,#74a9cf,#2b8cbe,#045a8d"},
+                                     {"pubu7","#f1eef6,#d0d1e6,#a6bddb,#74a9cf,#3690c0,#0570b0,#034e7b"},
+                                     {"pubu8","#fff7fb,#ece7f2,#d0d1e6,#a6bddb,#74a9cf,#3690c0,#0570b0,#034e7b"},
+                                     {"pubu9","#fff7fb,#ece7f2,#d0d1e6,#a6bddb,#74a9cf,#3690c0,#0570b0,#045a8d,#023858"},
+                                     {"pubugn3","#ece2f0,#a6bddb,#1c9099"},
+                                     {"pubugn4","#f6eff7,#bdc9e1,#67a9cf,#02818a"},
+                                     {"pubugn5","#f6eff7,#bdc9e1,#67a9cf,#1c9099,#016c59"},
+                                     {"pubugn6","#f6eff7,#d0d1e6,#a6bddb,#67a9cf,#1c9099,#016c59"},
+                                     {"pubugn7","#f6eff7,#d0d1e6,#a6bddb,#67a9cf,#3690c0,#02818a,#016450"},
+                                     {"pubugn8","#fff7fb,#ece2f0,#d0d1e6,#a6bddb,#67a9cf,#3690c0,#02818a,#016450"},
+                                     {"pubugn9","#fff7fb,#ece2f0,#d0d1e6,#a6bddb,#67a9cf,#3690c0,#02818a,#016c59,#014636"},
+                                     {"puor10","#7f3b08,#b35806,#e08214,#fdb863,#fee0b6,#d8daeb,#b2abd2,#8073ac,#542788,#2d004b"},
+                                     {"puor11","#7f3b08,#b35806,#e08214,#fdb863,#fee0b6,#f7f7f7,#d8daeb,#b2abd2,#8073ac,#542788,#2d004b"},
+                                     {"puor3","#f1a340,#f7f7f7,#998ec3"},
+                                     {"puor4","#e66101,#fdb863,#b2abd2,#5e3c99"},
+                                     {"puor5","#e66101,#fdb863,#f7f7f7,#b2abd2,#5e3c99"},
+                                     {"puor6","#b35806,#f1a340,#fee0b6,#d8daeb,#998ec3,#542788"},
+                                     {"puor7","#b35806,#f1a340,#fee0b6,#f7f7f7,#d8daeb,#998ec3,#542788"},
+                                     {"puor8","#b35806,#e08214,#fdb863,#fee0b6,#d8daeb,#b2abd2,#8073ac,#542788"},
+                                     {"puor9","#b35806,#e08214,#fdb863,#fee0b6,#f7f7f7,#d8daeb,#b2abd2,#8073ac,#542788"},
+                                     {"purd3","#e7e1ef,#c994c7,#dd1c77"},
+                                     {"purd4","#f1eef6,#d7b5d8,#df65b0,#ce1256"},
+                                     {"purd5","#f1eef6,#d7b5d8,#df65b0,#dd1c77,#980043"},
+                                     {"purd6","#f1eef6,#d4b9da,#c994c7,#df65b0,#dd1c77,#980043"},
+                                     {"purd7","#f1eef6,#d4b9da,#c994c7,#df65b0,#e7298a,#ce1256,#91003f"},
+                                     {"purd8","#f7f4f9,#e7e1ef,#d4b9da,#c994c7,#df65b0,#e7298a,#ce1256,#91003f"},
+                                     {"purd9","#f7f4f9,#e7e1ef,#d4b9da,#c994c7,#df65b0,#e7298a,#ce1256,#980043,#67001f"},
+                                     {"purples3","#efedf5,#bcbddc,#756bb1"},
+                                     {"purples4","#f2f0f7,#cbc9e2,#9e9ac8,#6a51a3"},
+                                     {"purples5","#f2f0f7,#cbc9e2,#9e9ac8,#756bb1,#54278f"},
+                                     {"purples6","#f2f0f7,#dadaeb,#bcbddc,#9e9ac8,#756bb1,#54278f"},
+                                     {"purples7","#f2f0f7,#dadaeb,#bcbddc,#9e9ac8,#807dba,#6a51a3,#4a1486"},
+                                     {"purples8","#fcfbfd,#efedf5,#dadaeb,#bcbddc,#9e9ac8,#807dba,#6a51a3,#4a1486"},
+                                     {"purples9","#fcfbfd,#efedf5,#dadaeb,#bcbddc,#9e9ac8,#807dba,#6a51a3,#54278f,#3f007d"},
+                                     {"rdbu10","#67001f,#b2182b,#d6604d,#f4a582,#fddbc7,#d1e5f0,#92c5de,#4393c3,#2166ac,#053061"},
+                                     {"rdbu11","#67001f,#b2182b,#d6604d,#f4a582,#fddbc7,#f7f7f7,#d1e5f0,#92c5de,#4393c3,#2166ac,#053061"},
+                                     {"rdbu3","#ef8a62,#f7f7f7,#67a9cf"},
+                                     {"rdbu4","#ca0020,#f4a582,#92c5de,#0571b0"},
+                                     {"rdbu5","#ca0020,#f4a582,#f7f7f7,#92c5de,#0571b0"},
+                                     {"rdbu6","#b2182b,#ef8a62,#fddbc7,#d1e5f0,#67a9cf,#2166ac"},
+                                     {"rdbu7","#b2182b,#ef8a62,#fddbc7,#f7f7f7,#d1e5f0,#67a9cf,#2166ac"},
+                                     {"rdbu8","#b2182b,#d6604d,#f4a582,#fddbc7,#d1e5f0,#92c5de,#4393c3,#2166ac"},
+                                     {"rdbu9","#b2182b,#d6604d,#f4a582,#fddbc7,#f7f7f7,#d1e5f0,#92c5de,#4393c3,#2166ac"},
+                                     {"rdgy10","#67001f,#b2182b,#d6604d,#f4a582,#fddbc7,#e0e0e0,#bababa,#878787,#4d4d4d,#1a1a1a"},
+                                     {"rdgy11","#67001f,#b2182b,#d6604d,#f4a582,#fddbc7,#ffffff,#e0e0e0,#bababa,#878787,#4d4d4d,#1a1a1a"},
+                                     {"rdgy3","#ef8a62,#ffffff,#999999"},
+                                     {"rdgy4","#ca0020,#f4a582,#bababa,#404040"},
+                                     {"rdgy5","#ca0020,#f4a582,#ffffff,#bababa,#404040"},
+                                     {"rdgy6","#b2182b,#ef8a62,#fddbc7,#e0e0e0,#999999,#4d4d4d"},
+                                     {"rdgy7","#b2182b,#ef8a62,#fddbc7,#ffffff,#e0e0e0,#999999,#4d4d4d"},
+                                     {"rdgy8","#b2182b,#d6604d,#f4a582,#fddbc7,#e0e0e0,#bababa,#878787,#4d4d4d"},
+                                     {"rdgy9","#b2182b,#d6604d,#f4a582,#fddbc7,#ffffff,#e0e0e0,#bababa,#878787,#4d4d4d"},
+                                     {"rdpu3","#fde0dd,#fa9fb5,#c51b8a"},
+                                     {"rdpu4","#feebe2,#fbb4b9,#f768a1,#ae017e"},
+                                     {"rdpu5","#feebe2,#fbb4b9,#f768a1,#c51b8a,#7a0177"},
+                                     {"rdpu6","#feebe2,#fcc5c0,#fa9fb5,#f768a1,#c51b8a,#7a0177"},
+                                     {"rdpu7","#feebe2,#fcc5c0,#fa9fb5,#f768a1,#dd3497,#ae017e,#7a0177"},
+                                     {"rdpu8","#fff7f3,#fde0dd,#fcc5c0,#fa9fb5,#f768a1,#dd3497,#ae017e,#7a0177"},
+                                     {"rdpu9","#fff7f3,#fde0dd,#fcc5c0,#fa9fb5,#f768a1,#dd3497,#ae017e,#7a0177,#49006a"},
+                                     {"rdylbu10","#a50026,#d73027,#f46d43,#fdae61,#fee090,#e0f3f8,#abd9e9,#74add1,#4575b4,#313695"},
+                                     {"rdylbu11","#a50026,#d73027,#f46d43,#fdae61,#fee090,#ffffbf,#e0f3f8,#abd9e9,#74add1,#4575b4,#313695"},
+                                     {"rdylbu3","#fc8d59,#ffffbf,#91bfdb"},
+                                     {"rdylbu4","#d7191c,#fdae61,#abd9e9,#2c7bb6"},
+                                     {"rdylbu5","#d7191c,#fdae61,#ffffbf,#abd9e9,#2c7bb6"},
+                                     {"rdylbu6","#d73027,#fc8d59,#fee090,#e0f3f8,#91bfdb,#4575b4"},
+                                     {"rdylbu7","#d73027,#fc8d59,#fee090,#ffffbf,#e0f3f8,#91bfdb,#4575b4"},
+                                     {"rdylbu8","#d73027,#f46d43,#fdae61,#fee090,#e0f3f8,#abd9e9,#74add1,#4575b4"},
+                                     {"rdylbu9","#d73027,#f46d43,#fdae61,#fee090,#ffffbf,#e0f3f8,#abd9e9,#74add1,#4575b4"},
+                                     {"rdylgn10","#a50026,#d73027,#f46d43,#fdae61,#fee08b,#d9ef8b,#a6d96a,#66bd63,#1a9850,#006837"},
+                                     {"rdylgn11","#a50026,#d73027,#f46d43,#fdae61,#fee08b,#ffffbf,#d9ef8b,#a6d96a,#66bd63,#1a9850,#006837"},
+                                     {"rdylgn3","#fc8d59,#ffffbf,#91cf60"},
+                                     {"rdylgn4","#d7191c,#fdae61,#a6d96a,#1a9641"},
+                                     {"rdylgn5","#d7191c,#fdae61,#ffffbf,#a6d96a,#1a9641"},
+                                     {"rdylgn6","#d73027,#fc8d59,#fee08b,#d9ef8b,#91cf60,#1a9850"},
+                                     {"rdylgn7","#d73027,#fc8d59,#fee08b,#ffffbf,#d9ef8b,#91cf60,#1a9850"},
+                                     {"rdylgn8","#d73027,#f46d43,#fdae61,#fee08b,#d9ef8b,#a6d96a,#66bd63,#1a9850"},
+                                     {"rdylgn9","#d73027,#f46d43,#fdae61,#fee08b,#ffffbf,#d9ef8b,#a6d96a,#66bd63,#1a9850"},
+                                     {"reds3","#fee0d2,#fc9272,#de2d26"},
+                                     {"reds4","#fee5d9,#fcae91,#fb6a4a,#cb181d"},
+                                     {"reds5","#fee5d9,#fcae91,#fb6a4a,#de2d26,#a50f15"},
+                                     {"reds6","#fee5d9,#fcbba1,#fc9272,#fb6a4a,#de2d26,#a50f15"},
+                                     {"reds7","#fee5d9,#fcbba1,#fc9272,#fb6a4a,#ef3b2c,#cb181d,#99000d"},
+                                     {"reds8","#fff5f0,#fee0d2,#fcbba1,#fc9272,#fb6a4a,#ef3b2c,#cb181d,#99000d"},
+                                     {"reds9","#fff5f0,#fee0d2,#fcbba1,#fc9272,#fb6a4a,#ef3b2c,#cb181d,#a50f15,#67000d"},
+                                     {"set13","#e41a1c,#377eb8,#4daf4a"},
+                                     {"set14","#e41a1c,#377eb8,#4daf4a,#984ea3"},
+                                     {"set15","#e41a1c,#377eb8,#4daf4a,#984ea3,#ff7f00"},
+                                     {"set16","#e41a1c,#377eb8,#4daf4a,#984ea3,#ff7f00,#ffff33"},
+                                     {"set17","#e41a1c,#377eb8,#4daf4a,#984ea3,#ff7f00,#ffff33,#a65628"},
+                                     {"set18","#e41a1c,#377eb8,#4daf4a,#984ea3,#ff7f00,#ffff33,#a65628,#f781bf"},
+                                     {"set19","#e41a1c,#377eb8,#4daf4a,#984ea3,#ff7f00,#ffff33,#a65628,#f781bf,#999999"},
+                                     {"set23","#66c2a5,#fc8d62,#8da0cb"},
+                                     {"set24","#66c2a5,#fc8d62,#8da0cb,#e78ac3"},
+                                     {"set25","#66c2a5,#fc8d62,#8da0cb,#e78ac3,#a6d854"},
+                                     {"set26","#66c2a5,#fc8d62,#8da0cb,#e78ac3,#a6d854,#ffd92f"},
+                                     {"set27","#66c2a5,#fc8d62,#8da0cb,#e78ac3,#a6d854,#ffd92f,#e5c494"},
+                                     {"set28","#66c2a5,#fc8d62,#8da0cb,#e78ac3,#a6d854,#ffd92f,#e5c494,#b3b3b3"},
+                                     {"set310","#8dd3c7,#ffffb3,#bebada,#fb8072,#80b1d3,#fdb462,#b3de69,#fccde5,#d9d9d9,#bc80bd"},
+                                     {"set311","#8dd3c7,#ffffb3,#bebada,#fb8072,#80b1d3,#fdb462,#b3de69,#fccde5,#d9d9d9,#bc80bd,#ccebc5"},
+                                     {"set312","#8dd3c7,#ffffb3,#bebada,#fb8072,#80b1d3,#fdb462,#b3de69,#fccde5,#d9d9d9,#bc80bd,#ccebc5,#ffed6f"},
+                                     {"set33","#8dd3c7,#ffffb3,#bebada"},
+                                     {"set34","#8dd3c7,#ffffb3,#bebada,#fb8072"},
+                                     {"set35","#8dd3c7,#ffffb3,#bebada,#fb8072,#80b1d3"},
+                                     {"set36","#8dd3c7,#ffffb3,#bebada,#fb8072,#80b1d3,#fdb462"},
+                                     {"set37","#8dd3c7,#ffffb3,#bebada,#fb8072,#80b1d3,#fdb462,#b3de69"},
+                                     {"set38","#8dd3c7,#ffffb3,#bebada,#fb8072,#80b1d3,#fdb462,#b3de69,#fccde5"},
+                                     {"set39","#8dd3c7,#ffffb3,#bebada,#fb8072,#80b1d3,#fdb462,#b3de69,#fccde5,#d9d9d9"},
+                                     {"spectral10","#9e0142,#d53e4f,#f46d43,#fdae61,#fee08b,#e6f598,#abdda4,#66c2a5,#3288bd,#5e4fa2"},
+                                     {"spectral11","#9e0142,#d53e4f,#f46d43,#fdae61,#fee08b,#ffffbf,#e6f598,#abdda4,#66c2a5,#3288bd,#5e4fa2"},
+                                     {"spectral3","#fc8d59,#ffffbf,#99d594"},
+                                     {"spectral4","#d7191c,#fdae61,#abdda4,#2b83ba"},
+                                     {"spectral5","#d7191c,#fdae61,#ffffbf,#abdda4,#2b83ba"},
+                                     {"spectral6","#d53e4f,#fc8d59,#fee08b,#e6f598,#99d594,#3288bd"},
+                                     {"spectral7","#d53e4f,#fc8d59,#fee08b,#ffffbf,#e6f598,#99d594,#3288bd"},
+                                     {"spectral8","#d53e4f,#f46d43,#fdae61,#fee08b,#e6f598,#abdda4,#66c2a5,#3288bd"},
+                                     {"spectral9","#d53e4f,#f46d43,#fdae61,#fee08b,#ffffbf,#e6f598,#abdda4,#66c2a5,#3288bd"},
+                                     {"ylgn3","#f7fcb9,#addd8e,#31a354"},
+                                     {"ylgn4","#ffffcc,#c2e699,#78c679,#238443"},
+                                     {"ylgn5","#ffffcc,#c2e699,#78c679,#31a354,#006837"},
+                                     {"ylgn6","#ffffcc,#d9f0a3,#addd8e,#78c679,#31a354,#006837"},
+                                     {"ylgn7","#ffffcc,#d9f0a3,#addd8e,#78c679,#41ab5d,#238443,#005a32"},
+                                     {"ylgn8","#ffffe5,#f7fcb9,#d9f0a3,#addd8e,#78c679,#41ab5d,#238443,#005a32"},
+                                     {"ylgn9","#ffffe5,#f7fcb9,#d9f0a3,#addd8e,#78c679,#41ab5d,#238443,#006837,#004529"},
+                                     {"ylgnbu3","#edf8b1,#7fcdbb,#2c7fb8"},
+                                     {"ylgnbu4","#ffffcc,#a1dab4,#41b6c4,#225ea8"},
+                                     {"ylgnbu5","#ffffcc,#a1dab4,#41b6c4,#2c7fb8,#253494"},
+                                     {"ylgnbu6","#ffffcc,#c7e9b4,#7fcdbb,#41b6c4,#2c7fb8,#253494"},
+                                     {"ylgnbu7","#ffffcc,#c7e9b4,#7fcdbb,#41b6c4,#1d91c0,#225ea8,#0c2c84"},
+                                     {"ylgnbu8","#ffffd9,#edf8b1,#c7e9b4,#7fcdbb,#41b6c4,#1d91c0,#225ea8,#0c2c84"},
+                                     {"ylgnbu9","#ffffd9,#edf8b1,#c7e9b4,#7fcdbb,#41b6c4,#1d91c0,#225ea8,#253494,#081d58"},
+                                     {"ylorbr3","#fff7bc,#fec44f,#d95f0e"},
+                                     {"ylorbr4","#ffffd4,#fed98e,#fe9929,#cc4c02"},
+                                     {"ylorbr5","#ffffd4,#fed98e,#fe9929,#d95f0e,#993404"},
+                                     {"ylorbr6","#ffffd4,#fee391,#fec44f,#fe9929,#d95f0e,#993404"},
+                                     {"ylorbr7","#ffffd4,#fee391,#fec44f,#fe9929,#ec7014,#cc4c02,#8c2d04"},
+                                     {"ylorbr8","#ffffe5,#fff7bc,#fee391,#fec44f,#fe9929,#ec7014,#cc4c02,#8c2d04"},
+                                     {"ylorbr9","#ffffe5,#fff7bc,#fee391,#fec44f,#fe9929,#ec7014,#cc4c02,#993404,#662506"},
+                                     {"ylorrd3","#ffeda0,#feb24c,#f03b20"},
+                                     {"ylorrd4","#ffffb2,#fecc5c,#fd8d3c,#e31a1c"},
+                                     {"ylorrd5","#ffffb2,#fecc5c,#fd8d3c,#f03b20,#bd0026"},
+                                     {"ylorrd6","#ffffb2,#fed976,#feb24c,#fd8d3c,#f03b20,#bd0026"},
+                                     {"ylorrd7","#ffffb2,#fed976,#feb24c,#fd8d3c,#fc4e2a,#e31a1c,#b10026"},
+                                     {"ylorrd8","#ffffcc,#ffeda0,#fed976,#feb24c,#fd8d3c,#fc4e2a,#e31a1c,#b10026"},
+                                     {"ylorrd9","#ffffcc,#ffeda0,#fed976,#feb24c,#fd8d3c,#fc4e2a,#e31a1c,#bd0026,#800026"}};
 
 
 
index bf2c6333ad670b5623a49266f701e79606e21e71..a0ae7106d83ed165f965adcd8606f657a318aa3c 100644 (file)
@@ -207,7 +207,7 @@ int comp_ascend_int(const void *s1, const void *s2){
 
 
 void vector_ordering(int n, real *v, int **p, int ascending){
-  /* give the position of the lagest, second largest etc in vector v if ascending = TRUE
+  /* give the position of the lagest, second largest etc in vector v if ascending = FALSE
 
      or
 
@@ -298,6 +298,7 @@ real point_distance(real *p1, real *p2, int dim){
 
 char *strip_dir(char *s){
   int i, first = TRUE;
+  if (!s) return s;
   for (i = strlen(s); i >= 0; i--) {
     if (first && s[i] == '.') {/* get rid of .mtx */
       s[i] = '\0';
@@ -342,3 +343,24 @@ void scale_to_box(real xmin, real ymin, real xmax, real ymax, int n, int dim, re
   
   
 }
+
+int digitsQ(char *s){
+  while (*s && *s - '0' >= 0 && *s - '0' <= 9) {
+    s++;
+  }
+  if (*s) return 0;
+  return 1;
+}
+int validQ_int_string(char *to_convert, int *v){
+  /* check to see if this is a string is integer */
+  char *p = to_convert;
+  int errno = 0;
+  long val = strtoul(to_convert, &p, 10);
+  if (errno != 0 ||// conversion failed (EINVAL, ERANGE)
+      to_convert == p || // conversion failed (no characters consumed)
+      *p != 0
+      ) return 0;
+  if (val > INT_MAX || val < INT_MIN) return 0;
+  *v = (int) val;
+  return 1;
+}