]> granicus.if.org Git - graphviz/commitdiff
sparse: take 'jcn' as a value instead of pointer
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 23 May 2022 00:54:34 +0000 (17:54 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 27 May 2022 01:05:23 +0000 (18:05 -0700)
cmd/gvmap/country_graph_coloring.c
cmd/gvmap/make_map.c
lib/edgepaint/edge_distinct_coloring.c
lib/mingle/agglomerative_bundling.cpp
lib/mingle/edge_bundling.cpp
lib/neatogen/call_tri.c
lib/neatogen/overlap.c
lib/sparse/SparseMatrix.c
lib/sparse/SparseMatrix.h
lib/sparse/clustering.c
lib/sparse/mq.c

index 0102ddad2c27117d69360e59f27a2685e3c3032c..f5ad497e582941c66c659e06e474b1ecbf896af4 100644 (file)
@@ -127,10 +127,10 @@ static void country_graph_coloring_internal(int seed, SparseMatrix A, int **p){
       jj = ja[j];
       if (jj != i){
        nrow ++;
-       L = SparseMatrix_coordinate_form_add_entry(L, i, &jj, &a);
+       L = SparseMatrix_coordinate_form_add_entry(L, i, jj, &a);
       }
     }
-    L = SparseMatrix_coordinate_form_add_entry(L, i, &i, &nrow);
+    L = SparseMatrix_coordinate_form_add_entry(L, i, i, &nrow);
   }
   L = SparseMatrix_from_coordinate_format(L);
 
