From 253ad54c7bea75652a5fb693aad83e576318620e Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 25 Jun 2021 21:48:29 -0700 Subject: [PATCH] remove unused SparseMatrix_pseudo_diameter_weighted --- lib/sparse/SparseMatrix.c | 64 --------------------------------------- lib/sparse/SparseMatrix.h | 1 - 2 files changed, 65 deletions(-) diff --git a/lib/sparse/SparseMatrix.c b/lib/sparse/SparseMatrix.c index de44d9a39..e4eba916b 100644 --- a/lib/sparse/SparseMatrix.c +++ b/lib/sparse/SparseMatrix.c @@ -2347,70 +2347,6 @@ static int Dijkstra_masked(SparseMatrix A, int root, real *dist, int *nlist, int return Dijkstra_internal(A, root, dist, nlist, list, dist_max, mask); } -real SparseMatrix_pseudo_diameter_weighted(SparseMatrix A0, int root, int aggressive, int *end1, int *end2, int *connectedQ){ - /* weighted graph. But still assume to be undirected. unsymmetric matrix ill be symmetrized */ - SparseMatrix A = A0; - int m = A->m, i, *list = NULL, nlist; - int flag; - real *dist = NULL, dist_max = -1, dist0 = -1; - int roots[5], iroots, end11, end22; - - if (!SparseMatrix_is_symmetric(A, TRUE)){ - A = SparseMatrix_symmetrize(A, TRUE); - } - assert(m == A->n); - - dist = MALLOC(sizeof(real)*((size_t)m)); - list = MALLOC(sizeof(int)*((size_t)m)); - nlist = 1; - list[nlist-1] = root; - - assert(SparseMatrix_is_symmetric(A, TRUE)); - - do { - dist0 = dist_max; - root = list[nlist - 1]; - flag = Dijkstra(A, root, dist, &nlist, list, &dist_max); - //fprintf(stderr,"after Dijkstra, {%d,%d}-%f\n",root, list[nlist-1], dist_max); - assert(dist[list[nlist-1]] == dist_max); - assert(root == list[0]); - assert(nlist > 0); - } while (dist_max > dist0); - - *connectedQ = (!flag); - assert((dist_max - dist0)/MAX(1, MAX(fabs(dist0), fabs(dist_max))) < 1.e-10); - - *end1 = root; - *end2 = list[nlist-1]; - //fprintf(stderr,"after search for diameter, diam = %f, ends = {%d,%d}\n", dist_max, *end1, *end2); - - if (aggressive){ - iroots = 0; - for (i = MAX(0, nlist - 6); i < nlist - 1; i++){ - roots[iroots++] = list[i]; - } - for (i = 0; i < iroots; i++){ - root = roots[i]; - dist0 = dist_max; - fprintf(stderr,"search for diameter again from root=%d\n", root); - dist_max = SparseMatrix_pseudo_diameter_weighted(A, root, FALSE, &end11, &end22, connectedQ); - if (dist_max > dist0){ - *end1 = end11; *end2 = end22; - } else { - dist_max = dist0; - } - } - fprintf(stderr,"after aggressive search for diameter, diam = %f, ends = {%d,%d}\n", dist_max, *end1, *end2); - } - - FREE(dist); - FREE(list); - - if (A != A0) SparseMatrix_delete(A); - return dist_max; - -} - void SparseMatrix_decompose_to_supervariables(SparseMatrix A, int *ncluster, int **cluster, int **clusterp){ /* nodes for a super variable if they share exactly the same neighbors. This is know as modules in graph theory. We work on columns only and columns with the same pattern are grouped as a super variable diff --git a/lib/sparse/SparseMatrix.h b/lib/sparse/SparseMatrix.h index b82772772..847229614 100644 --- a/lib/sparse/SparseMatrix.h +++ b/lib/sparse/SparseMatrix.h @@ -87,7 +87,6 @@ SparseMatrix SparseMatrix_apply_fun(SparseMatrix A, double (*fun)(double x));/* SparseMatrix SparseMatrix_copy(SparseMatrix A); int SparseMatrix_has_diagonal(SparseMatrix A); SparseMatrix SparseMatrix_make_undirected(SparseMatrix A);/* make it strictly low diag only, and set flag to undirected */ -real SparseMatrix_pseudo_diameter_weighted(SparseMatrix A0, int root, int aggressive, int *end1, int *end2, int *connectedQ); /* assume real distances, unsymmetric matrix ill be symmetrized */ void SparseMatrix_level_sets(SparseMatrix A, int root, int *nlevel, int **levelset_ptr, int **levelset, int **mask, int reintialize_mask); void SparseMatrix_level_sets_khops(int khops, SparseMatrix A, int root, int *nlevel, int **levelset_ptr, int **levelset, int **mask, int reintialize_mask); void SparseMatrix_weakly_connected_components(SparseMatrix A0, int *ncomp, int **comps, int **comps_ptr); -- 2.40.0