@@ -118,6 +118,9 @@ void divide(double *z, const double *x, const double *y)
118118 * z = (* y != 0.0 ) ? (* x / * y ) : 0.0 ;
119119}
120120
121+ GrB_Type user , card ;
122+ GrB_Type tx_edge ;
123+
121124GrB_Info init_edges (GrB_Matrix * tx_mat , GrB_Matrix * owns_mat )
122125{
123126 GrB_Info info ;
@@ -167,7 +170,7 @@ GrB_Info init_edges(GrB_Matrix *tx_mat, GrB_Matrix *owns_mat)
167170 TRY (GrB_Matrix_setElement_BOOL (* owns_mat , & edge1011 , 9 , 10 ));
168171 TRY (GrB_Matrix_setElement_BOOL (* owns_mat , & edge1012 , 9 , 11 ));
169172
170- return info ;
173+ return GrB_SUCCESS ;
171174}
172175
173176GrB_Info init_vertices (GrB_Vector * users , GrB_Vector * cards )
@@ -201,53 +204,10 @@ GrB_Info init_vertices(GrB_Vector *users, GrB_Vector *cards)
201204 TRY (GrB_Vector_setElement_UDT (* cards , & card11 , 10 ));
202205 TRY (GrB_Vector_setElement_UDT (* cards , & card12 , 11 ));
203206
204- return info ;
207+ return GrB_SUCCESS ;
205208}
206209
207- int main ()
208- {
209- // init graphblas
210- GrB_Info info = GrB_init (GrB_NONBLOCKING );
211- if (info != GrB_SUCCESS )
212- {
213- fprintf (stderr , "GraphBLAS init failed\n" );
214- return 1 ;
215- }
216- printf ("GraphBLAS initialized.\n" );
217- LAGraph_Init (msg );
218- printf ("LAGraph initialized.\n\n" );
219-
220- // ------------------------------------------------------------------------
221- // init edge matrices
222- // ------------------------------------------------------------------------
223-
224- // custom type for transaction edges
225- GrB_Type tx_edge ;
226- TRY (GrB_Type_new (& tx_edge , sizeof (EdgeTX )));
227-
228- // edge decomposition
229-
230- GrB_Matrix tx_edge_mat , owns_edge_mat ;
231- TRY (GrB_Matrix_new (& tx_edge_mat , tx_edge , VERTICES_NUMBER , VERTICES_NUMBER ));
232- TRY (GrB_Matrix_new (& owns_edge_mat , GrB_BOOL , VERTICES_NUMBER , VERTICES_NUMBER ));
233- init_edges (& tx_edge_mat , & owns_edge_mat );
234-
235- // ------------------------------------------------------------------------
236- // init vertices vectors
237- // ------------------------------------------------------------------------
238-
239- GrB_Type user , card ;
240- TRY (GrB_Type_new (& user , sizeof (User )));
241-
242- TRY (GrB_Type_new (& card , sizeof (Card )));
243-
244- GrB_Vector users ;
245- TRY (GrB_Vector_new (& users , user , VERTICES_NUMBER ));
246-
247- GrB_Vector cards ;
248- TRY (GrB_Vector_new (& cards , card , VERTICES_NUMBER ));
249- TRY (init_vertices (& users , & cards ));
250-
210+ GrB_Info banking_page_rank (GrB_Matrix tx_edge_mat , GrB_Matrix owns_edge_mat , GrB_Vector users , GrB_Vector cards ){
251211 // ------------------------------------------------------------------------
252212 // build user filters
253213 // ------------------------------------------------------------------------
@@ -416,4 +376,46 @@ int main()
416376
417377 TRY (LAGr_PageRank (& pagerank_ans , & iteraions , G , 0.85 , 1e-4 , 100 , msg ));
418378 GxB_print (pagerank_ans , GxB_COMPLETE );
379+ }
380+
381+ int main ()
382+ {
383+ LAGraph_Init (msg );
384+ printf ("LAGraph initialized.\n\n" );
385+
386+ // ------------------------------------------------------------------------
387+ // init edge matrices
388+ // ------------------------------------------------------------------------
389+
390+ // custom type for transaction edges
391+ TRY (GrB_Type_new (& tx_edge , sizeof (EdgeTX )));
392+
393+ // edge decomposition
394+
395+ GrB_Matrix tx_edge_mat , owns_edge_mat ;
396+ TRY (GrB_Matrix_new (& tx_edge_mat , tx_edge , VERTICES_NUMBER , VERTICES_NUMBER ));
397+ TRY (GrB_Matrix_new (& owns_edge_mat , GrB_BOOL , VERTICES_NUMBER , VERTICES_NUMBER ));
398+ init_edges (& tx_edge_mat , & owns_edge_mat );
399+
400+ // ------------------------------------------------------------------------
401+ // init vertices vectors
402+ // ------------------------------------------------------------------------
403+
404+ TRY (GrB_Type_new (& user , sizeof (User )));
405+
406+ TRY (GrB_Type_new (& card , sizeof (Card )));
407+
408+ GrB_Vector users ;
409+ TRY (GrB_Vector_new (& users , user , VERTICES_NUMBER ));
410+
411+ GrB_Vector cards ;
412+ TRY (GrB_Vector_new (& cards , card , VERTICES_NUMBER ));
413+ TRY (init_vertices (& users , & cards ));
414+
415+ // ------------------------------------------------------------------------
416+ // run solver
417+ // ------------------------------------------------------------------------
418+
419+ TRY (banking_page_rank (tx_edge_mat ,owns_edge_mat ,users ,cards ));
420+
419421}
0 commit comments