From: Matthew Fernandez Date: Sun, 22 May 2022 23:58:57 +0000 (-0700) Subject: sparse: remove 'nentries' from 'SparseMatrix_coordinate_form_add_entries' X-Git-Tag: 4.0.0~5^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2776ffa23133449106f623afbd15b7fbf5039303;p=graphviz sparse: remove 'nentries' from 'SparseMatrix_coordinate_form_add_entries' This parameter is always passed as 1. --- diff --git a/cmd/gvmap/country_graph_coloring.c b/cmd/gvmap/country_graph_coloring.c index 4af049b81..e03c5bbd2 100644 --- a/cmd/gvmap/country_graph_coloring.c +++ b/cmd/gvmap/country_graph_coloring.c @@ -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_entries(L, 1, &i, &jj, &a); + L = SparseMatrix_coordinate_form_add_entries(L, &i, &jj, &a); } } - L = SparseMatrix_coordinate_form_add_entries(L, 1, &i, &i, &nrow); + L = SparseMatrix_coordinate_form_add_entries(L, &i, &i, &nrow); } L = SparseMatrix_from_coordinate_format(L); diff --git a/cmd/gvmap/make_map.c b/cmd/gvmap/make_map.c index eef39e7f9..e73f570a8 100644 --- a/cmd/gvmap/make_map.c +++ b/cmd/gvmap/make_map.c @@ -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_entries(A, 1, &j1, &i1, &val); - return SparseMatrix_coordinate_form_add_entries(A, 1, &i1, &j1, &val); + A = SparseMatrix_coordinate_form_add_entries(A, &j1, &i1, &val); + return SparseMatrix_coordinate_form_add_entries(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_entries(B, 1, &ig1, &ig1, &one); + SparseMatrix_coordinate_form_add_entries(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_entries(B, 1, &ig1, &ig2, &one); + SparseMatrix_coordinate_form_add_entries(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_entries(B, 1, &i, &jj, &one); + SparseMatrix_coordinate_form_add_entries(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_entries(*poly_lines, 1, &i, &cur, &ipoly2); + SparseMatrix_coordinate_form_add_entries(*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_entries(*poly_lines, 1, &i, &next, &ipoly2); + SparseMatrix_coordinate_form_add_entries(*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_entries(*poly_lines, 1, &i, &sta, &ipoly2);/* complete a cycle by adding starting point */ + SparseMatrix_coordinate_form_add_entries(*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_entries(half_edges, 1, &i, &jj, &ne); - half_edges = SparseMatrix_coordinate_form_add_entries(half_edges, 1, &jj, &i, &ne); + half_edges = SparseMatrix_coordinate_form_add_entries(half_edges, &i, &jj, &ne); + half_edges = SparseMatrix_coordinate_form_add_entries(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_entries(half_edges, 1, &i, &jj, &ne); - half_edges = SparseMatrix_coordinate_form_add_entries(half_edges, 1, &jj, &i, &ne); + half_edges = SparseMatrix_coordinate_form_add_entries(half_edges, &i, &jj, &ne); + half_edges = SparseMatrix_coordinate_form_add_entries(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_entries(*polys, 1, &i, &head, &i); + SparseMatrix_coordinate_form_add_entries(*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_entries(*polys, 1, &i, &head, &i); - SparseMatrix_coordinate_form_add_entries(*polys, 1, &i, &tail, &i); + SparseMatrix_coordinate_form_add_entries(*polys, &i, &head, &i); + SparseMatrix_coordinate_form_add_entries(*polys, &i, &tail, &i); /* unset edge_map */ diff --git a/lib/edgepaint/edge_distinct_coloring.c b/lib/edgepaint/edge_distinct_coloring.c index 517ccdabf..00e28e122 100644 --- a/lib/edgepaint/edge_distinct_coloring.c +++ b/lib/edgepaint/edge_distinct_coloring.c @@ -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_entries(B, 1, &i, &j, &cos_a); + B = SparseMatrix_coordinate_form_add_entries(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_entries(B, 1, &i, &j, &cos_a); + B = SparseMatrix_coordinate_form_add_entries(B, &i, &j, &cos_a); } } } diff --git a/lib/mingle/agglomerative_bundling.cpp b/lib/mingle/agglomerative_bundling.cpp index 213bb118a..da99b3120 100644 --- a/lib/mingle/agglomerative_bundling.cpp +++ b/lib/mingle/agglomerative_bundling.cpp @@ -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_entries(R1, 1, &jj, &i, &one); + SparseMatrix_coordinate_form_add_entries(R1, &jj, &i, &one); } R = SparseMatrix_from_coordinate_format(R1); SparseMatrix_delete(R1); diff --git a/lib/mingle/edge_bundling.cpp b/lib/mingle/edge_bundling.cpp index afa2c64fa..02c839ebb 100644 --- a/lib/mingle/edge_bundling.cpp +++ b/lib/mingle/edge_bundling.cpp @@ -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_entries(C, 1, &jj, &i, NULL); + SparseMatrix_coordinate_form_add_entries(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_entries(B, 1, &i, &jj, &dist); - B = SparseMatrix_coordinate_form_add_entries(B, 1, &jj, &i, &dist); + B = SparseMatrix_coordinate_form_add_entries(B, &i, &jj, &dist); + B = SparseMatrix_coordinate_form_add_entries(B, &jj, &i, &dist); } } } diff --git a/lib/neatogen/call_tri.c b/lib/neatogen/call_tri.c index 2c97b361e..67076e3b7 100644 --- a/lib/neatogen/call_tri.c +++ b/lib/neatogen/call_tri.c @@ -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_entries(A, 1, &(ii), &(jj), &one); + SparseMatrix_coordinate_form_add_entries(A, &(ii), &(jj), &one); } if (n == 2) { /* if two points, add edge i->j */ ii = 0; jj = 1; - SparseMatrix_coordinate_form_add_entries(A, 1, &(ii), &(jj), &one); + SparseMatrix_coordinate_form_add_entries(A, &(ii), &(jj), &one); } for (i = 0; i < n; i++) { - SparseMatrix_coordinate_form_add_entries(A, 1, &i, &i, &one); + SparseMatrix_coordinate_form_add_entries(A, &i, &i, &one); } B = SparseMatrix_from_coordinate_format(A); SparseMatrix_delete(A); @@ -85,13 +85,13 @@ 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_entries(A, 1, &i, + SparseMatrix_coordinate_form_add_entries(A, &i, &(delaunay[i]. edges[j]), &one); } } for (i = 0; i < n; i++) { - SparseMatrix_coordinate_form_add_entries(A, 1, &i, &i, &one); + SparseMatrix_coordinate_form_add_entries(A, &i, &i, &one); } B = SparseMatrix_from_coordinate_format(A); B = SparseMatrix_symmetrize(B, false); diff --git a/lib/neatogen/overlap.c b/lib/neatogen/overlap.c index 1522aa1b2..3c03b2fb6 100644 --- a/lib/neatogen/overlap.c +++ b/lib/neatogen/overlap.c @@ -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_entries(A, 1, &neighbor, &k, &one); + A = SparseMatrix_coordinate_form_add_entries(A, &neighbor, &k, &one); #ifdef DEBUG_RBTREE fprintf(stderr,"====================================== %d %d\n",k,neighbor); #endif diff --git a/lib/sparse/SparseMatrix.c b/lib/sparse/SparseMatrix.c index a76fbb617..985c6253a 100644 --- a/lib/sparse/SparseMatrix.c +++ b/lib/sparse/SparseMatrix.c @@ -1595,11 +1595,13 @@ SparseMatrix SparseMatrix_sum_repeat_entries(SparseMatrix A, int what_to_sum){ return A; } -SparseMatrix SparseMatrix_coordinate_form_add_entries(SparseMatrix A, int nentries, int *irn, int *jcn, void *val){ - int nz, nzmax, i; +SparseMatrix SparseMatrix_coordinate_form_add_entries(SparseMatrix A, int *irn, + int *jcn, void *val) { + int nz, nzmax; + + static const int nentries = 1; assert(A->format == FORMAT_COORD); - if (nentries <= 0) return A; nz = A->nz; if (nz + nentries >= A->nzmax){ @@ -1610,10 +1612,8 @@ SparseMatrix SparseMatrix_coordinate_form_add_entries(SparseMatrix A, int nentri memcpy((char*) A->ia + ((size_t)nz)*sizeof(int)/sizeof(char), irn, sizeof(int)*((size_t)nentries)); memcpy((char*) A->ja + ((size_t)nz)*sizeof(int)/sizeof(char), jcn, sizeof(int)*((size_t)nentries)); if (A->size) memcpy((char*) A->a + ((size_t)nz)*A->size/sizeof(char), val, A->size*((size_t)nentries)); - for (i = 0; i < nentries; i++) { - if (irn[i] >= A->m) A->m = irn[i]+1; - if (jcn[i] >= A->n) A->n = jcn[i]+1; - } + if (irn[0] >= A->m) A->m = irn[0] + 1; + if (jcn[0] >= A->n) A->n = jcn[0] + 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_entries(B, 1, &k, &itmp, &dtmp); + if (k != itmp) B = SparseMatrix_coordinate_form_add_entries(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_entries(B, 1, &k, &itmp, &dtmp); + if (k != itmp) B = SparseMatrix_coordinate_form_add_entries(B, &k, &itmp, &dtmp); } } } diff --git a/lib/sparse/SparseMatrix.h b/lib/sparse/SparseMatrix.h index e84628a12..4055632a9 100644 --- a/lib/sparse/SparseMatrix.h +++ b/lib/sparse/SparseMatrix.h @@ -68,7 +68,8 @@ 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_entries(SparseMatrix A, int nentries, int *irn, int *jcn, void *val); +SparseMatrix SparseMatrix_coordinate_form_add_entries(SparseMatrix A, int *irn, + 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, diff --git a/lib/sparse/clustering.c b/lib/sparse/clustering.c index 26501b8b9..503586d3c 100644 --- a/lib/sparse/clustering.c +++ b/lib/sparse/clustering.c @@ -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_entries(R0, 1, &jj, &i, &one); + SparseMatrix_coordinate_form_add_entries(R0, &jj, &i, &one); } R = SparseMatrix_from_coordinate_format(R0); SparseMatrix_delete(R0); diff --git a/lib/sparse/mq.c b/lib/sparse/mq.c index 3e6d7235c..734e45891 100644 --- a/lib/sparse/mq.c +++ b/lib/sparse/mq.c @@ -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_entries(R0, 1, &jj, &i, &one); + SparseMatrix_coordinate_form_add_entries(R0, &jj, &i, &one); } R = SparseMatrix_from_coordinate_format(R0); SparseMatrix_delete(R0);