index 3cac241c509ff35567e0263cd33b4521485370dc..602808711d392db9154fc455cde25ab0c1ad029c 100644 (file)
@@ -207,8 +207,8 @@ static SparseMatrix matrix_add_entry(SparseMatrix A, int i, int j, int val){
   if (i < j) {
     i1 = j; j1 = i;
   }
-  A = SparseMatrix_coordinate_form_add_entry(A, j1, &i1, &val);
-  return SparseMatrix_coordinate_form_add_entry(A, i1, &j1, &val);
+  A = SparseMatrix_coordinate_form_add_entry(A, j1, i1, &val);
+  return SparseMatrix_coordinate_form_add_entry(A, i1, j1, &val);
 }
 
 static void plot_dot_edges(FILE *f, SparseMatrix A){
@@ -428,12 +428,12 @@ static SparseMatrix get_country_graph(int n, SparseMatrix A, int *groups, int GR
   ja = A->ja;
   for (i = 0; i < n; i++){
     ig1 = groups[i]-1;/* add a diagonal entry */
-    SparseMatrix_coordinate_form_add_entry(B, ig1, &ig1, &one);
+    SparseMatrix_coordinate_form_add_entry(B, ig1, ig1, &one);
     for (j = ia[i]; j < ia[i+1]; j++){
       jj = ja[j];
       if (i != jj && groups[i] != groups[jj] && groups[jj] != GRP_RANDOM && groups[jj] != GRP_BBOX){
        ig1 = groups[i]-1; ig2 = groups[jj]-1;
-       SparseMatrix_coordinate_form_add_entry(B, ig1, &ig2, &one);
+       SparseMatrix_coordinate_form_add_entry(B, ig1, ig2, &one);
       }
     }
   }
@@ -456,7 +456,7 @@ static void conn_comp(int n, SparseMatrix A, int *groups, SparseMatrix *poly_poi
     for (j = ia[i]; j < ia[i+1]; j++){
       jj = ja[j];
       if (i != jj && groups[i] == groups[jj]){
-       SparseMatrix_coordinate_form_add_entry(B, i, &jj, &one);
+       SparseMatrix_coordinate_form_add_entry(B, i, jj, &one);
       }
     }
   }
@@ -591,7 +591,7 @@ static void get_poly_lines(int exclude_random, int nt, SparseMatrix graph, Spars
        } else {
          ipoly2 = ipoly;
        }
-       SparseMatrix_coordinate_form_add_entry(*poly_lines, i, &cur, &ipoly2);
+       SparseMatrix_coordinate_form_add_entry(*poly_lines, i, cur, &ipoly2);
        while (next != sta){
          mask[next] = i;
          
@@ -600,7 +600,7 @@ static void get_poly_lines(int exclude_random, int nt, SparseMatrix graph, Spars
          } else {
            ipoly2 = ipoly;
          }
-         SparseMatrix_coordinate_form_add_entry(*poly_lines, i, &next, &ipoly2);
+         SparseMatrix_coordinate_form_add_entry(*poly_lines, i, next, &ipoly2);
 
          nn = neighbor(next, 0, edim, elist);
          nlink = 0;
@@ -619,7 +619,7 @@ static void get_poly_lines(int exclude_random, int nt, SparseMatrix graph, Spars
        } else {
          ipoly2 = ipoly;
        }
-       SparseMatrix_coordinate_form_add_entry(*poly_lines, i, &sta, &ipoly2);/* complete a cycle by adding starting point */
+       SparseMatrix_coordinate_form_add_entry(*poly_lines, i, sta, &ipoly2);/* complete a cycle by adding starting point */
 
        ipoly++;
       }
@@ -732,14 +732,14 @@ static void get_polygon_solids(int nt, SparseMatrix E, int ncomps, int *comps_pt
        assert(jj < n);
        edge_table[ne*2] = t1;/*t1->t2*/
        edge_table[ne*2+1] = t2;
-       half_edges = SparseMatrix_coordinate_form_add_entry(half_edges, i, &jj, &ne);
-       half_edges = SparseMatrix_coordinate_form_add_entry(half_edges, jj, &i, &ne);
+       half_edges = SparseMatrix_coordinate_form_add_entry(half_edges, i, jj, &ne);
+       half_edges = SparseMatrix_coordinate_form_add_entry(half_edges, jj, i, &ne);
        ne++;
 
        edge_table[ne*2] = t2;/*t2->t1*/
        edge_table[ne*2+1] = t1;
-       half_edges = SparseMatrix_coordinate_form_add_entry(half_edges, i, &jj, &ne);
-       half_edges = SparseMatrix_coordinate_form_add_entry(half_edges, jj, &i, &ne);   
+       half_edges = SparseMatrix_coordinate_form_add_entry(half_edges, i, jj, &ne);
+       half_edges = SparseMatrix_coordinate_form_add_entry(half_edges, jj, i, &ne);    
 
 
        ne++;
@@ -918,13 +918,13 @@ static void get_polygon_solids(int nt, SparseMatrix E, int ncomps, int *comps_pt
     while ((enext = cycle_next(ecur)) != cycle_head){
       edge_cycle_map[ecur] = NOT_ON_CYCLE;
       head = edge_head(ecur);
-      SparseMatrix_coordinate_form_add_entry(*polys, i, &head, &i);
+      SparseMatrix_coordinate_form_add_entry(*polys, i, head, &i);
       ecur = enext;
     }
     edge_cycle_map[ecur] = NOT_ON_CYCLE;
     head = edge_head(ecur); tail = edge_tail(ecur);
-    SparseMatrix_coordinate_form_add_entry(*polys, i, &head, &i);
-    SparseMatrix_coordinate_form_add_entry(*polys, i, &tail, &i);
+    SparseMatrix_coordinate_form_add_entry(*polys, i, head, &i);
+    SparseMatrix_coordinate_form_add_entry(*polys, i, tail, &i);
 
 
     /* unset edge_map */
index 123c5b1d5c9b16192b157f69b516693db7f4c684..317045961a2da21dda1cf6126fdc7bb25d535112 100644 (file)
@@ -200,7 +200,7 @@ Agraph_t* edge_distinct_coloring(char *color_scheme, char *lightness, Agraph_t*
       for (j = i+1; j < nz2; j++){
        u2 = irn[j]; v2 = jcn[j];
        if (splines_intersect(dim, u1, v1, u2, v2, cos_critical, check_edges_with_same_endpoint, xsplines[i], xsplines[j])){
-         B = SparseMatrix_coordinate_form_add_entry(B, i, &j, &cos_a);
+         B = SparseMatrix_coordinate_form_add_entry(B, i, j, &cos_a);
        }
       }
     }
@@ -222,7 +222,7 @@ Agraph_t* edge_distinct_coloring(char *color_scheme, char *lightness, Agraph_t*
        cos_a = intersection_angle(&(x[dim*u1]), &(x[dim*v1]), &(x[dim*u2]), &(x[dim*v2]));
        if (!check_edges_with_same_endpoint && cos_a >= -1) cos_a = fabs(cos_a);
        if (cos_a > cos_critical) {
-         B = SparseMatrix_coordinate_form_add_entry(B, i, &j, &cos_a);
+         B = SparseMatrix_coordinate_form_add_entry(B, i, j, &cos_a);
        }
       }
     }
index db6cc0cf782b691e304e09e784a8445b05879c43..3420279f4065eb8570864569dc14d9c383a9169f 100644 (file)
@@ -240,7 +240,7 @@ static Agglomerative_Ink_Bundling Agglomerative_Ink_Bundling_establish(Agglomera
     R1 = SparseMatrix_new(nc, n, 1, MATRIX_TYPE_REAL, FORMAT_COORD);
     for (i = 0; i < n; i++){
       jj = matching[i];
-      SparseMatrix_coordinate_form_add_entry(R1, jj, &i, &one);
+      SparseMatrix_coordinate_form_add_entry(R1, jj, i, &one);
     }
     R = SparseMatrix_from_coordinate_format(R1);
     SparseMatrix_delete(R1);
index 97c854405801dec4bcb1de921ed24df038d4a286..0d232e73ea02ee323775b0d4f38b3d481a2fe72d 100644 (file)
@@ -535,7 +535,7 @@ static pedge* modularity_ink_bundling(int dim, int ne, SparseMatrix B, pedge* ed
   
   for (i = 0; i < ne; i++){
     jj = assignment[i];
-    SparseMatrix_coordinate_form_add_entry(C, jj, &i, NULL);
+    SparseMatrix_coordinate_form_add_entry(C, jj, i, NULL);
   }
   
   D = SparseMatrix_from_coordinate_format(C);
@@ -590,8 +590,8 @@ static SparseMatrix check_compatibility(SparseMatrix A, int ne, pedge *edges, in
       } 
 
       if (fabs(dist) > tol){
-       B = SparseMatrix_coordinate_form_add_entry(B, i, &jj, &dist);
-       B = SparseMatrix_coordinate_form_add_entry(B, jj, &i, &dist);
+       B = SparseMatrix_coordinate_form_add_entry(B, i, jj, &dist);
+       B = SparseMatrix_coordinate_form_add_entry(B, jj, i, &dist);
       }
     }
   }
index 24ec0a61cfd94cfc4b59abdd0d5fed0ffa28c767..419ef40de32693abe766a3a79ba56e831eda6e48 100644 (file)
@@ -41,15 +41,15 @@ SparseMatrix call_tri(int n, int dim, double * x)
     for (i = 0; i < numberofedges; i++) {
        ii = edgelist[i * 2];
        jj = edgelist[i * 2 + 1];
-       SparseMatrix_coordinate_form_add_entry(A, ii, &(jj), &one);
+       SparseMatrix_coordinate_form_add_entry(A, ii, jj, &one);
     }
     if (n == 2) {              /* if two points, add edge i->j */
        ii = 0;
        jj = 1;
-       SparseMatrix_coordinate_form_add_entry(A, ii, &(jj), &one);
+       SparseMatrix_coordinate_form_add_entry(A, ii, jj, &one);
     }
     for (i = 0; i < n; i++) {
-       SparseMatrix_coordinate_form_add_entry(A, i, &i, &one);
+       SparseMatrix_coordinate_form_add_entry(A, i, i, &one);
     }
     B = SparseMatrix_from_coordinate_format(A);
     SparseMatrix_delete(A);
@@ -85,13 +85,11 @@ SparseMatrix call_tri2(int n, int dim, double * xx)
 
     for (i = 0; i < n; i++) {
        for (j = 1; j < delaunay[i].nedges; j++) {
-           SparseMatrix_coordinate_form_add_entry(A, i,
-                                                    &(delaunay[i].
-                                                      edges[j]), &one);
+           SparseMatrix_coordinate_form_add_entry(A, i, delaunay[i].edges[j], &one);
        }
     }
     for (i = 0; i < n; i++) {
-       SparseMatrix_coordinate_form_add_entry(A, i, &i, &one);
+       SparseMatrix_coordinate_form_add_entry(A, i, i, &one);
     }
     B = SparseMatrix_from_coordinate_format(A);
     B = SparseMatrix_symmetrize(B, false);
index 52a93755e1c226ad61375b5dd0458873adb0dd25..45999ee70bd52fb00db68011a51f5cf1e8297068 100644 (file)
@@ -204,7 +204,7 @@ static SparseMatrix get_overlap_graph(int dim, int n, double *x, double *width,
 #endif
        if (neighbor != k){
          if (fabs(0.5*(bsta+bsto) - 0.5*(bbsta+bbsto)) < 0.5*(bsto-bsta) + 0.5*(bbsto-bbsta)){/* if the distance of the centers of the interval is less than sum of width, we have overlap */
-           A = SparseMatrix_coordinate_form_add_entry(A, neighbor, &k, &one);
+           A = SparseMatrix_coordinate_form_add_entry(A, neighbor, k, &one);
 #ifdef DEBUG_RBTREE
            fprintf(stderr,"======================================  %d %d\n",k,neighbor);
 #endif
index c7ea69f893086439a17aa8bbbdda3201886d9d26..f05d9a74c18f5c2c48f4a69b7e10e46724130f27 100644 (file)
@@ -1596,7 +1596,7 @@ SparseMatrix SparseMatrix_sum_repeat_entries(SparseMatrix A, int what_to_sum){
 }
 
 SparseMatrix SparseMatrix_coordinate_form_add_entry(SparseMatrix A, int irn,
-                                                    int *jcn, void *val) {
+                                                    int jcn, void *val) {
   int nz, nzmax;
 
   static const int nentries = 1;
@@ -1610,10 +1610,10 @@ SparseMatrix SparseMatrix_coordinate_form_add_entry(SparseMatrix A, int irn,
     A = SparseMatrix_realloc(A, nzmax);
   }
   A->ia[nz] = irn;
-  A->ja[nz] = *jcn;
+  A->ja[nz] = jcn;
   if (A->size) memcpy((char*) A->a + ((size_t)nz)*A->size/sizeof(char), val, A->size*((size_t)nentries));
   if (irn >= A->m) A->m = irn + 1;
-  if (jcn[0] >= A->n) A->n = jcn[0] + 1;
+  if (jcn >= A->n) A->n = jcn + 1;
   A->nz += nentries;
   return A;
 }
@@ -2594,7 +2594,7 @@ SparseMatrix SparseMatrix_distance_matrix_khops(int khops, SparseMatrix D0, int
       for (i = 0; i < nlevel; i++) {
        for (j = levelset_ptr[i]; j < levelset_ptr[i+1]; j++){
          itmp = levelset[j]; dtmp = i;
-         if (k != itmp) B = SparseMatrix_coordinate_form_add_entry(B, k, &itmp, &dtmp);
+         if (k != itmp) B = SparseMatrix_coordinate_form_add_entry(B, k, itmp, &dtmp);
        }
       }
      }
@@ -2629,7 +2629,7 @@ SparseMatrix SparseMatrix_distance_matrix_khops(int khops, SparseMatrix D0, int
       }
       for (j = 0; j < nlist; j++){
        itmp = list[j]; dtmp = dist[itmp];
-       if (k != itmp) B = SparseMatrix_coordinate_form_add_entry(B, k, &itmp, &dtmp);
+       if (k != itmp) B = SparseMatrix_coordinate_form_add_entry(B, k, itmp, &dtmp);
       }
    }
   }
index ce03b89e3ddf8ffd20631e1e7b561729a200f9fe..7c0840a0c4967e395a05a2d2baa17043b413bc2a 100644 (file)
@@ -69,7 +69,7 @@ SparseMatrix SparseMatrix_multiply3(SparseMatrix A, SparseMatrix B, SparseMatrix
 enum {SUM_REPEATED_NONE = 0, SUM_REPEATED_ALL, };
 SparseMatrix SparseMatrix_sum_repeat_entries(SparseMatrix A, int what_to_sum);
 SparseMatrix SparseMatrix_coordinate_form_add_entry(SparseMatrix A, int irn,
-                                                    int *jcn, void *val);
+                                                    int jcn, void *val);
 int SparseMatrix_is_symmetric(SparseMatrix A, bool test_pattern_symmetry_only);
 SparseMatrix SparseMatrix_transpose(SparseMatrix A);
 SparseMatrix SparseMatrix_symmetrize(SparseMatrix A,
index 7e41b39e13a882cb0b85a537a9a2a0b58b8a4861..3aa64e41c2a30fe16fc293e790b07a3751389a4c 100644 (file)
@@ -214,7 +214,7 @@ static Multilevel_Modularity_Clustering Multilevel_Modularity_Clustering_establi
     R0 = SparseMatrix_new(nc, n, 1, MATRIX_TYPE_REAL, FORMAT_COORD);
     for (i = 0; i < n; i++){
       jj = matching[i];
-      SparseMatrix_coordinate_form_add_entry(R0, jj, &i, &one);
+      SparseMatrix_coordinate_form_add_entry(R0, jj, i, &one);
     }
     R = SparseMatrix_from_coordinate_format(R0);
     SparseMatrix_delete(R0);
index 9e3ee3201f887b45d808d223f778775e8f8ea332..4f611f9fceffd371f8c8ba9ff11c275c0725f8aa 100644 (file)
@@ -461,7 +461,7 @@ static Multilevel_MQ_Clustering Multilevel_MQ_Clustering_establish(Multilevel_MQ
     R0 = SparseMatrix_new(nc, n, 1, MATRIX_TYPE_REAL, FORMAT_COORD);
     for (i = 0; i < n; i++){
       jj = matching[i];
-      SparseMatrix_coordinate_form_add_entry(R0, jj, &i, &one);
+      SparseMatrix_coordinate_form_add_entry(R0, jj, i, &one);
     }
     R = SparseMatrix_from_coordinate_format(R0);
     SparseMatrix_delete(R0);