Skip to content

Commit ae55be6

Browse files
modularity and markov clustering
1 parent 35c692d commit ae55be6

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

experimental/algorithm/LAGr_MarkovClustering.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ int LAGr_MarkovClustering(
141141
GRB_TRY(GrB_reduce(&mse, NULL, GrB_PLUS_MONOID_FP32, MSE, NULL));
142142
GRB_TRY(GrB_Matrix_nvals(&nvals, MSE));
143143
mse /= nvals;
144+
// FIXME: if iter > max_iter, return LAGRAPH_CONVERGENCE_FAILURE
144145
if (iter > max_iter || mse < convergence_threshold)
145146
break;
146147
}

experimental/algorithm/LAGr_Modularity.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,27 +155,34 @@ int LAGr_Modularity(
155155
GRB_TRY(GrB_reduce(vmask, NULL, NULL, GrB_LOR_MONOID_BOOL, C, NULL));
156156
GRB_TRY(GrB_apply(vmask, vmask, NULL, GrB_LNOT, vmask, NULL));
157157

158+
// FIXME:
159+
#if 1
160+
158161
// If any of the above vectors have fewer entries than nclusters, this means
159162
// that there are singleton clusters with one vertex/no out-degree/no
160163
// in-degree. So we need to add explicit zeros wherever values are missing
161164
// for further calculations.
162165
GrB_Index nclusters, nl, nk_out, nk_in;
163166
GRB_TRY(GrB_Vector_nvals(&nclusters, vmask));
167+
164168
GRB_TRY(GrB_Vector_nvals(&nl, l));
165-
GRB_TRY(GrB_Vector_nvals(&nk_out, l));
166-
GRB_TRY(GrB_Vector_nvals(&nk_in, l));
169+
GRB_TRY(GrB_Vector_nvals(&nk_out, k_out /* l */));
170+
GRB_TRY(GrB_Vector_nvals(&nk_in, k_in /* l */));
167171

168172
if (nclusters != nl)
169173
{
174+
// printf ("l needs padding (%ld, %ld)\n", nclusters, nl) ;
170175
GRB_TRY(GrB_assign(l, l, NULL, vmask, GrB_ALL, nclusters, GrB_DESC_SC));
171176
}
172177
if (nclusters != nk_out)
173178
{
179+
// printf ("k_out needs padding (%ld, %ld)\n", nclusters, nk_out) ;
174180
GRB_TRY(GrB_assign(k_out, k_out, NULL, vmask, GrB_ALL, nclusters,
175181
GrB_DESC_SC));
176182
}
177183
if (nclusters != nk_in)
178184
{
185+
// printf ("k_in needs padding (%ld, %ld)\n", nclusters, nk_in) ;
179186
GRB_TRY(GrB_assign(k_in, k_in, NULL, vmask, GrB_ALL, nclusters,
180187
GrB_DESC_SC));
181188
}
@@ -192,11 +199,11 @@ int LAGr_Modularity(
192199
GRB_TRY(GrB_Vector_extractTuples_INT64(NULL, (int64_t *) k_outX, &nclusters, k_out));
193200
GRB_TRY(GrB_Vector_extractTuples_INT64(NULL, (int64_t *) k_inX, &nclusters, k_in));
194201

195-
GrB_Index m, out_degree_sum, in_degree_sum, L_c;
202+
GrB_Index out_degree_sum ;
196203
GRB_TRY(GrB_reduce(&out_degree_sum, NULL, GrB_PLUS_MONOID_INT64, out_degree,
197204
NULL));
198205

199-
m = out_degree_sum;
206+
double m = out_degree_sum;
200207
double norm = 1.0 / (m * m);
201208

202209
// compute modularity
@@ -207,6 +214,7 @@ int LAGr_Modularity(
207214
mod += (1.0 * lX[c] / nedges) -
208215
(resolution * ((k_outX[c] * k_inX[c]) * norm));
209216
}
217+
#endif
210218

211219
// TODO: return a GrB_Scalar??
212220
(*mod_handle) = mod;

experimental/test/test_MaxFlow.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ test_info tests[] = {
6262
void test_MaxFlow(void) {
6363
#if LG_SUITESPARSE_GRAPHBLAS_V10
6464
LAGraph_Init(msg);
65-
OK(LG_SET_BURBLE(1)); // FIXME
66-
// OK(LG_SET_BURBLE(0));
65+
//OK(LG_SET_BURBLE(1));
66+
OK(LG_SET_BURBLE(0));
6767
for(uint8_t test = 0; test < NTESTS; test++){
6868
GrB_Matrix A=NULL;
6969
printf ("\nMatrix: %s\n", tests[test].filename);
@@ -123,8 +123,8 @@ void test_MaxFlow(void) {
123123
void test_MaxFlowMtx(void) {
124124
LAGraph_Init(msg);
125125
#if LG_SUITESPARSE_GRAPHBLAS_V10
126-
OK(LG_SET_BURBLE(1)); // FIXME
127-
// OK(LG_SET_BURBLE(0));
126+
//OK(LG_SET_BURBLE(1));
127+
OK(LG_SET_BURBLE(0));
128128
for(uint8_t test = 0; test < NTESTS; test++){
129129
GrB_Matrix A=NULL;
130130
printf ("\nMatrix: %s\n", tests[test].filename);

0 commit comments

Comments
 (0)