(*nzc) += *nvset;
}
-static void maximal_independent_vertex_set_RS(SparseMatrix A, int **vset, int *nvset, int *nzc){
- /* The Ruge-Stuben coarsening scheme. Initially all vertices are in the U set (with marker MAX_IND_VTX_SET_U),
- with gain equal to their degree. Select vertex with highest gain into a C set (with
- marker >= MAX_IND_VTX_SET_C), and their neighbors j in F set (with marker MAX_IND_VTX_SET_F). The neighbors of
- j that are in the U set get their gains incremented by 1. So overall
- gain[k] = |{neighbor of k in U set}|+2*|{neighbors of k in F set}|.
- nzc is the number of entries in the restriction matrix
- */
- int i, jj, ii, *p = NULL, j, k, *ia, *ja, m, n, gain, removed, nf = 0;
- PriorityQueue q;
- (void)removed;
- (void)n;
- assert(A);
- assert(SparseMatrix_known_strucural_symmetric(A));
-
- ia = A->ia;
- ja = A->ja;
- m = A->m;
- n = A->n;
- assert(n == m);
- *vset = gv_calloc(m, sizeof(int));
- for (i = 0; i < m; i++) {
- (*vset)[i] = MAX_IND_VTX_SET_U;
- }
- *nvset = 0;
- *nzc = 0;
-
- q = PriorityQueue_new(m, 2*(m-1));
-
- p = random_permutation(m);
- for (ii = 0; ii < m; ii++){
- i = p[ii];
- PriorityQueue_push(q, i, ia[i+1] - ia[i]);
- }
- free(p);
-
- while (PriorityQueue_pop(q, &i, &gain)){
- assert((*vset)[i] == MAX_IND_VTX_SET_U);
- (*vset)[i] = (*nvset)++;
- for (j = ia[i]; j < ia[i+1]; j++){
- jj = ja[j];
- assert((*vset)[jj] == MAX_IND_VTX_SET_U || (*vset)[jj] == MAX_IND_VTX_SET_F);
- if (i == jj) continue;
-
- if ((*vset)[jj] == MAX_IND_VTX_SET_U){
- removed = PriorityQueue_remove(q, jj);
- assert(removed);
- (*vset)[jj] = MAX_IND_VTX_SET_F;
- nf++;
-
- for (k = ia[jj]; k < ia[jj+1]; k++){
- if (jj == ja[k]) continue;
- if ((*vset)[ja[k]] == MAX_IND_VTX_SET_U){
- gain = PriorityQueue_get_gain(q, ja[k]);
- assert(gain >= 0);
- PriorityQueue_push(q, ja[k], gain + 1);
- }
- }
- }
- (*nzc)++;
- }
- }
- (*nzc) += *nvset;
- PriorityQueue_delete(q);
-
-}
-
static void maximal_independent_edge_set_heavest_edge_pernode_supernodes_first(SparseMatrix A, int **cluster, int **clusterp, int *ncluster){
int i, ii, j, *ia, *ja, m, n, *p = NULL;
(void)n;