@@ -41,6 +41,7 @@ typedef struct
4141 uint64_t ans_n ;
4242 const uint64_t * ans_i ;
4343 const uint64_t * ans_j ;
44+ double ans_w ;
4445}
4546matrix_info ;
4647const uint64_t A_mtx_i [] = {1 , 2 , 3 , 4 , 5 , 6 };
@@ -51,27 +52,24 @@ const uint64_t mtx8_i [] = {1, 2, 3, 4, 5, 6};
5152const uint64_t mtx8_j [] = {4 , 3 , 0 , 6 , 2 , 3 };
5253const matrix_info files [ ] =
5354{
54- #if LG_SUITESPARSE_GRAPHBLAS_V10
55- { 1 , "A.mtx" , 6 , A_mtx_i , A_mtx_j },
56- { 1 , "jagmesh7.mtx" , 1137 , NULL , NULL },
57- { 0 , "west0067.mtx" , 66 , NULL , NULL }, // unsymmetric
58- { 1 , "bcsstk13.mtx" , 2002 , NULL , NULL }, // overflows an INT32
59- { 0 , "matrix_int8.mtx" , 6 , mtx8_i , mtx8_j },
60- { 0 , "matrix_uint8.mtx" , 6 , mtx8u_i , mtx8u_j },
61- { 1 , "karate.mtx" , 33 , NULL , NULL },
62- { 1 , "ldbc-cdlp-undirected-example.mtx" , 7 , NULL , NULL },
63- { 1 , "ldbc-undirected-example-bool.mtx" , 8 , NULL , NULL },
64- { 1 , "ldbc-undirected-example-unweighted.mtx" , 8 , NULL , NULL },
65- { 1 , "ldbc-undirected-example.mtx" , 8 , NULL , NULL },
66- { 1 , "ldbc-wcc-example.mtx" , 9 , NULL , NULL },
67- #endif
55+ { 1 , "A.mtx" , 6 , A_mtx_i , A_mtx_j , NAN },
56+ { 1 , "jagmesh7.mtx" , 1137 , NULL , NULL , NAN },
57+ { 0 , "west0067.mtx" , 66 , NULL , NULL , -63.9103636 }, // unsymmetric
58+ { 1 , "bcsstk13.mtx" , 2002 , NULL , NULL , -27812381075940.4 },
59+ { 0 , "matrix_int8.mtx" , 6 , mtx8_i , mtx8_j , -120.0 },
60+ { 0 , "matrix_uint8.mtx" , 6 , mtx8u_i , mtx8u_j , 8.0 },
61+ { 1 , "karate.mtx" , 33 , NULL , NULL , NAN },
62+ { 1 , "ldbc-cdlp-undirected-example.mtx" , 7 , NULL , NULL , NAN },
63+ { 1 , "ldbc-undirected-example-bool.mtx" , 8 , NULL , NULL , NAN },
64+ { 1 , "ldbc-undirected-example-unweighted.mtx" , 8 , NULL , NULL , NAN },
65+ { 1 , "ldbc-undirected-example.mtx" , 8 , NULL , NULL , NAN },
66+ { 1 , "ldbc-wcc-example.mtx" , 9 , NULL , NULL , NAN },
6867 { 0 , "" },
6968} ;
7069
7170//****************************************************************************
7271void test_msf (void )
7372{
74- #if LAGRAPH_SUITESPARSE
7573 LAGraph_Init (msg ) ;
7674 GrB_Scalar zeroB = NULL ;
7775 GrB_Scalar_new (& zeroB , GrB_BOOL );
@@ -163,6 +161,10 @@ void test_msf (void)
163161 }
164162
165163 printf ("\nmsf:\n" ) ;
164+ double tot_weight , ans_w = files [k ].ans_w ;
165+ OK (GrB_Matrix_reduce_FP64 (& tot_weight , NULL , GrB_PLUS_MONOID_FP64 , C , NULL )) ;
166+ TEST_CHECK (isnan (files [k ].ans_w ) ||
167+ fabs (tot_weight - ans_w ) <= 1E-10 * fabs (ans_w )) ;
166168 OK (LAGraph_Matrix_Print (C , pr , stdout , msg )) ;
167169 OK (LAGraph_Delete (& G , msg )) ;
168170 OK (LAGraph_Delete (& G_C , msg )) ;
@@ -175,7 +177,64 @@ void test_msf (void)
175177 }
176178 GrB_free (& zeroB );
177179 LAGraph_Finalize (msg ) ;
178- #endif
180+ }
181+
182+ //------------------------------------------------------------------------------
183+ // infinity test
184+ //------------------------------------------------------------------------------
185+
186+ void test_inf_msf (void )
187+ {
188+ LAGraph_Init (msg ) ;
189+ GrB_Scalar zeroB = NULL ;
190+ GrB_Scalar_new (& zeroB , GrB_BOOL );
191+ GrB_Scalar_setElement_BOOL (zeroB , false);
192+
193+ // load the matrix as A
194+ const char * aname = "bcsstk13.mtx" ;
195+ bool symmetric = 1 ;
196+ printf ("\n================================== %s:\n" , aname ) ;
197+ TEST_CASE (aname ) ;
198+ snprintf (filename , LEN , LG_DATA_DIR "%s" , aname ) ;
199+ FILE * f = fopen (filename , "r" ) ;
200+ TEST_CHECK (f != NULL ) ;
201+ OK (LAGraph_MMRead (& A , f , msg )) ;
202+ fclose (f ) ;
203+
204+ GrB_Index n = 0 ;
205+ OK (GrB_Matrix_nrows (& n , A )) ;
206+ OK (GrB_Matrix_new (& S , GrB_BOOL , n , n )) ;
207+
208+ // Make A be iso infinity and S iso true.
209+ OK (GrB_Matrix_assign_FP64 (
210+ A , A , NULL , INFINITY , GrB_ALL , n , GrB_ALL , n , GrB_DESC_S )) ;
211+ OK (GrB_Matrix_assign_BOOL (
212+ S , A , NULL , (bool ) true, GrB_ALL , n , GrB_ALL , n , GrB_DESC_S )) ;
213+
214+ // compute the min spanning forest
215+ S_C = C = NULL ;
216+ // GxB_Global_Option_set(GxB_BURBLE, true);
217+ int result = LAGraph_msf (& C , A , false, msg ) ;
218+ // GxB_Global_Option_set(GxB_BURBLE, false);
219+ printf ("result: %d\n" , result ) ;
220+ OK (result );
221+
222+ // GxB_Global_Option_set(GxB_BURBLE, true);
223+ result = LAGraph_msf (& S_C , S , false, msg ) ;
224+ // GxB_Global_Option_set(GxB_BURBLE, false);
225+ printf ("result: %d\n" , result ) ;
226+ OK (result );
227+
228+ bool ok = false ;
229+ // check structure is equal.
230+ OK (LAGraph_Matrix_IsEqualOp (& ok , C , S_C , GrB_ONEB_BOOL , msg ));
231+ TEST_CHECK (ok );
232+ OK (GrB_free (& S )) ;
233+ OK (GrB_free (& S_C )) ;
234+ OK (GrB_free (& C )) ;
235+ OK (GrB_free (& A )) ;
236+ GrB_free (& zeroB );
237+ LAGraph_Finalize (msg ) ;
179238}
180239
181240//------------------------------------------------------------------------------
@@ -184,9 +243,9 @@ void test_msf (void)
184243
185244void test_errors (void )
186245{
187- #if LG_SUITESPARSE_GRAPHBLAS_V10
188246 LAGraph_Init (msg ) ;
189247
248+ #if LG_SUITESPARSE_GRAPHBLAS_V10
190249 // C and A are NULL
191250 int result = LAGraph_msf (NULL , NULL , true, msg ) ;
192251 TEST_CHECK (result == GrB_NULL_POINTER ) ;
@@ -197,20 +256,29 @@ void test_errors (void)
197256 TEST_CHECK (result == GrB_DIMENSION_MISMATCH ) ;
198257 OK (GrB_free (& A )) ;
199258
200- // A must be square
259+ // A must real
201260 OK (GrB_Matrix_new (& A , GxB_FC32 , 4 , 4 )) ;
202261 result = LAGraph_msf (& C , A , true, msg ) ;
203262 TEST_CHECK (result == GrB_DOMAIN_MISMATCH ) ;
263+
264+ #else
265+ // Not implemented
266+ OK (GrB_Matrix_new (& A , GrB_BOOL , 4 , 4 )) ;
267+ int result = LAGraph_msf (& C , A , true, msg ) ;
268+ TEST_CHECK (result == GrB_NOT_IMPLEMENTED ) ;
269+ #endif
204270
205271 OK (GrB_free (& A )) ;
206272 LAGraph_Finalize (msg ) ;
207- #endif
208273}
209274
210275//****************************************************************************
211276
212277TEST_LIST = {
278+ #if LG_SUITESPARSE_GRAPHBLAS_V10
213279 {"msf" , test_msf },
280+ {"inf_msf" , test_inf_msf },
281+ #endif
214282 {"msf_errors" , test_errors },
215283 {NULL , NULL }
216284};
0 commit comments