@@ -265,7 +265,6 @@ GrB_Info analyze_graph(GrB_Matrix tx_edge_mat, GrB_Matrix owns_edge_mat, GrB_Vec
265265 // ------------------------------------------------------------------------
266266
267267 // vertex filter: we will take only prersons over 30
268- GrB_Matrix ID ;
269268 GrB_IndexUnaryOp user_age ;
270269 TRY (GrB_IndexUnaryOp_new (& user_age , (GxB_index_unary_function )& check_user_age , GrB_BOOL , user , GrB_UINT8 ));
271270
@@ -276,7 +275,6 @@ GrB_Info analyze_graph(GrB_Matrix tx_edge_mat, GrB_Matrix owns_edge_mat, GrB_Vec
276275 TRY (GrB_Vector_select_UDT (v , NULL , NULL , user_age , users , & age , NULL ));
277276
278277 GxB_print (v , GxB_COMPLETE );
279- TRY (GrB_Matrix_diag (& ID , v , 0 ));
280278
281279 // ------------------------------------------------------------------------
282280 // apply user filters
@@ -288,26 +286,18 @@ GrB_Info analyze_graph(GrB_Matrix tx_edge_mat, GrB_Matrix owns_edge_mat, GrB_Vec
288286
289287 GrB_Semiring user_filter_semiring ;
290288 TRY (GrB_Semiring_new (& user_filter_semiring , GrB_LOR_MONOID_BOOL , user_filter_mul_op ));
291- GrB_Matrix owns_mat_filtered ;
292- TRY (GrB_Matrix_new (& owns_mat_filtered , GrB_BOOL , VERTICES_NUMBER , VERTICES_NUMBER ));
293- // apply filter
294- TRY (GrB_mxm (owns_mat_filtered , NULL , NULL , user_filter_semiring , ID , owns_edge_mat , NULL ));
295-
296- // ------------------------------------------------------------------------
297- // get cards of filtered users
298- // ------------------------------------------------------------------------
299-
300289 GrB_Vector filtered_cards ;
301290 TRY (GrB_Vector_new (& filtered_cards , GrB_BOOL , VERTICES_NUMBER ));
302- GxB_print (owns_mat_filtered , GxB_COMPLETE );
303- TRY (GrB_Matrix_reduce_Monoid (filtered_cards , NULL , NULL , GrB_LOR_MONOID_BOOL , owns_mat_filtered , GrB_DESC_T0 ));
291+ // apply filter
292+ TRY (GrB_vxm (filtered_cards , NULL , NULL , user_filter_semiring , v , owns_edge_mat , NULL ));
293+ GxB_print (filtered_cards , GxB_COMPLETE );
304294
305295 // ------------------------------------------------------------------------
306296 // build filter for tx matrix
307297 // ------------------------------------------------------------------------
308298
309299 // get cards with MIR payment system only
310- TRY ( GrB_Matrix_free ( & ID )) ;
300+ GrB_Matrix ID ;
311301 TRY (GrB_Vector_free (& v ));
312302 TRY (GrB_Vector_new (& v , card , VERTICES_NUMBER ));
313303 GrB_IndexUnaryOp payment_system ;
@@ -356,20 +346,6 @@ GrB_Info analyze_graph(GrB_Matrix tx_edge_mat, GrB_Matrix owns_edge_mat, GrB_Vec
356346
357347 GxB_print (tx_mat_filtered2 , GxB_COMPLETE );
358348
359- GrB_UnaryOp tx_is_nonempty_op ;
360- TRY (GxB_UnaryOp_new (& tx_is_nonempty_op , (GxB_unary_function )& tx_is_nonempty , GrB_BOOL , tx_edge , NULL , NULL ));
361-
362- GrB_Matrix keep ;
363- TRY (GrB_Matrix_new (& keep , GrB_BOOL , VERTICES_NUMBER , VERTICES_NUMBER ));
364- TRY (GrB_apply (keep , NULL , NULL , tx_is_nonempty_op , tx_mat_filtered2 , NULL ));
365- GxB_print (keep , GxB_COMPLETE );
366- GrB_Matrix tx_clean ;
367- TRY (GrB_Matrix_new (& tx_clean , tx_edge , VERTICES_NUMBER , VERTICES_NUMBER ));
368-
369- TRY (GrB_assign (tx_clean , keep , NULL , tx_mat_filtered2 , GrB_ALL , VERTICES_NUMBER , GrB_ALL , VERTICES_NUMBER , NULL ));
370-
371- GxB_print (tx_clean , GxB_COMPLETE );
372-
373349 // ------------------------------------------------------------------------
374350 // build matrix for pagerank
375351 // ------------------------------------------------------------------------
@@ -379,7 +355,7 @@ GrB_Info analyze_graph(GrB_Matrix tx_edge_mat, GrB_Matrix owns_edge_mat, GrB_Vec
379355 TRY (GrB_UnaryOp_new (& mean_op , (GxB_unary_function )& F_op , GrB_FP64 , tx_edge ));
380356 GrB_Matrix Fmat ;
381357 TRY (GrB_Matrix_new (& Fmat , GrB_FP64 , VERTICES_NUMBER , VERTICES_NUMBER ));
382- TRY (GrB_Matrix_apply (Fmat , NULL , NULL , mean_op , tx_clean , NULL ));
358+ TRY (GrB_Matrix_apply (Fmat , NULL , NULL , mean_op , tx_mat_filtered2 , NULL ));
383359 GxB_print (Fmat , GxB_COMPLETE );
384360
385361 // apply exp function to every element of every element of matrix (lEXPmat)
@@ -426,6 +402,7 @@ GrB_Info analyze_graph(GrB_Matrix tx_edge_mat, GrB_Matrix owns_edge_mat, GrB_Vec
426402 // ------------------------------------------------------------------------
427403 // run pagerank
428404 // ------------------------------------------------------------------------
405+
429406 int iteraions = 0 ;
430407 GrB_Vector pagerank_ans ;
431408 TRY (GrB_Vector_new (& pagerank_ans , GrB_FP64 , VERTICES_NUMBER ));
@@ -439,9 +416,13 @@ GrB_Info analyze_graph(GrB_Matrix tx_edge_mat, GrB_Matrix owns_edge_mat, GrB_Vec
439416
440417 TRY (banking_pagerank (& pagerank_ans , & iteraions , EXPSUMvec , G , 1e-4 , 100 ));
441418 GxB_print (pagerank_ans , GxB_COMPLETE );
419+
420+ // ------------------------------------------------------------------------
421+ // clean up
422+ // ------------------------------------------------------------------------
423+
442424 GrB_free (& ID );
443425 GrB_free (& v );
444- GrB_free (& owns_mat_filtered );
445426 GrB_free (& filtered_cards );
446427 GrB_free (& tx_bool_add_op );
447428 GrB_free (& tx_bool_mul_op );
@@ -451,9 +432,6 @@ GrB_Info analyze_graph(GrB_Matrix tx_edge_mat, GrB_Matrix owns_edge_mat, GrB_Vec
451432 GrB_free (& tx_bool_semiring_right );
452433 GrB_free (& tx_mat_filtered );
453434 GrB_free (& tx_mat_filtered2 );
454- GrB_free (& tx_is_nonempty_op );
455- GrB_free (& keep );
456- GrB_free (& tx_clean );
457435 GrB_free (& mean_op );
458436 GrB_free (& exp_op );
459437 GrB_free (& Fmat );
@@ -476,7 +454,6 @@ int main()
476454{
477455 LAGraph_Init (msg );
478456 printf ("LAGraph initialized.\n\n" );
479- // GxB_Global_Option_set(GxB_BURBLE);
480457
481458 // ------------------------------------------------------------------------
482459 // init edge matrices
@@ -512,6 +489,11 @@ int main()
512489 // ------------------------------------------------------------------------
513490
514491 TRY (analyze_graph (tx_edge_mat , owns_edge_mat , users , cards ));
492+
493+ // ------------------------------------------------------------------------
494+ // clean up
495+ // ------------------------------------------------------------------------
496+
515497 GrB_free (& tx_edge_mat );
516498 GrB_free (& owns_edge_mat );
517499 GrB_free (& users );
0 commit comments