From 226546b4cb777bc358a915cadeb1be072910adad Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 1 Jan 2023 16:36:45 -0800 Subject: [PATCH] sparse modularity_clustering: remove 'use_value' parameter This is always set to true. --- lib/mingle/edge_bundling.cpp | 3 +-- lib/sparse/DotIO.c | 6 ++---- lib/sparse/clustering.c | 4 ++-- lib/sparse/clustering.h | 3 +-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/mingle/edge_bundling.cpp b/lib/mingle/edge_bundling.cpp index 1003d1105..9d11096c4 100644 --- a/lib/mingle/edge_bundling.cpp +++ b/lib/mingle/edge_bundling.cpp @@ -498,14 +498,13 @@ static pedge* modularity_ink_bundling(int dim, int ne, SparseMatrix B, pedge* ed double ink0, ink1; pedge e; int i, j, jj; - int use_value_for_clustering = TRUE; SparseMatrix BB; /* B may contain negative entries */ BB = SparseMatrix_copy(B); BB = SparseMatrix_apply_fun(BB, fabs); - modularity_clustering(BB, TRUE, 0, use_value_for_clustering, &nclusters, &assignment, &modularity); + modularity_clustering(BB, TRUE, 0, &nclusters, &assignment, &modularity); SparseMatrix_delete(BB); if (Verbose > 1) fprintf(stderr, "there are %d clusters, modularity = %f\n",nclusters, modularity); diff --git a/lib/sparse/DotIO.c b/lib/sparse/DotIO.c index b1fb3f81c..c00ef07e7 100644 --- a/lib/sparse/DotIO.c +++ b/lib/sparse/DotIO.c @@ -473,7 +473,6 @@ SparseMatrix Import_coord_clusters_from_dot(Agraph_t* g, int maxcluster, int dim MAX_GRPS = nc; if (noclusterinfo) { - int use_value = TRUE; double modularity; if (!clust_sym) clust_sym = agattr(g,AGNODE,"cluster","-1"); @@ -481,7 +480,7 @@ SparseMatrix Import_coord_clusters_from_dot(Agraph_t* g, int maxcluster, int dim mq_clustering(A, maxcluster, &nc, clusters, &modularity); } else if (clustering_scheme == CLUSTERING_MODULARITY){ - modularity_clustering(A, FALSE, maxcluster, use_value, + modularity_clustering(A, FALSE, maxcluster, &nc, clusters, &modularity); } else { assert(0); @@ -660,7 +659,6 @@ void attached_clustering(Agraph_t* g, int maxcluster, int clustering_scheme){ clusters = MALLOC(sizeof(int)*nnodes); { - int use_value = TRUE; double modularity; if (!clust_sym) clust_sym = agattr(g,AGNODE,"cluster","-1"); @@ -668,7 +666,7 @@ void attached_clustering(Agraph_t* g, int maxcluster, int clustering_scheme){ mq_clustering(A, maxcluster, &nc, &clusters, &modularity); } else if (clustering_scheme == CLUSTERING_MODULARITY){ - modularity_clustering(A, FALSE, maxcluster, use_value, + modularity_clustering(A, FALSE, maxcluster, &nc, &clusters, &modularity); } else { assert(0); diff --git a/lib/sparse/clustering.c b/lib/sparse/clustering.c index ab9b2472f..fd43ac0de 100644 --- a/lib/sparse/clustering.c +++ b/lib/sparse/clustering.c @@ -346,7 +346,7 @@ static void hierachical_modularity_clustering(SparseMatrix A, int ncluster_targe -void modularity_clustering(SparseMatrix A, int inplace, int ncluster_target, int use_value, +void modularity_clustering(SparseMatrix A, int inplace, int ncluster_target, int *nclusters, int **assignment, double *modularity){ /* find a clustering of vertices by maximize modularity A: symmetric square matrix n x n. If real value, value will be used as edges weights, otherwise edge weights are considered as 1. @@ -373,7 +373,7 @@ void modularity_clustering(SparseMatrix A, int inplace, int ncluster_target, int B = SparseMatrix_remove_diagonal(B); - if (B->type != MATRIX_TYPE_REAL || !use_value) B = SparseMatrix_set_entries_to_real_one(B); + if (B->type != MATRIX_TYPE_REAL) B = SparseMatrix_set_entries_to_real_one(B); hierachical_modularity_clustering(B, ncluster_target, nclusters, assignment, modularity); diff --git a/lib/sparse/clustering.h b/lib/sparse/clustering.h index 13e6b28e7..118d26d3d 100644 --- a/lib/sparse/clustering.h +++ b/lib/sparse/clustering.h @@ -45,13 +45,12 @@ enum {CLUSTERING_MODULARITY = 0, CLUSTERING_MQ}; maxcluster: used to specify the maximum number of cluster desired, e.g., maxcluster=10 means that a maximum of 10 clusters . is desired. this may not always be realized, and modularity may be low when this is specified. Default: maxcluster = 0 (no limit) - use_value: whether to use the entry value, or treat edge weights as 1. nclusters: on output the number of clusters assignment: dimension n. Node i is assigned to cluster "assignment[i]". 0 <= assignment < nclusters. . If *assignment = NULL on entry, it will be allocated. Otherwise used. modularity: achieve modularity */ -void modularity_clustering(SparseMatrix A, int inplace, int maxcluster, int use_value, +void modularity_clustering(SparseMatrix A, int inplace, int maxcluster, int *nclusters, int **assignment, double *modularity); #ifdef __cplusplus -- 2.40.0