From: Matthew Fernandez Date: Tue, 24 May 2022 02:53:01 +0000 (-0700) Subject: sfdpgen: remove 'node_weights' from 'spring_electrical_spring_embedding' X-Git-Tag: 4.0.0~1^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fecff95f07dc7795c3b2430a9ffd1ccbdb446e28;p=graphviz sfdpgen: remove 'node_weights' from 'spring_electrical_spring_embedding' This parameter is always passed as `NULL`. --- diff --git a/lib/sfdpgen/post_process.c b/lib/sfdpgen/post_process.c index bd6a59bb4..bba858e3a 100644 --- a/lib/sfdpgen/post_process.c +++ b/lib/sfdpgen/post_process.c @@ -992,7 +992,7 @@ void SpringSmoother_delete(SpringSmoother sm){ void SpringSmoother_smooth(SpringSmoother sm, SparseMatrix A, int dim, double *x){ int flag = 0; - spring_electrical_spring_embedding(dim, A, sm->D, sm->ctrl, NULL, x, &flag); + spring_electrical_spring_embedding(dim, A, sm->D, sm->ctrl, x, &flag); assert(!flag); } diff --git a/lib/sfdpgen/spring_electrical.c b/lib/sfdpgen/spring_electrical.c index 5712a346f..11e93e5b3 100644 --- a/lib/sfdpgen/spring_electrical.c +++ b/lib/sfdpgen/spring_electrical.c @@ -1443,7 +1443,7 @@ static void spring_maxent_embedding(int dim, SparseMatrix A0, SparseMatrix D, sp -void spring_electrical_spring_embedding(int dim, SparseMatrix A0, SparseMatrix D, spring_electrical_control ctrl, double *node_weights, double *x, int *flag){ +void spring_electrical_spring_embedding(int dim, SparseMatrix A0, SparseMatrix D, spring_electrical_control ctrl, double *x, int *flag){ /* x is a point to a 1D array, x[i*dim+j] gives the coordinate of the i-th node at dimension j. Same as the spring-electrical except we also introduce force due to spring length */ @@ -1521,11 +1521,7 @@ void spring_electrical_spring_embedding(int dim, SparseMatrix A0, SparseMatrix D nsuper_avg = 0; if (USE_QT) { - if (ctrl->use_node_weights){ - qt = QuadTree_new_from_point_list(dim, n, max_qtree_level, x, node_weights); - } else { - qt = QuadTree_new_from_point_list(dim, n, max_qtree_level, x, NULL); - } + qt = QuadTree_new_from_point_list(dim, n, max_qtree_level, x, NULL); } for (i = 0; i < n; i++){ @@ -1566,21 +1562,11 @@ void spring_electrical_spring_embedding(int dim, SparseMatrix A0, SparseMatrix D } } } else { - if (ctrl->use_node_weights && node_weights){ - for (j = 0; j < n; j++){ - if (j == i) continue; - dist = distance_cropped(x, dim, i, j); - for (k = 0; k < dim; k++){ - f[k] += node_weights[j]*KP*(x[i*dim+k] - x[j*dim+k])/pow(dist, 1.- p); - } - } - } else { - for (j = 0; j < n; j++){ - if (j == i) continue; - dist = distance_cropped(x, dim, i, j); - for (k = 0; k < dim; k++){ - f[k] += KP*(x[i*dim+k] - x[j*dim+k])/pow(dist, 1.- p); - } + for (j = 0; j < n; j++){ + if (j == i) continue; + dist = distance_cropped(x, dim, i, j); + for (k = 0; k < dim; k++){ + f[k] += KP*(x[i*dim+k] - x[j*dim+k])/pow(dist, 1.- p); } } } diff --git a/lib/sfdpgen/spring_electrical.h b/lib/sfdpgen/spring_electrical.h index abc7b3092..b790e3fe1 100644 --- a/lib/sfdpgen/spring_electrical.h +++ b/lib/sfdpgen/spring_electrical.h @@ -78,7 +78,7 @@ void print_matrix(double *x, int n, int dim); double average_edge_length(SparseMatrix A, int dim, double *coord); -void spring_electrical_spring_embedding(int dim, SparseMatrix A, SparseMatrix D, spring_electrical_control ctrl, double *node_weights, double *x, int *flag); +void spring_electrical_spring_embedding(int dim, SparseMatrix A, SparseMatrix D, spring_electrical_control ctrl, double *x, int *flag); void force_print(FILE *fp, int n, int dim, double *x, double *force); enum {MAX_I = 20, OPT_UP = 1, OPT_DOWN = -1, OPT_INIT = 0};